mdgriffith / elm-style-animation

The style animation library for Elm!
http://package.elm-lang.org/packages/mdgriffith/elm-style-animation/latest
BSD 3-Clause "New" or "Revised" License
441 stars 41 forks source link

Expose `isRunning`? #61

Closed jesse-c closed 6 years ago

jesse-c commented 6 years ago

Would you be open to exposing the isRunning function? My use case is, that when an animation has finished (i.e. opacity 1 → opacity 0), then I'd like to hide the element. To do that I need to know when the animation has finished.

I tried animating the DisplayMode property from noneblock, but it didn't work, as the display property was never changed.

        Animation.styleWith
            (Animation.easing
                { duration = 400 * Time.millisecond
                , ease = identity
                }
            )
            [ Animation.opacity 0.0, Animation.display Animation.none ]
                            Animation.interrupt
                                [ Animation.to
                                    [ Animation.opacity 0
                                    , Animation.display Animation.none
                                    ]
                                ]
                    Animation.interrupt
                        [ Animation.to
                            [ Animation.opacity 1
                            , Animation.display Animation.block
                            ]
                        ]
mdgriffith commented 6 years ago

Yeah, it's a bit unintuitive, but you'll need to use Animation.set in order to set display.

Animation.interrupt
    [ Animation.to
        [ Animation.opacity 1
        ]
    , Animation.set
        [ Animation.display Animation.block
        ]
    ]

Small history on why isRunning is not exposed

jesse-c commented 6 years ago

Ah, okay! Thank you @mdgriffith. It's working a bit better now—showing the item isn't particularly smooth, but hiding it is. Update: Ordering of styles is important!