-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
inView
lifecycle method
#6443
Comments
How actually do we detect that a component comes into the viewport? IntersectionObserver relies on observing a DOM element. Since a component can have multiple root elements, should we trigger the There seems to be a lot of unknowns here, which I think should be handled off to a library or a custom action, like svelte-inview. |
We could define that in some sort of config object or even in the DOM elements itself. I wasn't aware of svelte-inview . Thanks for that. |
Sounds like a perfect use case for a Svelte action :) Personally I find the API from svelte-inview much easier to work with, than having an |
you can implement your own action, and there's no plan of having any built-in actions within Svelte right now. |
Is your feature request related to a problem? Please describe.
Not really a problem. Rather a convenience thing.
Describe the solution you'd like
A method namely
inView()
that will run whenever the component came into the viewport. It could use IntersectionObserver behind the scene.Describe alternatives you've considered
Currently, I can use an component around the component I want to listen to.
How important is this feature to you?
For me, it will be a welcoming feature. Whatever projects I do more often than not it involves some use of IntersectionObserver.
The text was updated successfully, but these errors were encountered: