for more information visit the package's GitHub page
Package contains the following modules:
A simple library that will scroll to a position in an animated way.
elm install simplystuart/elm-scroll-to
ScrollTo.Status
in your model with ScrollTo.init
ScrollTo.Msg
messages with ScrollTo.update
ScrollTo.Msg
messages with ScrollTo.subscriptions
ScrollTo.toPosition
commandDefault animation:
Customize animations with:
withDelay : Float -> Status -> Status
withDuration : Float -> Status -> Status
withEasing : (Float -> Float) -> Status -> Status
-- MODEL
type alias Model =
{ scroll : ScrollTo.Status }
init : () -> ( Model, Cmd Msg )
init _ =
( { scroll = ScrollTo.init }, Cmd.none )
-- UPDATE
type Msg
= ClickScrollToTop
| ScrollMsg ScrollTo.Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
ClickScrollToTop ->
( model
, Cmd.map ScrollMsg <|
ScrollTo.toPosition { x = 0, y = 0 }
)
ScrollMsg scrollMsg ->
Tuple.mapBoth (\status -> { model | scroll = status })
(Cmd.map ScrollMsg)
(ScrollTo.update scrollMsg model.scroll)
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
ScrollTo.subscriptions ScrollMsg model.scroll
git clone https://github.com/simplystuart/elm-scroll-to.git
cd elm-scroll-to/examples
elm reactor
open http://localhost:8000