andrewMacmurray / elm-simple-animation

stateless animation utils for Elm
https://package.elm-lang.org/packages/andrewMacmurray/elm-simple-animation/latest/
MIT License
50 stars 3 forks source link

Yoyo animation #3

Closed andrewMacmurray closed 3 years ago

andrewMacmurray commented 3 years ago

Could be nice to have an option to make an animation yoyo back to it's first frame

For something like this animation:

2021-01-03 13 22 52

Instead of writing:

pulseOpacity : Animation
pulseOpacity =
    Animation.steps
        { startAt = [ P.opacity 1 ]
        , options = [ Animation.loop ]
        }
        [ Animation.step 800 [ P.opacity 0 ]
        , Animation.step 800 [ P.opacity 1 ]
        ]

You could have a shorthand like:

pulseOpacity : Animation
pulseOpacity =
    Animation.fromTo
        { duration = 800
        , options = [ Animation.loop, Animation.yoyo ]
        }
        [ P.opacity 1 ]
        [ P.opacity 0 ]