Skip to content

Commit

Permalink
chore: fix scale
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Jun 13, 2024
1 parent 645b5a0 commit 995a836
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {

const onHolderResize: ResizeObserverProps['onResize'] = (sizeInfo) => {
setSize({
width: sizeInfo.width || sizeInfo.offsetWidth,
height: sizeInfo.height || sizeInfo.offsetHeight,
width: sizeInfo.offsetWidth,
height: sizeInfo.offsetHeight,
});
};

Expand Down
8 changes: 5 additions & 3 deletions src/ScrollBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import classNames from 'classnames';
import raf from 'rc-util/lib/raf';
import * as React from 'react';

export type ScrollBarDirectionType = 'ltr' | 'rtl';

Expand Down Expand Up @@ -84,7 +84,7 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
}, [scrollOffset, enableScrollRange, enableOffsetRange]);

// ====================== Container =======================
const onContainerMouseDown: React.MouseEventHandler = e => {
const onContainerMouseDown: React.MouseEventHandler = (e) => {
e.stopPropagation();
e.preventDefault();
};
Expand Down Expand Up @@ -142,8 +142,10 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
} = stateRef.current;
raf.cancel(moveRafId);

const scale = containerSize / scrollbarRef.current.getBoundingClientRect().height;

if (stateDragging) {
const offset = getPageXY(e, horizontal) - statePageY;
const offset = (getPageXY(e, horizontal) - statePageY) * scale;
let newTop = stateStartTop;

if (!isLTR && horizontal) {
Expand Down

0 comments on commit 995a836

Please sign in to comment.