utils/dom/scroll
@ckeditor/ckeditor5-utils/src/dom/scroll
Filtering
Functions
-
scrollAncestorsToShowTarget( target, [ ancestorOffset ], [ limiterElement ] ) → void
module:utils/dom/scroll~scrollAncestorsToShowTarget
Makes any page
HTMLElement
orRange
(target) visible within its scrollable ancestors, e.g. if they haveoverflow: scroll
CSS style.Parameters
target : HTMLElement | Range
A target, which supposed to become visible to the user.
[ ancestorOffset ] : number
An offset between the target and the boundary of scrollable ancestors to be maintained while scrolling.
[ limiterElement ] : HTMLElement
The 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] } ) → void
module:utils/dom/scroll~scrollViewportToShowTarget
Makes any page
HTMLElement
orRange
(target
) visible inside the browser viewport. This helper will scroll alltarget
ancestors and the web browser viewport to reveal the target to the user. If thetarget
is already visible, nothing will happen.Type parameters
T : extends boolean
U : extends true
Parameters
options : object
Additional configuration of the scrolling behavior.
Properties[ options.alignToTop ] : T
When set
true
, the helper will make sure thetarget
is scrolled up to the top boundary of the viewport and/or scrollable ancestors if scrolled up. When not set (default), thetarget
will be revealed by scrolling as little as possible. This option will not affecttargets
that 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 ]
[ options.ancestorOffset ] : number
An offset from the boundary of scrollable ancestors (if any) the
target
will be moved by if the viewport is scrolled. It enhances the user experience by keeping thetarget
some distance from the edge of the ancestors and thus making it easier to read or edit by the user.[ options.forceScroll ] : U
When set
true
, thetarget
will be aligned to the top of the viewport and scrollable ancestors whether it is already visible or not. This option will only work whenalignToTop
istrue
options.target : HTMLElement | Range
A target, which supposed to become visible to the user.
[ options.viewportOffset ] : number | object
An offset from the edge of the viewport (in pixels) the
target
will be moved by if the viewport is scrolled. It enhances the user experience by keeping thetarget
some distance from the edge of the viewport and thus making it easier to read or edit by the user.
Returns
void
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.