MCPcopy Create free account
hub / github.com/adobe/react-spectrum / scrollAlongAxis

Function scrollAlongAxis

packages/react-aria-components/src/Sheet.tsx:1133–1136  ·  view source on GitHub ↗
(element: HTMLElement, axis: Axis, value: number, smooth = false)

Source from the content-addressed store, hash-verified

1131}
1132
1133function scrollAlongAxis(element: HTMLElement, axis: Axis, value: number, smooth = false) {
1134 let behavior: ScrollBehavior | undefined = smooth && !reduceMotion() ? 'smooth' : undefined;
1135 element.scrollTo(axis === 'y' ? {top: value, behavior} : {left: value, behavior});
1136}
1137
1138// Moves the scroller so the sheet's leading edge sits at the viewport edge, with snapping
1139// disabled so the browser doesn't pull it back to a snap point. Returns whether it moved.

Callers 2

Sheet.tsxFile · 0.85
scrollToRestFunction · 0.85

Calls 1

reduceMotionFunction · 0.85

Tested by

no test coverage detected