Skip to content

How to limit viewport detection to only once #1428

Answered by k3nsei
DevExplotel asked this question in Q&A
Discussion options

You must be logged in to vote

You can see how it's done in lazy load images example.

For example you can create directive and inject InViewportDirective using DI.
https://github.com/k3nsei/ng-in-viewport/blob/develop/projects/example/src/app/page-lazy-images/lazy-image.directive.ts#L39

Then just subscribe for inViewportAction.
https://github.com/k3nsei/ng-in-viewport/blob/develop/projects/example/src/app/page-lazy-images/lazy-image.directive.ts#L58

This is only one way how this could be achieved. There are many others.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DevExplotel
Comment options

Answer selected by k3nsei
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants