shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
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
- target*-HTMLElement
The element to scroll to
- settings{}IScrollToSettings
Some settings to tweak the scroll behavior
Return
- -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
- $elmwindowHTMLElement
The element to scroll
- duration1000Number
The animation duration
- easingeaseInOutQuadFunction
An easing Function
- offsetX0Number
An offset to apply on the X axis
- offsetY0Number
An offset to apply on the Y axis
- align’start’String
The destination align (start, center, end)
- justify’start’String
The destination justify (start, center, end)
- forcefalseBoolean
Force the scroll even if the user is scrolling
- onFinish-Function
A callback to call when the animation if finished
Todo
- interfacenormal
- docnormal
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space