Skip to content

Commit

Permalink
fix(list): wrong position when auto scrolling (#1687)
Browse files Browse the repository at this point in the history
Co-authored-by: Sleaf <huangshu@xd.com>
  • Loading branch information
Sleaf and Sleaf authored May 25, 2021
1 parent 7f9b03b commit 6b387f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/List/helper/useSortHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ const useSortHelper = (config: SortConfig) => {

// init scroller
const scrollContainer = getScrollingParent(containerElement) || containerElement;
const initScroll: Axis = {
x: scrollContainer.scrollLeft,
y: scrollContainer.scrollTop
};
const autoScroller = new AutoScroller(scrollContainer, (offset: Offset) => {
activeNodeHolderTranslate.x += offset.left;
activeNodeHolderTranslate.y += offset.top;
Expand All @@ -99,8 +103,8 @@ const useSortHelper = (config: SortConfig) => {
document.body.appendChild(activeNodeHelper);

const getContainerScrollDelta = (): Offset => ({
left: scrollContainer.scrollLeft - scrollContainer.scrollLeft,
top: scrollContainer.scrollTop - scrollContainer.scrollTop
left: scrollContainer.scrollLeft - initScroll.x,
top: scrollContainer.scrollTop - initScroll.y
});
const getHolderTranslate = (): Axis =>
animatedNodesOffset.reduce(
Expand Down

0 comments on commit 6b387f0

Please sign in to comment.