mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Use passive event listeners for touch events
Avoid this warning in Chrome console: https://www.chromestatus.com/feature/5745543795965952
This commit is contained in:
parent
6d25e02cb5
commit
3bdb9251da
3 changed files with 29 additions and 7 deletions
|
@ -83,12 +83,13 @@ class TouchHandler {
|
|||
|
||||
listen() {
|
||||
let elements = document.querySelectorAll(".touch-item");
|
||||
let hasPassiveOption = DomHelper.hasPassiveEventListenerOption();
|
||||
|
||||
elements.forEach((element) => {
|
||||
element.addEventListener("touchstart", (e) => this.onTouchStart(e), false);
|
||||
element.addEventListener("touchmove", (e) => this.onTouchMove(e), false);
|
||||
element.addEventListener("touchend", (e) => this.onTouchEnd(e), false);
|
||||
element.addEventListener("touchcancel", () => this.reset(), false);
|
||||
element.addEventListener("touchstart", (e) => this.onTouchStart(e), hasPassiveOption ? { passive: true } : false);
|
||||
element.addEventListener("touchmove", (e) => this.onTouchMove(e), hasPassiveOption ? { passive: true } : false);
|
||||
element.addEventListener("touchend", (e) => this.onTouchEnd(e), hasPassiveOption ? { passive: true } : false);
|
||||
element.addEventListener("touchcancel", () => this.reset(), hasPassiveOption ? { passive: true } : false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue