MCPcopy Index your code
hub / github.com/adobe/react-spectrum / getScrollLeft

Function getScrollLeft

packages/react-aria/src/virtualizer/utils.ts:66–84  ·  view source on GitHub ↗
(node: Element, direction: Direction)

Source from the content-addressed store, hash-verified

64}
65
66export function getScrollLeft(node: Element, direction: Direction): number {
67 let {scrollLeft} = node;
68
69 // scrollLeft in rtl locales differs across browsers, so normalize.
70 // See comment by getRTLOffsetType below for details.
71 if (direction === 'rtl') {
72 let {scrollWidth, clientWidth} = node;
73 switch (getRTLOffsetType()) {
74 case 'negative':
75 scrollLeft = -scrollLeft;
76 break;
77 case 'positive-descending':
78 scrollLeft = scrollWidth - clientWidth - scrollLeft;
79 break;
80 }
81 }
82
83 return scrollLeft;
84}
85
86export function setScrollLeft(node: Element, direction: Direction, scrollLeft: number): void {
87 if (direction === 'rtl') {

Callers 1

useScrollViewFunction · 0.90

Calls 1

getRTLOffsetTypeFunction · 0.85

Tested by

no test coverage detected