From 5d06241911d187d00f65ec55638bc82260e87859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Tue, 28 Nov 2023 19:56:16 +0100 Subject: [PATCH] menu: make swipe handler passive #735 --- static/js/theme.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/static/js/theme.js b/static/js/theme.js index 394cf40adb..24b525703a 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -1087,7 +1087,6 @@ function initSwipeHandler(){ var handleStartX = function(evt) { startx = evt.touches[0].clientX; starty = evt.touches[0].clientY; - return false; }; var handleMoveX = function(evt) { if( startx !== null ){ @@ -1104,24 +1103,22 @@ function initSwipeHandler(){ closeNav(); } } - return false; }; var handleEndX = function(evt) { startx = null; starty = null; - return false; }; var s = document.querySelector( '#R-body-overlay' ); - s && s.addEventListener("touchstart", handleStartX, false); - document.querySelector( '#R-sidebar' ).addEventListener("touchstart", handleStartX, false); - document.querySelectorAll( '#R-sidebar *' ).forEach( function(e){ e.addEventListener("touchstart", handleStartX); }, false); - s && s.addEventListener("touchmove", handleMoveX, false); - document.querySelector( '#R-sidebar' ).addEventListener("touchmove", handleMoveX, false); - document.querySelectorAll( '#R-sidebar *' ).forEach( function(e){ e.addEventListener("touchmove", handleMoveX); }, false); - s && s.addEventListener("touchend", handleEndX, false); - document.querySelector( '#R-sidebar' ).addEventListener("touchend", handleEndX, false); - document.querySelectorAll( '#R-sidebar *' ).forEach( function(e){ e.addEventListener("touchend", handleEndX); }, false); + s && s.addEventListener("touchstart", handleStartX, { capture: false, passive: true}); + document.querySelector( '#R-sidebar' ).addEventListener("touchstart", handleStartX, { capture: false, passive: true}); + document.querySelectorAll( '#R-sidebar *' ).forEach( function(e){ e.addEventListener("touchstart", handleStartX, { capture: false, passive: true}) }); + s && s.addEventListener("touchmove", handleMoveX, { capture: false, passive: true}); + document.querySelector( '#R-sidebar' ).addEventListener("touchmove", handleMoveX, { capture: false, passive: true}); + document.querySelectorAll( '#R-sidebar *' ).forEach( function(e){ e.addEventListener("touchmove", handleMoveX, { capture: false, passive: true}) }); + s && s.addEventListener("touchend", handleEndX, { capture: false, passive: true}); + document.querySelector( '#R-sidebar' ).addEventListener("touchend", handleEndX, { capture: false, passive: true}); + document.querySelectorAll( '#R-sidebar *' ).forEach( function(e){ e.addEventListener("touchend", handleEndX, { capture: false, passive: true}) }); } function initImage(){