mdgriffith/elm-style-animation/3.5.5

NOTE: this package is not compatible with Elm 0.19.1

Animation

A library for animations.

Setting up an animation

type alias State =
Animation Never

Note - The compiler will refer to your Animation.State as Animation.Model.Animation msg

subscription : (Msg -> msgB) -> List (Animation msgA) -> Sub msgB

Create a subscription to AnimationFrame.times.

It is throttled based on whether the current animation is running or not.

type alias Msg =
Tick
render : Animation msgA -> List (Attribute msgB)

Render style properties into the style attribute and render other attributes as needed for svg.

Combine "transform" based properties into a single css property.

Combine "filter" based properties into a single css property.

Creating an animation

interrupt : List (Step msg) -> Animation msg -> Animation msg

Interrupt any running animations with the following animation.

queue : List (Step msg) -> Animation msg -> Animation msg

Add an animation to the queue, execiting once the current animation finishes

type alias Step =
Step Never
wait : Time -> Step msg
to : List Property -> Step msg

Animate to a set of target values, using the default interpolation.

toWith : Interpolation -> List Property -> Step msg

Animate to a set of target values. Use a temporary interpolation instead of the default. The interpolation will revert back to default after this step.

toWithEach : List ( Interpolation, Property ) -> Step msg

Animate to a set of target values. Use a temporary interpolation for each property instead of the default. The interpolation will revert back to default after this step.

set : List Property -> Step msg

Immediately set properties to a value.

repeat : Int -> List (Step msg) -> Step msg

Repeat a number of steps n times.

loop : List (Step msg) -> Step msg

Repeat a number of steps until interrupted.

update : Msg -> Animation msg -> Animation msg

Update an animation.

style : List Property -> Animation msg

Set an initial style for an animation.

Uses standard defaults for interpolation

styleWith : Interpolation -> List Property -> Animation msg

Set an initial style for an animation and override the standard default for interpolation.

styleWithEach : List ( Interpolation, Property ) -> Animation msg

Set an initial style for an animation and specify the interpolation to be used for each property.

Any property not listed will receive interpolation based on the standard defaults.

type alias Interpolation =
Interpolation
{ stiffness : Float
, damping : Float
}
-> Interpolation

Specify a custom Spring to animate with. To be used in conjunction with StyleWith, StyleWithEach, toWith, and toWithEach.

This should be your preferred interpolation to use.

{ duration : Time
, ease : Float -> Float
}
-> Interpolation

Specify a custom Easing to animate with. To be used in conjunction with StyleWith, StyleWithEach, toWith, and toWithEach.

The elm-community/easing-functions package has a bunch of useful easing functions!

speed : { perSecond : Float } -> Interpolation

Specify a speed to animate with. To be used in conjunction with StyleWith, StyleWithEach, toWith, and toWithEach.

Generally you don't want this. It's used in the special case of the default interpolation for rotation.

Use Animation.spring or Animation.easing instead as they are more powerful.

Animatable Properties

type alias Property =
Property
opacity : Float -> Property
type Length
top : Length -> Property
left : Length -> Property
bottom : Length -> Property
width : Length -> Property
height : Length -> Property
padding : Length -> Property
paddingLeft : Length -> Property
paddingRight : Length -> Property
paddingTop : Length -> Property
paddingBottom : Length -> Property
margin : Length -> Property
marginLeft : Length -> Property
marginRight : Length -> Property
marginTop : Length -> Property
marginBottom : Length -> Property
color : Color -> Property
backgroundColor : Color -> Property
borderColor : Color -> Property
borderWidth : Length -> Property
borderLeftWidth : Length -> Property
borderRightWidth : Length -> Property
borderTopWidth : Length -> Property
borderBottomWidth : Length -> Property
borderRadius : Length -> Property
borderTopLeftRadius : Length -> Property
borderTopRightRadius : Length -> Property
borderBottomLeftRadius : Length -> Property
borderBottomRightRadius : Length -> Property
shadow : Shadow -> Property
textShadow : Shadow -> Property

Text shadows will ignore the shadow's size value. This is just one of the bizarre quirks of CSS.

insetShadow : Shadow -> Property
display : DisplayMode -> Property
inline : DisplayMode
inlineBlock : DisplayMode
flex : DisplayMode
inlineFlex : DisplayMode
block : DisplayMode
none : DisplayMode
listItem : DisplayMode

Transforms

