mdgriffith / elm-animator

A timeline-based animation engine for Elm

Home Page:https://package.elm-lang.org/packages/mdgriffith/elm-animator/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Struggled to understand how to create helpers

lucamug opened this issue · comments

commented

I needed to change the scaleX and scaleY independently and it was not trivial to understand that is possible to create helpers like.

I think either adding this as example in the documentation or including the most important in the code could be beneficial for beginners.

scaleXY : Timeline state -> (state -> { x : Movement, y : Movement }) -> Html.Attribute msg
scaleXY timeline lookup =
    let
        pos =
            Animator.xy timeline lookup
    in
    Html.Attributes.style "transform"
        ("scaleX(" ++ String.fromFloat pos.x ++ ") scaleY(" ++ String.fromFloat pos.y ++ ")")

Thanks to @dmy to came out with the idea for this helper

Good call, the documentation could be clearer in showing people how to "manually" put these together.