andrewMacmurray/elm-simple-animation/2.0.3

NOTE: the latest version is 2.3.2

Simple.Animation

Build an Animation for rendering on the page

Create an Animation

type alias Animation =
Animation

Animation to be rendered with Simple.Animation.Animated functions

type alias Millis =
Millis

Time unit for all Animations

{ duration : Millis
, options : List Option
}
-> List Property
-> List Property
-> Animation

Create an animation with start and end properties:

import Simple.Animation as Animation exposing (Animation)
import Simple.Animation.Property as P


fadeOut : Animation
fadeOut =
    Animation.fromTo
        { duration = 1000
        , options = []
        }
        [ P.opacity 1 ]
        [ P.opacity 0 ]
{ startAt : List Property
, options : List Option
}
-> List Step
-> Animation

Create an animation with multiple steps:

import Simple.Animation as Animation exposing (Animation)
import Simple.Animation.Property as P


backAndForth : Animation
backAndForth =
    Animation.steps
        { startAt = [ P.x 0 ]
        , options = []
        }
        [ Animation.step 1000 [ P.x 100 ]
        , Animation.step 1000 [ P.x 0 ]
        ]

Steps

Build up a multi step animation

type Step
step : Millis -> List Property -> Step

Animate to a list of properties for a given number of milliseconds:

Animation.step 1000 [ P.opacity 1 ]
set : List Property -> Step

Set a list of properties immediately in an animation (This is equivalent to step 1):

Animation.set [ P.opacity 0 ]
wait : Millis -> Step

Wait for a given number of milliseconds before animating the next properties:

Animation.wait 1000
waitTillComplete : Animation -> Step

Wait for another animation to complete before animating the next properties:

This animation will wait for 1500 milliseconds before animating to the next step

import Simple.Animation as Animation exposing (Animation)
import Simple.Animation.Property as P


finishAfterFadeOut : Animation
finishAfterFadeOut =
    Animation.steps
        { startAt = [ P.x 0 ]
        , options = []
        }
        [ Animation.step 500 [ P.x 20 ]
        , Animation.waitTillComplete fadeOut
        , Animation.step 500 [ P.x 60 ]
        ]


fadeOut : Animation
fadeOut =
    Animation.fromTo
        { duration = 2000
        , options = []
        }
        [ P.opacity 1 ]
        [ P.opacity 2 ]

Options

Customise the feel and behaviour of an animation

type alias Option =
Option
loop : Option

Repeat an animation forever

count : Int -> Option

Play an animation a given number of times

delay : Millis -> Option

Delay the start of an animation (repeats like loop or count are not affected by this)

Standard Eases

Standard CSS eases

linear : Option
easeIn : Option
easeOut : Option
easeInOut : Option
cubic : Float -> Float -> Float -> Float -> Option

Extended Eases

See what these eases look and feel like: https://easings.net

easeInSine : Option
easeOutSine : Option
easeInOutSine : Option
easeInQuad : Option
easeOutQuad : Option
easeInOutQuad : Option
easeInCubic : Option
easeOutCubic : Option
easeInQuart : Option
easeOutQuart : Option
easeInQuint : Option
easeOutQuint : Option
easeInExpo : Option
easeOutExpo : Option
easeInOutExpo : Option
easeInCirc : Option
easeOutCirc : Option
easeInOutCirc : Option
easeInBack : Option
easeOutBack : Option
easeInOutBack : Option

Duration

duration : Animation -> Millis

Get the duration of an animation