From 46939972f252aec2b17a70c4d77339cde28ef61d Mon Sep 17 00:00:00 2001 From: ShuGang Zhou Date: Thu, 22 Jun 2023 11:05:01 +0800 Subject: [PATCH] fix(FloatingPanel): Reuse closest function (#12007) --- packages/vant/src/floating-panel/FloatingPanel.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/vant/src/floating-panel/FloatingPanel.tsx b/packages/vant/src/floating-panel/FloatingPanel.tsx index 54a9c9fa8..b4d9b2002 100644 --- a/packages/vant/src/floating-panel/FloatingPanel.tsx +++ b/packages/vant/src/floating-panel/FloatingPanel.tsx @@ -9,6 +9,7 @@ import { // Utils import { addUnit, + closest, createNamespace, makeArrayProp, makeNumericProp, @@ -88,11 +89,6 @@ export default defineComponent({ return moveY; }; - const closest = (arr: number[], target: number) => - arr.reduce((pre, cur) => - Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur - ); - let startY: number; const touch = useTouch();