Calculate menu width on touch start

Fixes #831
This commit is contained in:
Pavel Djundik 2016-12-21 19:58:36 +02:00 committed by GitHub
parent 1d4fe979b1
commit 3017e67f3a

View File

@ -5,7 +5,7 @@ function slideoutMenu(viewport, menu) {
var touchStartPos = null; var touchStartPos = null;
var touchCurPos = null; var touchCurPos = null;
var touchStartTime = 0; var touchStartTime = 0;
var menuWidth = parseFloat(window.getComputedStyle(menu).width); var menuWidth = 0;
var menuIsOpen = false; var menuIsOpen = false;
var menuIsMoving = false; var menuIsMoving = false;
@ -27,6 +27,8 @@ function slideoutMenu(viewport, menu) {
var touch = e.touches.item(0); var touch = e.touches.item(0);
viewport.classList.toggle("menu-dragging", true); viewport.classList.toggle("menu-dragging", true);
menuWidth = parseFloat(window.getComputedStyle(menu).width);
if ((!menuIsOpen && touch.screenX < 50) || (menuIsOpen && touch.screenX > menuWidth)) { if ((!menuIsOpen && touch.screenX < 50) || (menuIsOpen && touch.screenX > menuWidth)) {
touchStartPos = touch; touchStartPos = touch;
touchCurPos = touch; touchCurPos = touch;