From b29cec965a8321d8802958baee0bd96cb8a82abc Mon Sep 17 00:00:00 2001 From: jackliu Date: Fri, 15 Apr 2022 21:19:37 +0800 Subject: [PATCH] fix raf bug --- components/_util/raf.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/_util/raf.ts b/components/_util/raf.ts index e264f72728..9598e11269 100644 --- a/components/_util/raf.ts +++ b/components/_util/raf.ts @@ -20,7 +20,7 @@ export default function wrapperRaf(callback: () => void, times = 1): number { function callRef(leftTimes: number) { if (leftTimes === 0) { // Clean up - cleanup(id); + wrapperRaf.cancel(id); // Trigger callback(); @@ -29,6 +29,9 @@ export default function wrapperRaf(callback: () => void, times = 1): number { const realId = raf(() => { callRef(leftTimes - 1); }); + if (rafIds.get(id)) { + wrapperRaf.cancel(id); + } // Bind real raf id rafIds.set(id, realId);