aboutsummaryrefslogtreecommitdiffhomepage
path: root/ui/static/js/touch_handler.js
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2019-07-17 20:27:39 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2019-07-17 20:34:11 -0700
commit2b6e17c1ef7f54f822e37991eaf7a309013182e2 (patch)
tree0c59d78c5a60fe6cae0c6c07935fe51074e216a5 /ui/static/js/touch_handler.js
parent34421dcd496198db82ca7c7fd54362d9b600fbb3 (diff)
Refactoring of Javascript code
Diffstat (limited to 'ui/static/js/touch_handler.js')
-rw-r--r--ui/static/js/touch_handler.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/ui/static/js/touch_handler.js b/ui/static/js/touch_handler.js
index 9e4b7bc..4f6d7ae 100644
--- a/ui/static/js/touch_handler.js
+++ b/ui/static/js/touch_handler.js
@@ -1,13 +1,12 @@
class TouchHandler {
- constructor(navHandler) {
- this.navHandler = navHandler;
+ constructor() {
this.reset();
}
reset() {
this.touch = {
- start: {x: -1, y: -1},
- move: {x: -1, y: -1},
+ start: { x: -1, y: -1 },
+ move: { x: -1, y: -1 },
element: null
};
}
@@ -75,8 +74,9 @@ class TouchHandler {
let distance = Math.abs(this.calculateDistance());
if (distance > 75) {
- EntryHandler.toggleEntryStatus(this.touch.element);
+ toggleEntryStatus(this.touch.element);
}
+
this.touch.element.style.opacity = 1;
this.touch.element.style.transform = "none";
}
@@ -101,7 +101,7 @@ class TouchHandler {
previous: null,
next: null
};
-
+
const detectDoubleTap = (doubleTapTimer, event) => {
const timer = doubleTapTimers[doubleTapTimer];
if (timer === null) {
@@ -110,17 +110,18 @@ class TouchHandler {
}, 200);
} else {
event.preventDefault();
- this.navHandler.goToPage(doubleTapTimer);
+ goToPage(doubleTapTimer);
}
};
-
+
entryContentElement.addEventListener("touchend", (e) => {
- if (e.changedTouches[0].clientX >= (entryContentElement.offsetWidth / 2)) {
- detectDoubleTap("next", e);
- } else {
- detectDoubleTap("previous", e);
- }
- }, hasPassiveOption ? { passive: false } : false);
+ if (e.changedTouches[0].clientX >= (entryContentElement.offsetWidth / 2)) {
+ detectDoubleTap("next", e);
+ } else {
+ detectDoubleTap("previous", e);
+ }
+ }, hasPassiveOption ? { passive: false } : false);
+
entryContentElement.addEventListener("touchmove", (e) => {
Object.keys(doubleTapTimers).forEach(timer => doubleTapTimers[timer] = null);
});