phollyer/elm-motion/2.1.3

NOTE: the latest version is 3.0.4

Anim.Property.CustomColor

Animate any CSS color property not covered by the first-class property modules.

Default: transparent

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

Types

type alias Builder eng =
Builder eng

Builder type for custom color animations.

type alias AnimGroupName =
String

Type alias for the animation group name.

= AccentColor
| BackgroundColor
| BorderColor
| BorderTopColor
| BorderRightColor
| BorderBottomColor
| BorderLeftColor
| BorderBlockColor
| BorderBlockStartColor
| BorderBlockEndColor
| BorderInlineColor
| BorderInlineStartColor
| BorderInlineEndColor
| CaretColor
| ColumnRuleColor
| OutlineColor
| TextColor
| TextDecorationColor
| TextEmphasisColor
| Fill
| Stroke
| StopColor
| FloodColor
| LightingColor
| Custom String

A typed set of common color properties with a custom escape hatch.

Use the escape hatch Custom to animate any CSS color property not currently supported out of the box.

import Anim.Extra.Color as Color
import Anim.Property.CustomColor as CustomColor


CustomColor.begin (Custom "outline-color")
    >> CustomColor.to (Color.rgb 255 0 0)
    >> CustomColor.end

Initialize

AnimGroupName
-> Color
-> AnimBuilder eng
-> AnimBuilder eng

Set the initial color value.

Use this to initialize the property in your Engine's init function.

import Anim.Engine.* as Engine
import Anim.Extra.Color as Color
import Anim.Property.CustomColor as CustomColor


init : ( Model, Cmd Msg )
init =
    ( { animState =
            Engine.init
                [ CustomColor.init "box" BorderColor <|
                    Color.rgb 99 102 241
                ]
      }
    , Cmd.none
    )

Build

begin : ColorProperty -> AnimBuilder eng -> Builder eng

Begin the animation configuration by turning an AnimBuilder into a custom property animation Builder.

myAnimation : AnimBuilder eng -> AnimBuilder eng
myAnimation =
    CustomColor.begin TextColor
        >> CustomColor.to (Color.rgb 255 0 0)
        >> CustomColor.end
end : Builder eng -> AnimBuilder eng

Complete the animation configuration and return an AnimBuilder.

Configure

Start Value

When not set, the default will be used.

📖 See Start Values for details.

from : Color -> Builder eng -> Builder eng

Set the starting color value.

End Value

📖 See End Values for details.

to : Color -> Builder eng -> Builder eng

Set the target color value.

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 : () }

Set the animation speed (units per second).

Easing

📖 See Easing for details.

easing : Easing -> Builder eng -> Builder eng

Set the easing function.

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


CustomColor.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


CustomColor.spring Spring.wobbly

Snap

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

set : Color -> Builder eng -> Builder eng

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