phollyer/elm-motion/2.1.3

NOTE: the latest version is 3.0.4

Anim.Property.Skew

Skew elements along the X and Y axes.

Default: 0 degrees for both axes

When no start value is configured for any axis, the default will be used.

Types

type alias Builder eng =
SkewBuilder eng

Builder type for skew animations.

type alias AnimGroupName =
String

Type alias for the animation group name.

Initialize

initXY : AnimGroupName -> Float -> Float -> AnimBuilder eng -> AnimBuilder eng

Set the initial X and Y skew.

import Anim.Engine.* as Engine
import Anim.Property.Skew as Skew


init : ( Model, Cmd Msg )
init =
    ( { animState = Engine.init [ Skew.initXY "animGroupName" 12 6 ] }
    , Cmd.none
    )
initX : AnimGroupName -> Float -> AnimBuilder eng -> AnimBuilder eng

Set the initial X skew.

import Anim.Engine.* as Engine
import Anim.Property.Skew as Skew


init : ( Model, Cmd Msg )
init =
    ( { animState = Engine.init [ Skew.initX "animGroupName" 12 ] }
    , Cmd.none
    )
initY : AnimGroupName -> Float -> AnimBuilder eng -> AnimBuilder eng

Set the initial Y skew.

import Anim.Engine.* as Engine
import Anim.Property.Skew as Skew


init : ( Model, Cmd Msg )
init =
    ( { animState = Engine.init [ Skew.initY "animGroupName" 8 ] }
    , Cmd.none
    )

Build

begin : AnimBuilder eng -> Builder eng

Turn the AnimBuilder into a skew animation Builder for the specified animation group.

Use this to start configuring a skew animation.

myAnimation : AnimBuilder eng -> AnimBuilder eng
myAnimation =
    Skew.begin
        >> ... -- Configure and build the animation
end : Builder eng -> AnimBuilder eng

Complete the Builder animation configuration and return an AnimBuilder so you can continue configuring other property animations or execute the animation with an Engine.

myAnimation : AnimBuilder eng -> AnimBuilder eng
myAnimation =
    Skew.begin
        >> ... -- configure the animation with from, to, duration, easing, etc.
        >> Skew.end
        >> ... -- continue with animation

Configure

Start Value

When not set, the default will be used.

📖 See Start Values for details.

fromXY : Float -> Float -> Builder eng -> Builder eng

Set the starting X and Y skew (degrees).

fromX : Float -> Builder eng -> Builder eng

Set the starting X skew (degrees). Y is left unchanged (or 0 if not set).

fromY : Float -> Builder eng -> Builder eng

Set the starting Y skew (degrees). X is left unchanged (or 0 if not set).

End Value

📖 See End Values for details.

Absolute

toXY : Float -> Float -> Builder eng -> Builder eng

Set the target X and Y skew (degrees).

toX : Float -> Builder eng -> Builder eng

Set the target X skew (degrees). Y is left unchanged (or 0 if not set).

toY : Float -> Builder eng -> Builder eng

Set the target Y skew (degrees). X is left unchanged (or 0 if not set).

Relative

Move by a delta instead of to a fixed skew. The end value is current + delta where current is the live animated skew.

Only available on the Sub and WAAPI engines. Using these with any other engine results in a type error.

byXY : Float -> Float -> Builder eng -> Builder eng

Move by a delta on the X and Y axes.

byX : Float -> Builder eng -> Builder eng

Move by a delta on the X axis. Y is unaffected.

byY : Float -> Builder eng -> Builder eng

Move by a delta on the Y axis. X is unaffected.

Timing

📖 See Animation Timing for details.

Int
-> Builder { eng | withTiming : () }
-> Builder { eng | withTiming : () }

Set the delay (milliseconds) before the animation starts.

Int
-> Builder { eng | withTiming : () }
-> Builder { eng | withTiming : () }

Set the animation duration (milliseconds).

Float
-> Builder { eng | withTiming : () }
-> Builder { eng | withTiming : () }

The speed represents how many degrees the skew changes per second.

For example, a skew animation from 0 to 30 degrees with a speed of 15.0 will take 2 seconds to complete.

Easing

📖 See Easing for details.

easing : Easing -> Builder eng -> Builder eng

Set the easing function for the animation.

import Motion.Easing exposing (Easing(..))


Skew.easing EaseInOut

Spring

📖 See Spring for details.

Spring
-> Builder { eng | withSpring : () }
-> Builder { eng | withSpring : () }

Drive this property with a spring.

import Motion.Spring as Spring


Skew.spring Spring.wobbly

Clamping

Keep skew values on each axis within a range you choose.

Values outside the range are clamped to the nearest boundary.

The range stays in effect for future animations until you Unclamp it:

update msg model =
    case msg of
        TiltChanged xDeg yDeg ->
            let
                ( animState, cmd ) =
                    WAAPI.animate model.animState <|
                        Skew.begin
                            >> Skew.clampX -30 30
                            >> Skew.clampY -30 30
                            >> Skew.end
            in
            ( { model | animState = animState }
            , cmd
            )

Clamp

clampX : Float -> Float -> Builder eng -> Builder eng

Keep the X axis skew within min and max values. If min > max the values are flipped.

clampY : Float -> Float -> Builder eng -> Builder eng

Keep the Y axis skew within min and max values. If min > max the values are flipped.

Unclamp

unclampX : Builder eng -> Builder eng

Remove the X axis range for this animation group. Does nothing if no range is set.

unclampY : Builder eng -> Builder eng

Remove the Y axis range for this animation group. Does nothing if no range is set.

Snap

Snap to a specific skew, cancelling any in-flight animation on this property.

setXY : Float -> Float -> Builder eng -> Builder eng

Snap target X and Y skew angles.

setX : Float -> Builder eng -> Builder eng

Snap target X angle, preserving the current Y angle.

setY : Float -> Builder eng -> Builder eng

Snap target Y angle, preserving the current X angle.