diff --git a/src/ScrollBar.tsx b/src/ScrollBar.tsx index dcfe1e1..d8f90a7 100644 --- a/src/ScrollBar.tsx +++ b/src/ScrollBar.tsx @@ -142,7 +142,8 @@ const ScrollBar = React.forwardRef((props, ref) => } = stateRef.current; raf.cancel(moveRafId); - const scale = containerSize / scrollbarRef.current.getBoundingClientRect().height; + const rect = scrollbarRef.current.getBoundingClientRect(); + const scale = containerSize / (horizontal ? rect.width : rect.height); if (stateDragging) { const offset = (getPageXY(e, horizontal) - statePageY) * scale; @@ -193,7 +194,7 @@ const ScrollBar = React.forwardRef((props, ref) => React.useEffect(() => { delayHidden(); - return () => { + return () => { clearTimeout(visibleTimeoutRef.current); }; }, [scrollOffset]); diff --git a/tests/scrollWidth.test.tsx b/tests/scrollWidth.test.tsx index b1f8fd1..79a141c 100644 --- a/tests/scrollWidth.test.tsx +++ b/tests/scrollWidth.test.tsx @@ -37,7 +37,7 @@ describe('List.scrollWidth', () => { }, clientHeight: { get() { - return holderWidth; + return holderHeight; }, }, getBoundingClientRect() {