-
Notifications
You must be signed in to change notification settings - Fork 91
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
New API: watchElement for classes with no mixin #185
Conversation
I like the idea 💯 I dislike names for const viewportWatcher = this.inViewport.watchElement(element);
viewportWatcher.onEnter(() => {
// do sth here
});
viewportWatcher.onLeave(() => {
// do sth here
});
this.inViewport.unwatchElement(viewportWatcher); Just food for thought. |
@gossi I like returning an object to do the job! As long as we add the callbacks before the actual "watching" occurs (we have it wrapped with |
What happens internally... happens internally ;) I dunno what it is, I can solely think about the API. One addition, I guess it should be: |
Updated README to include a note about that second argument of options 👍. Thx for all the suggestions @gossi. Lmk if you notice anything else! |
@gossi Merged to master. Lmk if you have other feedback. Otherwise bump a minor release on Friday or so! |
@gossi 👋 again! This PR adds the ability to use classes if your target browser supports IntersectionObserver (e.g. not Safari). I likely won't merge this until we can at least support rAF, but wanted to get your feedback first. Thoughts on naming?
This PR adds three user facing APIs.
watchElement
addEnterCallback
addExitCallback