From 26a928a2a8b1c5cdc2c25db4d750f0222ca34618 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 9 Oct 2016 12:44:15 +0200 Subject: [PATCH] Detect vertical movement earlier in Android Menu --- .../WoltLabSuite/Core/Ui/Page/Menu/Abstract.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Abstract.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Abstract.js index 9f28e0d23c..c798075e3d 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Abstract.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Menu/Abstract.js @@ -167,6 +167,9 @@ define(['Core', 'Environment', 'EventHandler', 'ObjectMap', 'Dom/Traverse', 'Dom */ _initializeAndroid: function() { var appearsAt, backdrop, touchStart; + /** @const */ var AT_EDGE = 20; + /** @const */ var MOVED_HORIZONTALLY = 5; + /** @const */ var MOVED_VERTICALLY = 10; // specify on which side of the page the menu appears switch (this._menu.id) { @@ -193,12 +196,12 @@ define(['Core', 'Environment', 'EventHandler', 'ObjectMap', 'Dom/Traverse', 'Dom // check whether we touch the edges of the menu if (appearsAt === 'left') { - isLeftEdge = !isOpen && (touches[0].clientX < 20); - isRightEdge = isOpen && (Math.abs(this._menu.offsetWidth - touches[0].clientX) < 20); + isLeftEdge = !isOpen && (touches[0].clientX < AT_EDGE); + isRightEdge = isOpen && (Math.abs(this._menu.offsetWidth - touches[0].clientX) < AT_EDGE); } else if (appearsAt === 'right') { - isLeftEdge = isOpen && (Math.abs(document.body.clientWidth - this._menu.offsetWidth - touches[0].clientX) < 20); - isRightEdge = !isOpen && ((document.body.clientWidth - touches[0].clientX) < 20); + isLeftEdge = isOpen && (Math.abs(document.body.clientWidth - this._menu.offsetWidth - touches[0].clientX) < AT_EDGE); + isRightEdge = !isOpen && ((document.body.clientWidth - touches[0].clientX) < AT_EDGE); } // abort if more than one touch @@ -288,9 +291,9 @@ define(['Core', 'Environment', 'EventHandler', 'ObjectMap', 'Dom/Traverse', 'Dom // check whether the user started moving in the correct direction // this avoids false positives, in case the user just wanted to tap var movedFromEdge = false, movedVertically = false; - if (_androidTouching === 'left') movedFromEdge = touches[0].clientX > (touchStart.x + 5); - if (_androidTouching === 'right') movedFromEdge = touches[0].clientX < (touchStart.x - 5); - movedVertically = Math.abs(touches[0].clientY - touchStart.y) > 30; + if (_androidTouching === 'left') movedFromEdge = touches[0].clientX > (touchStart.x + MOVED_HORIZONTALLY); + if (_androidTouching === 'right') movedFromEdge = touches[0].clientX < (touchStart.x - MOVED_HORIZONTALLY); + movedVertically = Math.abs(touches[0].clientY - touchStart.y) > MOVED_VERTICALLY; var isOpen = this._menu.classList.contains('open'); -- 2.20.1