|
|
@@ -15,8 +15,8 @@ class TouchHandler {
|
|
|
|
|
|
calculateDistance() {
|
|
|
if (this.touch.start.x >= -1 && this.touch.move.x >= -1) {
|
|
|
- let horizontalDistance = Math.abs(this.touch.move.x - this.touch.start.x);
|
|
|
- let verticalDistance = Math.abs(this.touch.move.y - this.touch.start.y);
|
|
|
+ const horizontalDistance = Math.abs(this.touch.move.x - this.touch.start.x);
|
|
|
+ const verticalDistance = Math.abs(this.touch.move.y - this.touch.start.y);
|
|
|
|
|
|
if (horizontalDistance > 30 && verticalDistance < 70 || this.touch.moved) {
|
|
|
return this.touch.move.x - this.touch.start.x;
|
|
|
@@ -54,8 +54,8 @@ class TouchHandler {
|
|
|
this.touch.move.x = event.touches[0].clientX;
|
|
|
this.touch.move.y = event.touches[0].clientY;
|
|
|
|
|
|
- let distance = this.calculateDistance();
|
|
|
- let absDistance = Math.abs(distance);
|
|
|
+ const distance = this.calculateDistance();
|
|
|
+ const absDistance = Math.abs(distance);
|
|
|
|
|
|
if (absDistance > 0) {
|
|
|
this.touch.moved = true;
|
|
|
@@ -78,7 +78,7 @@ class TouchHandler {
|
|
|
}
|
|
|
|
|
|
if (this.touch.element !== null) {
|
|
|
- let absDistance = Math.abs(this.calculateDistance());
|
|
|
+ const absDistance = Math.abs(this.calculateDistance());
|
|
|
|
|
|
if (absDistance > 75) {
|
|
|
toggleEntryStatus(this.touch.element);
|
|
|
@@ -118,9 +118,9 @@ class TouchHandler {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- let distance = this.calculateDistance();
|
|
|
- let absDistance = Math.abs(distance);
|
|
|
- let now = Date.now();
|
|
|
+ const distance = this.calculateDistance();
|
|
|
+ const absDistance = Math.abs(distance);
|
|
|
+ const now = Date.now();
|
|
|
|
|
|
if (now - this.touch.time <= 1000 && absDistance > 75) {
|
|
|
if (distance > 0) {
|
|
|
@@ -138,10 +138,10 @@ class TouchHandler {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- let now = Date.now();
|
|
|
+ const now = Date.now();
|
|
|
|
|
|
if (this.touch.start.x !== -1 && now - this.touch.time <= 200) {
|
|
|
- let innerWidthHalf = window.innerWidth / 2;
|
|
|
+ const innerWidthHalf = window.innerWidth / 2;
|
|
|
|
|
|
if (this.touch.start.x >= innerWidthHalf && event.changedTouches[0].clientX >= innerWidthHalf) {
|
|
|
goToPage("next");
|
|
|
@@ -158,19 +158,16 @@ class TouchHandler {
|
|
|
}
|
|
|
|
|
|
listen() {
|
|
|
- let hasPassiveOption = DomHelper.hasPassiveEventListenerOption();
|
|
|
+ const hasPassiveOption = DomHelper.hasPassiveEventListenerOption();
|
|
|
|
|
|
- let elements = document.querySelectorAll(".entry-swipe");
|
|
|
-
|
|
|
- elements.forEach((element) => {
|
|
|
+ document.querySelectorAll(".entry-swipe").forEach((element) => {
|
|
|
element.addEventListener("touchstart", (e) => this.onItemTouchStart(e), hasPassiveOption ? { passive: true } : false);
|
|
|
element.addEventListener("touchmove", (e) => this.onItemTouchMove(e), hasPassiveOption ? { passive: false } : false);
|
|
|
element.addEventListener("touchend", (e) => this.onItemTouchEnd(e), hasPassiveOption ? { passive: true } : false);
|
|
|
element.addEventListener("touchcancel", () => this.reset(), hasPassiveOption ? { passive: true } : false);
|
|
|
});
|
|
|
|
|
|
- let element = document.querySelector(".entry-content");
|
|
|
-
|
|
|
+ const element = document.querySelector(".entry-content");
|
|
|
if (element) {
|
|
|
if (element.classList.contains("gesture-nav-tap")) {
|
|
|
element.addEventListener("touchend", (e) => this.onTapEnd(e), hasPassiveOption ? { passive: true } : false);
|