diff --git a/src/List.tsx b/src/List.tsx index ad1f4b3..6a5c751 100644 --- a/src/List.tsx +++ b/src/List.tsx @@ -275,8 +275,8 @@ export function RawList(props: ListProps, ref: React.Ref) { const onHolderResize: ResizeObserverProps['onResize'] = (sizeInfo) => { setSize({ - width: sizeInfo.width || sizeInfo.offsetWidth, - height: sizeInfo.height || sizeInfo.offsetHeight, + width: sizeInfo.offsetWidth, + height: sizeInfo.offsetHeight, }); }; diff --git a/src/ScrollBar.tsx b/src/ScrollBar.tsx index a0ab734..01b9d69 100644 --- a/src/ScrollBar.tsx +++ b/src/ScrollBar.tsx @@ -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'; @@ -84,7 +84,7 @@ const ScrollBar = React.forwardRef((props, ref) => }, [scrollOffset, enableScrollRange, enableOffsetRange]); // ====================== Container ======================= - const onContainerMouseDown: React.MouseEventHandler = e => { + const onContainerMouseDown: React.MouseEventHandler = (e) => { e.stopPropagation(); e.preventDefault(); }; @@ -142,8 +142,10 @@ const ScrollBar = React.forwardRef((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) {