Skip to content

Commit

Permalink
fix: 解决 _rect 排序错误
Browse files Browse the repository at this point in the history
  • Loading branch information
limaofeng committed Nov 13, 2021
1 parent 811d6a7 commit d41ab4e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
node_modules
.cache
dist
storybook-static
storybook-static

# test tree
src/tree
stories/Tree.stories.tsx
2 changes: 1 addition & 1 deletion src/SortableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function SortableContainer(props: SortableContainerProps, externalRef: any) {
try {
coord = getItemCoord(ref, data);
} catch (e) {
console.log(e, id, activities, temp.current.activities);
// console.log(e, id, activities, temp.current.activities);
continue;
}

Expand Down
21 changes: 9 additions & 12 deletions src/SortableProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const delayDispatch = (callback: any, delay: number) => {
const sleeps = Array.from(sleepBuffer);
sleepBuffer.clear();
exec = undefined;
console.log('>>>>>', wakeups, sleeps);
callback(wakeups, sleeps);
}, delay);
};
Expand Down Expand Up @@ -356,17 +355,15 @@ function useStore(items: ISortableItem[], pos: number[]): ISortableContext {
return item;
}
const { _originalSortable, _sortable, _rect, ...prevData } = data;
return isEqual(prevData, item)
? data
: assign(
{
...data,
get _rect() {
return data?._rect;
},
},
item
);
if (isEqual(prevData, item)) {
return data;
}
return assign(
{
...data,
},
item
);
}),
pos: state.pos,
activeIds: state.activeIds,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSortItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function useSortItem<T extends ISortableItem, RT extends HTMLElement>(
},
},
});
}, []);
}, [options?.index]);

const handleCanDrag = useCallback(
(monitor: DragSourceMonitor<ISortableItemInternalData>) => {
Expand Down

0 comments on commit d41ab4e

Please sign in to comment.