xtianmiller / emergence.js

Detect element visibility in the browser
https://xtianmiller.github.io/emergence.js/
MIT License
1.89k stars 62 forks source link

IntersectionObserver #14

Open thesnups opened 6 years ago

thesnups commented 6 years ago

Why not feature check for IntersectionObserver support and use it when available?

N1kto commented 6 years ago

IMHO this lib is kind of alternative to IntersectionObserver, so there is not much sense using the latter inside the lib. The value of this lib is that it serves same purposes as IntersectionObserver while grounding on very basic browser API and thus having much broader browser support.

I think it's up to consumer (you) to decide whether to use IntersectionObserver when it's available or this lib :)

mjsisley commented 6 years ago

As a counterpoint @N1kto, if this library feature checked IntersectionObserver and used it when available, you would get the assumed performance improvements of that API when available... but also achieve broader browser support by falling back to the methods currently in use here.

It is a further benefit to the consumer to not have to have multiple implementations within the codebase.

thesnups commented 6 years ago

I agree with @mjsisley. As a programmer I'd like to be able to code again a consistent API (e.g. the emergence.js API) whilst knowing that the performance benefits of IntersectionObserver are being leveraged when they are available.