mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
refactor(js): remove isTouchSupported()
static function
This commit is contained in:
parent
a60a153003
commit
645800ce3c
2 changed files with 8 additions and 14 deletions
|
@ -1230,8 +1230,10 @@ function initializeKeyboardShortcuts() {
|
|||
* Initialize touch handler for mobile devices.
|
||||
*/
|
||||
function initializeTouchHandler() {
|
||||
if ( "ontouchstart" in window || navigator.maxTouchPoints > 0) {
|
||||
const touchHandler = new TouchHandler();
|
||||
touchHandler.listen();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -151,35 +151,27 @@ class TouchHandler {
|
|||
}
|
||||
}
|
||||
|
||||
static isTouchSupported() {
|
||||
return "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
||||
}
|
||||
|
||||
listen() {
|
||||
if (!TouchHandler.isTouchSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const eventListenerOptions = { passive: true };
|
||||
|
||||
document.querySelectorAll(".entry-swipe").forEach((element) => {
|
||||
element.addEventListener("touchstart", (e) => this.onItemTouchStart(e), eventListenerOptions);
|
||||
element.addEventListener("touchmove", (e) => this.onItemTouchMove(e));
|
||||
element.addEventListener("touchend", (e) => this.onItemTouchEnd(e), eventListenerOptions);
|
||||
element.addEventListener("touchcancel", () => this.reset(), eventListenerOptions);
|
||||
element.addEventListener("touchcancel", this.reset, eventListenerOptions);
|
||||
});
|
||||
|
||||
const element = document.querySelector(".entry-content");
|
||||
if (element) {
|
||||
if (element.classList.contains("gesture-nav-tap")) {
|
||||
element.addEventListener("touchend", (e) => this.onTapEnd(e), eventListenerOptions);
|
||||
element.addEventListener("touchmove", () => this.reset(), eventListenerOptions);
|
||||
element.addEventListener("touchcancel", () => this.reset(), eventListenerOptions);
|
||||
element.addEventListener("touchmove", this.reset, eventListenerOptions);
|
||||
element.addEventListener("touchcancel", this.reset, eventListenerOptions);
|
||||
} else if (element.classList.contains("gesture-nav-swipe")) {
|
||||
element.addEventListener("touchstart", (e) => this.onContentTouchStart(e), eventListenerOptions);
|
||||
element.addEventListener("touchmove", (e) => this.onContentTouchMove(e), eventListenerOptions);
|
||||
element.addEventListener("touchend", (e) => this.onContentTouchEnd(e), eventListenerOptions);
|
||||
element.addEventListener("touchcancel", () => this.reset(), eventListenerOptions);
|
||||
element.addEventListener("touchcancel", this.reset, eventListenerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue