Skip to content

Commit 6b387f0

Browse files
authored
fix(list): wrong position when auto scrolling (#1687)
Co-authored-by: Sleaf <huangshu@xd.com>
1 parent 7f9b03b commit 6b387f0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/List/helper/useSortHelper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ const useSortHelper = (config: SortConfig) => {
7878

7979
// init scroller
8080
const scrollContainer = getScrollingParent(containerElement) || containerElement;
81+
const initScroll: Axis = {
82+
x: scrollContainer.scrollLeft,
83+
y: scrollContainer.scrollTop
84+
};
8185
const autoScroller = new AutoScroller(scrollContainer, (offset: Offset) => {
8286
activeNodeHolderTranslate.x += offset.left;
8387
activeNodeHolderTranslate.y += offset.top;
@@ -99,8 +103,8 @@ const useSortHelper = (config: SortConfig) => {
99103
document.body.appendChild(activeNodeHelper);
100104

101105
const getContainerScrollDelta = (): Offset => ({
102-
left: scrollContainer.scrollLeft - scrollContainer.scrollLeft,
103-
top: scrollContainer.scrollTop - scrollContainer.scrollTop
106+
left: scrollContainer.scrollLeft - initScroll.x,
107+
top: scrollContainer.scrollTop - initScroll.y
104108
});
105109
const getHolderTranslate = (): Axis =>
106110
animatedNodesOffset.reduce(

0 commit comments

Comments
 (0)