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

Restart Animation with "play" type #90

Closed MATTiVOLTARii closed 2 years ago

MATTiVOLTARii commented 2 years ago

there doesn't seem to be a way to restart a lottie in the "play" type.

In my use case, I try to make a lottie play when it is visible, to make it invisible again when I scroll up (is there a way to connect playing backwards with the "seek" type?) and when I scroll down the lottie should play again

Type

Labels

samuelOsborne commented 2 years ago

@MATTiVOLTARii Can you please link your LottieInteractivity code setup?

MATTiVOLTARii commented 2 years ago

@MATTiVOLTARii Can you please link your LottieInteractivity code setup?

i tried something like this:

LottieInteractivity.create({ mode:"scroll", player:"#lottie_demo_prototyp", container:"#section", actions: [ { visibility: [0.1, 0.3], type: "play", },{
visibility: [0.1, 0.3], type: "seek", frames: [0, 79] } ]
});

samuelOsborne commented 2 years ago

@MATTiVOLTARii I think your setup needs changing, can you try something like this:

LottieInteractivity.create({
     mode:"scroll",
     player:player,
         actions: [
         {           
              visibility: [0.1, 0.3],
            type: "seek",
            frames: [0, X]
         },
         {
              visibility: [0.4, 1],
            type: "loop",
           frames: [X, X]
         }
     ]  
 }); 
MATTiVOLTARii commented 2 years ago

Here is the animation: https://di-gi.de/ You can see it in the smartphone animation about halfway down the site.

It should be like this: If the Lottie is in the viewport it should play - it does. when scrolling up, it should play back in type "seek". Once the lottie is back in the viewport it should start playing again.

The rewind with the "seek" is not absolutely necessary. But it would be great if the animation played back as soon as you scrolled in from above. With loop, the animation plays repeatedly. I just want the "play" to be triggered only once when entering the viewport from above. But every time I come down from above and not just once for visiting the website.

I hope this is understandable.

github-actions[bot] commented 2 years 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.