From 65f6b6e8cad027726af980dc4c509be35011b720 Mon Sep 17 00:00:00 2001 From: Marek Grzybek Date: Tue, 31 Mar 2020 13:19:58 +0200 Subject: [PATCH] (fix) Fix preventDefault inside passive events --- src/baguetteBox.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/baguetteBox.js b/src/baguetteBox.js index 9375753d..0bb87af6 100644 --- a/src/baguetteBox.js +++ b/src/baguetteBox.js @@ -317,27 +317,31 @@ } function bindEvents() { - var options = supports.passiveEvents ? { passive: true } : null; + var passiveEvent = supports.passiveEvents ? { passive: false } : null; + var nonPassiveEvent = supports.passiveEvents ? { passive: false } : null; + bind(overlay, 'click', overlayClickHandler); bind(previousButton, 'click', previousButtonClickHandler); bind(nextButton, 'click', nextButtonClickHandler); bind(closeButton, 'click', closeButtonClickHandler); bind(slider, 'contextmenu', contextmenuHandler); - bind(overlay, 'touchstart', touchstartHandler, options); - bind(overlay, 'touchmove', touchmoveHandler, options); + bind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent); + bind(overlay, 'touchmove', touchmoveHandler, passiveEvent); bind(overlay, 'touchend', touchendHandler); bind(document, 'focus', trapFocusInsideOverlay, true); } function unbindEvents() { - var options = supports.passiveEvents ? { passive: true } : null; + var passiveEvent = supports.passiveEvents ? { passive: false } : null; + var nonPassiveEvent = supports.passiveEvents ? { passive: false } : null; + unbind(overlay, 'click', overlayClickHandler); unbind(previousButton, 'click', previousButtonClickHandler); unbind(nextButton, 'click', nextButtonClickHandler); unbind(closeButton, 'click', closeButtonClickHandler); unbind(slider, 'contextmenu', contextmenuHandler); - unbind(overlay, 'touchstart', touchstartHandler, options); - unbind(overlay, 'touchmove', touchmoveHandler, options); + unbind(overlay, 'touchstart', touchstartHandler, nonPassiveEvent); + unbind(overlay, 'touchmove', touchmoveHandler, passiveEvent); unbind(overlay, 'touchend', touchendHandler); unbind(document, 'focus', trapFocusInsideOverlay, true); }