scale : Float -> Property
scale3d : Float -> Float -> Float -> Property
type Angle
rotate : Angle -> Property
rotate3d : Angle -> Angle -> Angle -> Property
translate : Length -> Length -> Property
translate3d : Length -> Length -> Length -> Property
transformOrigin : Length -> Length -> Length -> Property

Animatable CSS Filters

filterUrl : String -> Property

Create a CSS filter-url

blur : Length -> Property

Create a CSS blur filter, these stack with other filters.

brightness : Float -> Property

Create a CSS brightness filter, these stack with other filters.

contrast : Float -> Property

Create a CSS contrast filter, these stack with other filters.

grayscale : Float -> Property

Create a CSS grayscale filter, these stack with other filters.

greyscale : Float -> Property

Create a CSS grayscale filter, these stack with other filters. This is a spelling adjusment.

hueRotate : Angle -> Property

Create a CSS hue-rotation filter, these stack with other filters.

invert : Float -> Property

Create a CSS invert filter, these stack with other filters.

saturate : Float -> Property

Create a CSS saturate filter, these stack with other filters.

sepia : Float -> Property

Create a CSS sepia filter, these stack with other filters.

dropShadow : Shadow -> Property

Drop shadows will ignore the shadow's size value. This is just one of the bizarre quirks of CSS.

Animatable Svg Properties

viewBox : Float -> Float -> Float -> Float -> Property
fill : Color -> Property
stroke : Color -> Property
strokeWidth : Float -> Property
stopColor : Color -> Property

Used for svg gradients

offset : Float -> Property

Used for svg gradients. Accepts a number between 0 and 1.

x : Float -> Property
y : Float -> Property
cx : Float -> Property
cy : Float -> Property
radius : Float -> Property
radiusX : Float -> Property
radiusY : Float -> Property
points : List ( Float, Float ) -> Property

Used with the svg polygon element

Constructing an Svg Path

path : List PathCommand -> Property

To be used with the svg path element. Renders as the d property.

type alias PathStep =
PathCommand
move : Float -> Float -> PathCommand
moveTo : Float -> Float -> PathCommand
line : Float -> Float -> PathCommand
lineTo : Float -> Float -> PathCommand
horizontal : Float -> PathCommand
horizontalTo : Float -> PathCommand
vertical : Float -> PathCommand
verticalTo : Float -> PathCommand
close : PathCommand

Close a Path

type alias QuadraticCurve =
{ control : ( Float, Float )
, point : ( Float, Float )
}
curve : QuadraticCurve -> PathCommand

Create a relative curve with 1 control point and a target point. This is a Quadratic curve in teh svg spec.

curveTo : QuadraticCurve -> PathCommand

Create an absolute curve with 1 control point and a target point. This is a Quadratic curve in teh svg spec.

type alias CubicCurve =
{ control1 : ( Float, Float )
, control2 : ( Float, Float )
, point : ( Float, Float )
}
curve2 : CubicCurve -> PathCommand

Create a relative Curve with 2 control points and a target point. This is a Cubic Curve in the svg spec.

curve2To : CubicCurve -> PathCommand

Create an absolute Curve with 2 control points and a target point. This is a Cubic Curve in the svg spec.

arc : Arc -> PathCommand
type alias Arc =
{ x : Float
, y : Float
, radius : Float
, startAngle : Float
, endAngle : Float
, clockwise : Bool
}

Units

px : Float -> Length
percent : Float -> Length
em : Float -> Length
rem : Float -> Length
turn : Float -> Angle
deg : Float -> Angle
grad : Float -> Angle
rad : Float -> Angle

Advanced

exactly : String -> String -> Property

Set a non-numerical to an exact value. This is generally only used with Animation.set.

For example

Animation.set
    [ Animation.exactly "border-style" "dashed"
    ]
custom : String -> Float -> String -> Property

Animate a custom style property by providing it's name, a float value, and the units it should have.

custom2 : String -> ( Float, String ) -> ( Float, String ) -> Property
customColor : String -> Color -> Property
attr : String -> Float -> String -> Property

Animate a custom attribute by providing it's name, a float value, and the units it should have.

attr2 : String -> ( Float, String ) -> ( Float, String ) -> Property
String
-> ( Float, String )
-> ( Float, String )
-> ( Float, String )
-> Property
String
-> ( Float, String )
-> ( Float, String )
-> ( Float, String )
-> ( Float, String )
-> Property
attrColor : String -> Color -> Property