-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy load image does not work with preboot #327
Comments
Hi @lares83, Thanks for letting me know. This is a quite tricky issue since there is no way to know when the image becomes visible. A quickfix is to set One way to fix it is to listen for the constructor() {
this.scrollAndPrebootComplete$ = Observable.merge(
Observable.fromEvent(window, 'scroll'),
Observable.fromEvent(window, 'PrebootComplete')
);
} And then in the template: <img [lazyLoad]="lazyLoadImage" [scrollObservable]="scrollAndPrebootComplete$" /> You could easily create a custom component that wraps Another solution is to use |
That's actually a bug, it shouldn't be happening. I'll open a separate issue for it. |
I'm closing this. Let me know it the proposed solution above didn't work. |
Preboot (https://github.com/angular/preboot) makes the whole app is not visible at start which causes lazy load component not to load image - function
isVisible
returns false.fromElement
inrect.ts
usesgetBoundingClientRect
which in this case returns 0 dimensions.Quick workaround is to set
offset
attribute to e.g.1
which makesintersectsWith
returntrue
.The text was updated successfully, but these errors were encountered: