Skip to content
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

Example of lazy loading when element is scrolled into viewport? #1326

Closed
mspanish opened this issue Apr 8, 2018 · 3 comments
Closed

Example of lazy loading when element is scrolled into viewport? #1326

mspanish opened this issue Apr 8, 2018 · 3 comments

Comments

@mspanish
Copy link

mspanish commented Apr 8, 2018

Hello I've seen the actions for components, and in the issue for this addition here - #1247 - and while it mentions the idea of using a lazyload, from the samples here I'm not sure how one would actually go about adding a lazy load for items. I have a gallery of icons - and by default I load 50 of them when the user loads the collection, but I'd like to load additional icons as the user scrolls down. My old app uses a jQuery lazy loading plugin to do this. Anybody have something like that already going in Svelte? Thanks!

@Rich-Harris
Copy link
Member

This is a fairly crude example — a more sophisticated one might include things like a configurable rootMargin, and a controlled fade in etc. But it illustrates the general idea. Note that it's using IntersectionObserver which needs a polyfill in some browsers

@mspanish
Copy link
Author

mspanish commented Apr 8, 2018

thanks a lot @Rich-Harris I will try implementing that later today. Got a little bogged down in my SVG parsing algos, but hope to get back to the UI => Svelte conversion shortly!

@Rich-Harris
Copy link
Member

Closing this as no action required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants