LottieFiles / lottie-interactivity

A small javascript library to enable interactivity with Lottie animations
https://lottiefiles.com/interactivity
MIT License
430 stars 55 forks source link

Change Scroll Event to Intersection Observer #100

Closed armanogan closed 1 year ago

armanogan commented 1 year ago

Overview

...

Motivation

Hey,

What is the purpose of using scroll event instead of Intersection Observer(https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API). Scroll event is working in the main thread , Intersection Observer is out of main thread and this small code reflow all the page on every scroll https://github.com/LottieFiles/lottie-interactivity/blob/7fc80bf513b6f9e05bc5025f867c3ccce0eae52e/src/main.js#L64 .You don`t even if use requestAnimationFrame in the scroll.

Even if you are going to do it with scroll why you aren't passing argument passive:false(not passing that argument is bad practice)?

Why you aren't caching variables window.innerHeight and window.innerWidth and change them after window resize?

I like this project. but the performance is very poor. ...

Labels

samuelOsborne commented 1 year ago

Thanks for your feedback @armanogan ! I'll look in to this when we start working on the next version :)

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.