From bb6a9657a04641d91d835be71b2f02708306dc2d Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Mon, 15 Oct 2018 14:54:33 +0300 Subject: [PATCH] Fix touch position being null when touching with multiple fingers --- client/js/slideout.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/js/slideout.js b/client/js/slideout.js index 63dfba64..46fd498f 100644 --- a/client/js/slideout.js +++ b/client/js/slideout.js @@ -28,20 +28,19 @@ class SlideoutMenu { } function onTouchStart(e) { + touchStartPos = touchCurPos = e.touches.item(0); + if (e.touches.length !== 1) { onTouchEnd(); return; } - const touch = e.touches.item(0); const styles = window.getComputedStyle(menu); menuWidth = parseFloat(styles.width); menuIsAbsolute = styles.position === "absolute"; - if (!menuIsOpen || touch.screenX > menuWidth) { - touchStartPos = touch; - touchCurPos = touch; + if (!menuIsOpen || touchStartPos.screenX > menuWidth) { touchStartTime = Date.now(); document.body.addEventListener("touchmove", onTouchMove, {passive: true});