Skip to content

Commit

Permalink
chore(tree): adjustment onScroll
Browse files Browse the repository at this point in the history
  • Loading branch information
HaixingOoO committed Dec 23, 2024
1 parent b5044b9 commit af9d9b5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tree/hooks/useTreeVirtualScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import useVirtualScroll from '../../hooks/useVirtualScroll';
import TreeNode from '../../_common/js/tree-v1/tree-node';
import { TScroll } from '../../common';
import type { TdTreeProps } from '../type';
import useLatest from '../../hooks/useLatest';

export default function useTreeVirtualScroll({
treeRef,
Expand Down Expand Up @@ -34,6 +35,7 @@ export default function useTreeVirtualScroll({
} as const),
[scroll, scrollThreshold],
);
const onScrollLatest = useLatest(onScroll);

const {
visibleData = null,
Expand All @@ -49,7 +51,7 @@ export default function useTreeVirtualScroll({

let lastScrollY = -1;
const onInnerVirtualScroll = (e: WheelEvent) => {
onScroll?.({ e });
onScrollLatest.current?.({ e });
if (!isVirtual) {
return;
}
Expand Down

0 comments on commit af9d9b5

Please sign in to comment.