How to limit viewport detection to only once #1428
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can see how it's done in lazy load images example. For example you can create directive and inject Then just subscribe for This is only one way how this could be achieved. There are many others. |
Beta Was this translation helpful? Give feedback.
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.