From 839276784fbf6fdfdcdeb600ca689ddfecd9bf3d Mon Sep 17 00:00:00 2001 From: cadrell0 Date: Thu, 31 Jul 2014 14:37:42 -0400 Subject: [PATCH] Prevent modal from triggering while scrolling --- js/modals.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/modals.js b/js/modals.js index 3e349b0..de012ac 100644 --- a/js/modals.js +++ b/js/modals.js @@ -28,8 +28,22 @@ return document.querySelector(modalToggle.hash); } }; + + var dragging = false; + + window.addEventListener('touchmove', function () { + dragging = true; + }); + + window.addEventListener('touchstart', function () { + dragging = false; + }); window.addEventListener('touchend', function (event) { + if (dragging) { + return; + } + var modal = getModal(event); if (modal) { if (modal && modal.classList.contains('modal')) {