Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.

Commit 395022b

Browse files
committed
fix: Should cancel timeout if not reach align condition
1 parent 4e9f33e commit 395022b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Align.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const Align: React.RefForwardingComponent<RefAlign, AlignProps> = (
5353
// ===================== Align ======================
5454
const forceAlignRef = React.useRef<Function>();
5555

56+
const [forceAlign, cancelForceAlign] = useBuffer(() => {
57+
forceAlignRef.current();
58+
}, monitorBufferTime);
59+
5660
forceAlignRef.current = () => {
5761
if (!disabled && target) {
5862
const source = findDOMNode<HTMLElement>(nodeRef.current);
@@ -79,13 +83,11 @@ const Align: React.RefForwardingComponent<RefAlign, AlignProps> = (
7983
if (onAlign) {
8084
onAlign(source, result);
8185
}
86+
} else {
87+
cancelForceAlign();
8288
}
8389
};
8490

85-
const [forceAlign, cancelForceAlign] = useBuffer(() => {
86-
forceAlignRef.current();
87-
}, monitorBufferTime);
88-
8991
// ===================== Effect =====================
9092
// Listen for target updated
9193
const resizeMonitor = React.useRef<MonitorRef>({

0 commit comments

Comments
 (0)