From 4d2c9a4f7861ac2b61366bbde2284a24cb915d5c Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 27 Jul 2021 19:53:17 +0200 Subject: fix button click on drag done --- components/controls.tsx | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'components') diff --git a/components/controls.tsx b/components/controls.tsx index 8e55d22..b831bfc 100644 --- a/components/controls.tsx +++ b/components/controls.tsx @@ -43,6 +43,8 @@ var options = { doneTolerance: 0.5, // if movement per frame goes below this value the animation is considered done releaseSlopeAverageCount: 3, }; +var lastDrag = 0; +var preventDragClick = (fn: () => void) => Date.now() > lastDrag + 10 && fn(); export function MenuBarControls({ next, previous, menu }: controlsPropsType) { var menuBarRef = useRef(null); @@ -57,7 +59,10 @@ export function MenuBarControls({ next, previous, menu }: controlsPropsType) { mouseX = x; mouseY = y; mouseDown = true; - if (last) mouseDown = false; + if (last) { + mouseDown = false; + lastDrag = Date.now(); + } }, { domTarget: menuBarRef, eventOptions: { passive: false }, threshold: 10 }); menuBarPosApi = api; @@ -201,11 +206,21 @@ export function MenuBarControls({ next, previous, menu }: controlsPropsType) { '--vertical': menuBarSpring.vertical, } as CSSProperties} > -