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

Evaluate IntersectionObserver support #56

Open
joshwnj opened this issue Dec 16, 2016 · 3 comments
Open

Evaluate IntersectionObserver support #56

joshwnj opened this issue Dec 16, 2016 · 3 comments

Comments

@joshwnj
Copy link
Owner

joshwnj commented Dec 16, 2016

Suggested by @Andarist in #54 (comment)

What would you say about implementing IntersectionObserver support? It could even be the default with scroll and interval being used only as a fallback settings. Its already implemented in 2 browsers.

https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API

It would be cool to try this, and compare to the current approach. We can try the polyfill for browsers that don't support it yet:

https://github.com/WICG/IntersectionObserver/tree/gh-pages/polyfill

http://caniuse.com/#search=Intersection

@Andarist
Copy link
Contributor

Andarist commented Dec 16, 2016

I might try to implement this in following week or so, no promises yet though.

NOTE (for myself): https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md - could be added too to the basic scroll listener
https://gist.github.com/threepointone/0564095704d76757c631b891f634899a - IntersectionObserver's example usage in React

@Andarist
Copy link
Contributor

Andarist commented Jan 4, 2017

Didnt have time to tackle this yet, if somebody wants to pick it up faster, I do not mind - if not, I will still try to do this when I have some spare time

@mshustov
Copy link

Actually I used in my project both react-visibility-sensor and IntersectionObserver (IO). So I have some notices. even if main functionality could be replaced, some API are incompatible.

  1. checking on startWatching ensures that API consumer gets isVisible status on componentDidMount, for example. but IntersectionObserver calls callback only when real status has changed (elements became visible/invisible)
  2. with IO containment must be ancestor of target element
    An IntersectionObserver with a root Element can observe any target Element that is a descendant of the root in the containing block chain.
  3. current implementation RVS works for hidden elements (for example, wrapped in element with display: none). IO doesn't work for hidden elements
  4. imho implementing things like partialVisibility='side' could be hard without changing rendering API. for getting more info check how algorithm works
    solution is possible with adding some intermediate threshold points, but seems to be performance overhead

Probably, I missed something else.
Any thoughts about feasibility such changes?

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

No branches or pull requests

3 participants