Skip to content

Commit

Permalink
fix: scale scroll (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored Jun 25, 2024
1 parent f10c8e8 commit ed2cac5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ScrollBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((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;
Expand Down Expand Up @@ -193,7 +194,7 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>

React.useEffect(() => {
delayHidden();
return () => {
return () => {
clearTimeout(visibleTimeoutRef.current);
};
}, [scrollOffset]);
Expand Down
2 changes: 1 addition & 1 deletion tests/scrollWidth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('List.scrollWidth', () => {
},
clientHeight: {
get() {
return holderWidth;
return holderHeight;
},
},
getBoundingClientRect() {
Expand Down

0 comments on commit ed2cac5

Please sign in to comment.