utils/dom/scroll
Type Definitions
module:utils/dom/scroll~IfTrue
Functions
scrollAncestorsToShowTarget( target, [ ancestorOffset ], [ limiterElement ] ) → voidmodule:utils/dom/scroll~scrollAncestorsToShowTargetMakes any page
HTMLElementorRange(target) visible within its scrollable ancestors, e.g. if they haveoverflow: scrollCSS style.Parameters
target : HTMLElement | RangeA target, which supposed to become visible to the user.
[ ancestorOffset ] : numberAn offset between the target and the boundary of scrollable ancestors to be maintained while scrolling.
[ limiterElement ] : HTMLElementThe outermost ancestor that should be scrolled. If specified, it can prevent scrolling the whole page.
Returns
void
scrollViewportToShowTarget( options = { [options.alignToTop], [options.ancestorOffset], [options.forceScroll], options.target, [options.viewportOffset] } ) → voidmodule:utils/dom/scroll~scrollViewportToShowTargetMakes any page
HTMLElementorRange(target) visible inside the browser viewport. This helper will scroll alltargetancestors and the web browser viewport to reveal the target to the user. If thetargetis already visible, nothing will happen.Type parameters
T : extends booleanU : extends true
Parameters
options : objectAdditional configuration of the scrolling behavior.
Properties[ options.alignToTop ] : TWhen set
true, the helper will make sure thetargetis scrolled up to the top boundary of the viewport and/or scrollable ancestors if scrolled up. When not set (default), thetargetwill be revealed by scrolling as little as possible. This option will not affecttargetsthat must be scrolled down because they will appear at the top of the boundary anyway.scrollViewportToShowTarget() with scrollViewportToShowTarget() with Initial state alignToTop unset (default) alignToTop = true ┌────────────────────────────────┬─┐ ┌────────────────────────────────┬─┐ ┌────────────────────────────────┬─┐ │ │▲│ │ │▲│ │ [ Target to be revealed ] │▲│ │ │ │ │ │ │ │ │ │ │ │█│ │ │ │ │ │ │ │ │█│ │ │ │ │ │ │ │ │ │ │ │█│ │ │ │ │ │ │ │ │█│ │ │█│ │ │ │ │ │ │ │ │█│ │ │▼│ │ [ Target to be revealed ] │▼│ │ │▼│ └────────────────────────────────┴─┘ └────────────────────────────────┴─┘ └────────────────────────────────┴─┘ [ Target to be revealed ]Copy code[ options.ancestorOffset ] : numberAn offset from the boundary of scrollable ancestors (if any) the
targetwill be moved by if the viewport is scrolled. It enhances the user experience by keeping thetargetsome distance from the edge of the ancestors and thus making it easier to read or edit by the user.Defaults to
0[ options.forceScroll ] : UWhen set
true, thetargetwill be aligned to the top of the viewport and scrollable ancestors whether it is already visible or not. This option will only work whenalignToTopistrueoptions.target : HTMLElement | RangeA target, which supposed to become visible to the user.
[ options.viewportOffset ] : number | objectAn offset from the edge of the viewport (in pixels) the
targetwill be moved by if the viewport is scrolled. It enhances the user experience by keeping thetargetsome distance from the edge of the viewport and thus making it easier to read or edit by the user.Defaults to
0
Returns
void