A simple fire-and-forget scroll command.
Choose this engine when you just want to trigger a scroll and move on.
📖 See Scroll Cmd Engine Documentation and Scroll Overview for details.
Use the Builder module to configure scroll targets.
Start a scroll as a fire-and-forget Cmd.
import Scroll.Engine.Cmd as Cmd
type Msg
= ScrollCompleted
| ...
Cmd.scroll ScrollCompleted <|
scrollToElement "target-section"If you need progress, cancellation, or safe retriggering, use Scroll.Engine.Sub instead.
📖 See Timing for details.
Set the delay for all scrolls.
This will be inherited by all scrolls that don't define their own delay.
import Scroll.Builder as Scroll
import Scroll.Engine.Cmd as Cmd
scrollToElement : String -> ScrollBuilder -> ScrollBuilder
scrollToElement elementId =
Cmd.delay 100
>> Scroll.forDocument
>> Scroll.toElement elementId
>> Scroll.speed 200
>> Scroll.buildSet the duration of all scrolls.
This will be inherited by all scrolls that don't define their own duration.
import Scroll.Builder as Scroll
import Scroll.Engine.Cmd as Cmd
scrollToElement : String -> ScrollBuilder -> ScrollBuilder
scrollToElement elementId =
Cmd.duration 1000
>> Scroll.forDocument
>> Scroll.toElement elementId
>> Scroll.buildSet the speed that scrolls should run at.
This will be inherited by all scrolls that don't define their own speed.
import Scroll.Builder as Scroll
import Scroll.Engine.Cmd as Cmd
scrollToElement : String -> ScrollBuilder -> ScrollBuilder
scrollToElement elementId =
Cmd.speed 200
>> Scroll.forDocument
>> Scroll.toElement elementId
>> Scroll.build📖 See Easing for details.
Set the easing function to be used by all scrolls.
This will be inherited by all scrolls that don't define their own easing.
import Motion.Easing exposing (Easing(..))
import Scroll.Builder as Scroll
import Scroll.Engine.Cmd as Cmd
scrollToElement : String -> ScrollBuilder -> ScrollBuilder
scrollToElement elementId =
Cmd.easing BounceOut
>> Scroll.forDocument
>> Scroll.toElement elementId
>> Scroll.speed 200
>> Scroll.build
Builder type for scroll animations.