1
0
Fork 0
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:
Julien Voisin 2025-09-09 00:41:50 +02:00 committed by GitHub
parent a60a153003
commit 645800ce3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 14 deletions

View file

@ -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();
}
}
/**

View file

@ -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);
}
}
}