Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@ng-web-apis/intersection-observer
Advanced tools
A library for declarative use of Intersection Observer API with Angular
Part of Web APIs for Angular
This is a library for declarative use of Intersection Observer API with Angular.
If you do not have @ng-web-apis/common:
npm i @ng-web-apis/common
Now install the package:
npm i @ng-web-apis/intersection-observer
waIntersectionRoot
directive to designate root element
for observer.waIntersectionObserver
directive to observe an element:<section waIntersectionRoot>
<h1 waIntersectionThreshold="0.5" (waIntersectionObserver)="onIntersection($event)">
I'm being observed
</h1>
</section>
Use waIntersectionThreshold
and waIntersectionRootMargin
attributes to configure
IntersectionObserver options
NOTE: Keep in mind these are used one time in constructor so you cannot use binding, only strings. Pass coma separated numbers to set an array of thresholds.
Alternatively you can use Observable
-based IntersectionObserverService
and provide tokens
INTERSECTION_ROOT_MARGIN
and INTERSECTION_THRESHOLD
manually:
@Component({
selector: 'my-component',
providers: [
IntersectionObserverService,
{
provide: INTERSECTION_THRESHOLD,
useValue: 0.5,
},
],
})
export class MyComponent {
constructor(
@Inject(IntersectionObserverService) entries$: IntersectionObserverService,
) {
entries$.subscribe(entries => {
// This will trigger once my-component becomes half way visible
// in parent element designated with waIntersectionRoot directive
// Don't forget to unsubscribe
console.log(entries);
});
}
}
15+ | 55+ | 51+ | 12.2+ |
You can use polyfill to support older browsers
You can try online demo here
Other Web APIs for Angular by @ng-web-apis
Do you also want to open-source something, but hate the collateral work? Check out this Angular Open-source Library Starter we’ve created for our projects. It got you covered on continuous integration, pre-commit checks, linting, versioning + changelog, code coverage and all that jazz.
FAQs
A library for declarative use of Intersection Observer API with Angular
The npm package @ng-web-apis/intersection-observer receives a total of 18,629 weekly downloads. As such, @ng-web-apis/intersection-observer popularity was classified as popular.
We found that @ng-web-apis/intersection-observer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.