electerious / basicScroll

Standalone parallax scrolling for mobile and desktop with CSS variables.
https://basicscroll.electerious.com
MIT License
3.63k stars 148 forks source link

Move to Intersection Observer API #55

Closed FYITom closed 4 years ago

FYITom commented 4 years ago

Rather than using getBoundingClientRect() move to the much more performant Intersection Observer API. It will also make calculations easier too.

electerious commented 4 years ago

I'm not sure if that's possible because basicScroll allows you to start and stop animating elements that aren't in the viewport (or become visible during the animation). It's not planned from my side, but it would be cool to see a proof of concept.

garrylachman commented 3 years ago

Intersection Observer API exists to detect elements that displayed/going to be displayed or not... you can set the threshold of the visibility... check this impl: https://github.com/wes337/io-animate/blob/master/src/index.js