linuss / smooth-scroll / SmoothScroll

Config


type alias Config =
{ offset : Basics.Int
, speed : Basics.Int
, easing : Ease.Easing 
}

Configuration options for smooth scrolling. Has three options:

defaultConfig : Config

import SmoothScroll

defaultConfig : Config
defaultConfig =
    { offset = 12
    , speed = 200
    , easing = Ease.outQuint
    }

Scrolling

scrollTo : String -> Task Browser.Dom.Error (List ())

Scroll to the element with the given id, using the default configuration

import SmoothScroll

scrollTo "article"

scrollToWithOptions : Config -> String -> Task Browser.Dom.Error (List ())

Scroll to the element with the given id, using a custom configuration

import SmoothScroll exposing (defaultConfig)

scrollToWithOptions { defaultConfig | offset = 60 } "article"