defaultScrollTarget

Utilities for working with scrolling

API

canScrollInDirection(target, orientation, downOrRight) static method

Returns true if the given target or any of its ancestors can be scrolled in the indicated direction.

This is used, e.g., by gesture event handlers to predict if the default behavior for a given event is likely to result in scrolling.

Parameters:

  • target: EventTarget
  • orientation: 'horizontal'|'vertical'
  • downOrRight: boolean

defaultScrollTarget(element) static method

This helper returns a guess as to what portion of the given element can be scrolled. This is used by CursorInViewMixin to provide a default implementation of [scrollTarget].

If the element has a shadow root containing a default (unnamed) slot, this returns the first ancestor of that slot that has either overflow-x or overflow-y styled as auto or scroll. If the element has no default slot, or no scrolling ancestor is found, the element itself is returned.

Parameters:

  • element: Element– the component to examine for a scrolling element

Returns: Element

getScrollableElement(node) static method

If the given element can be scrolled, return that. If not, return the closest ancestor that can be scrolled. If no such ancestor is found, return null.

Parameters:

  • node: Element

Returns: Elementnull