airbnb / lottie-web

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
MIT License
30.45k stars 2.87k forks source link

Load animation when you scroll the page #2131

Open jeansevilla opened 4 years ago

jeansevilla commented 4 years ago

Hi, i have a problem, the animation doesn't start when you scroll and se the objects, but its start when you refresh the page, how can I change?

Thank you (I'm not a coder so if I can have a simple examples, thank you)

 <div id="face"></div>
          <script src="js/lottie.js" ></script> 
          <script>
let anim= lottie.loadAnimation({
container: document.getElementById('face'),
renderer: 'svg',
loop: true,
autoplay: false,
path: 'JS/face.json',
});
anim.addEventListener('DOMLoaded', (e) => {
anim.playSegments([[0,125],[50,125]], true);

</script> 
bodymovin commented 4 years ago

Hi, you can search for libraries that hook to the scroll movement and fire events that you can use to trigger animations. but this library doesn't take care of that part.

jeansevilla commented 4 years ago

Hi, you can search for libraries that hook to the scroll movement and fire events that you can use to trigger animations. but this library doesn't take care of that part.

ok but why if I put the animation in autoplay does the animation start when one displays the object? I would like the same effect as when it is set to autoplay but with playsegment. Thank you

bodymovin commented 4 years ago

sorry, I don't follow what you are trying to achieve and the problem you are facing. Can you describe it further?