Fix menu swiping

This commit is contained in:
Pavel Djundik 2018-07-13 10:41:12 +03:00 committed by Pavel Djundik
parent d9206c1087
commit 797731262a

View File

@ -35,7 +35,7 @@ function onTouchStart(e) {
return;
}
const styles = window.getComputedStyle(this.menu);
const styles = window.getComputedStyle(SlideoutMenu.menu);
menuWidth = parseFloat(styles.width);
menuIsAbsolute = styles.position === "absolute";
@ -65,7 +65,7 @@ function onTouchMove(e) {
const devicePixelRatio = window.devicePixelRatio || 2;
if (Math.abs(distX) > devicePixelRatio) {
this.viewport.classList.toggle("menu-dragging", true);
SlideoutMenu.viewport.classList.toggle("menu-dragging", true);
menuIsMoving = true;
}
}
@ -85,8 +85,8 @@ function onTouchMove(e) {
distX = 0;
}
this.menu.style.transform = "translate3d(" + distX + "px, 0, 0)";
this.sidebarOverlay.style.opacity = distX / menuWidth;
SlideoutMenu.menu.style.transform = "translate3d(" + distX + "px, 0, 0)";
SlideoutMenu.sidebarOverlay.style.opacity = distX / menuWidth;
}
function onTouchEnd() {
@ -99,9 +99,9 @@ function onTouchEnd() {
document.body.removeEventListener("touchmove", onTouchMove);
document.body.removeEventListener("touchend", onTouchEnd);
this.viewport.classList.toggle("menu-dragging", false);
this.menu.style.transform = null;
this.sidebarOverlay.style.opacity = null;
SlideoutMenu.viewport.classList.toggle("menu-dragging", false);
SlideoutMenu.menu.style.transform = null;
SlideoutMenu.sidebarOverlay.style.opacity = null;
touchStartPos = null;
touchCurPos = null;