scrollTo

Type:Function
Status:stable
Since:2.0.0
Platform:js
@blackbyte.sugar.js.dom.scroll

Function that let you make a smooth page scroll to a specific element in the page

Params

  1. target*-HTMLElement

    The element to scroll to

  2. settings{}IScrollToSettings

    Some settings to tweak the scroll behavior

Return

  1. -Promise

    A promise resolved once the scroll has ended

Example

import { scrollTo } from '@coffeekraken/sugar/dom'
import { easeInOutQuad } from '@coffeekraken/sugar/easing'
scrollTo(myCoolHTMLElement);

Settings

  1. $elmwindowHTMLElement

    The element to scroll

  2. duration1000Number

    The animation duration

  3. easingeaseInOutQuadFunction

    An easing Function

  4. offsetX0Number

    An offset to apply on the X axis

  5. offsetY0Number

    An offset to apply on the Y axis

  6. align’start’String

    The destination align (start, center, end)

  7. justify’start’String

    The destination justify (start, center, end)

  8. forcefalseBoolean

    Force the scroll even if the user is scrolling

  9. onFinish-Function

    A callback to call when the animation if finished

Todo

  • interfacenormal
  • docnormal
  • testsnormal