diff --git a/dist/ratchet.js b/dist/ratchet.js index 515392d..7c11128 100644 --- a/dist/ratchet.js +++ b/dist/ratchet.js @@ -6,6 +6,12 @@ * ================================== */ +var clickEvent = 'click'; +if(typeof window.ontouchmove !== 'undefined') { + var clickEvent = clickEvent; + $('body').removeClass('no-touch'); +} + /* ---------------------------------- * POPOVER v1.0.0 * Licensed under The MIT License @@ -54,7 +60,8 @@ return popover; } - window.addEventListener('touchend', function (e) { + window.addEventListener(clickEvent, function (e) { + e.preventDefault(); var popover = getPopover(e); if (!popover) return; @@ -65,9 +72,7 @@ popover.parentNode.appendChild(backdrop); }); - - window.addEventListener('click', function (e) { if (getPopover(e)) e.preventDefault(); }); - + }(); /* ---------------------------------- * PUSH v1.0.0 @@ -481,8 +486,7 @@ window.addEventListener('touchstart', function () { isScrolling = false; }); window.addEventListener('touchmove', function () { isScrolling = true; }) - window.addEventListener('touchend', touchend); - window.addEventListener('click', function (e) { if (getTarget(e)) e.preventDefault(); }); + window.addEventListener(clickEvent, touchend); window.addEventListener('popstate', popstate); }();/* ---------------------------------- @@ -499,7 +503,8 @@ } }; - window.addEventListener("touchend", function (e) { + window.addEventListener(clickEvent, function (e) { + e.preventDefault(); var activeTab; var activeBody; var targetBody; @@ -529,8 +534,6 @@ targetBody.classList.add(className) }); - - window.addEventListener('click', function (e) { if (getTarget(e.target)) e.preventDefault(); }); }();/* ---------------------------------- * SLIDER v1.0.0 * Licensed under The MIT License @@ -642,7 +645,7 @@ window.addEventListener('touchstart', onTouchStart); window.addEventListener('touchmove', onTouchMove); - window.addEventListener('touchend', onTouchEnd); + window.addEventListener(clickEvent, onTouchEnd); }(); /* ---------------------------------- @@ -712,7 +715,7 @@ toggle.classList[(distanceX > (toggleWidth/2 - handleWidth/2)) ? 'add' : 'remove']('active'); }); - window.addEventListener('touchend', function (e) { + window.addEventListener(clickEvent, function (e) { if (!toggle) return; var handle = toggle.querySelector('.toggle-handle'); diff --git a/lib/js/popovers.js b/lib/js/popovers.js index 6cdf1c6..ed4cb5b 100644 --- a/lib/js/popovers.js +++ b/lib/js/popovers.js @@ -1,3 +1,9 @@ +var clickEvent = 'click'; +if(typeof window.ontouchmove !== 'undefined') { + var clickEvent = clickEvent; + $('body').removeClass('no-touch'); +} + /* ---------------------------------- * POPOVER v1.0.0 * Licensed under The MIT License @@ -46,7 +52,8 @@ return popover; } - window.addEventListener('touchend', function (e) { + window.addEventListener(clickEvent, function (e) { + e.preventDefault(); var popover = getPopover(e); if (!popover) return; @@ -57,7 +64,5 @@ popover.parentNode.appendChild(backdrop); }); - - window.addEventListener('click', function (e) { if (getPopover(e)) e.preventDefault(); }); - + }(); diff --git a/lib/js/push.js b/lib/js/push.js index 3a48c54..c183cac 100644 --- a/lib/js/push.js +++ b/lib/js/push.js @@ -410,8 +410,7 @@ window.addEventListener('touchstart', function () { isScrolling = false; }); window.addEventListener('touchmove', function () { isScrolling = true; }) - window.addEventListener('touchend', touchend); - window.addEventListener('click', function (e) { if (getTarget(e)) e.preventDefault(); }); + window.addEventListener(clickEvent, touchend); window.addEventListener('popstate', popstate); }(); \ No newline at end of file diff --git a/lib/js/segmented-controllers.js b/lib/js/segmented-controllers.js index 6c1111d..a9dab6c 100644 --- a/lib/js/segmented-controllers.js +++ b/lib/js/segmented-controllers.js @@ -12,7 +12,8 @@ } }; - window.addEventListener("touchend", function (e) { + window.addEventListener(clickEvent, function (e) { + e.preventDefault(); var activeTab; var activeBody; var targetBody; @@ -42,6 +43,4 @@ targetBody.classList.add(className) }); - - window.addEventListener('click', function (e) { if (getTarget(e.target)) e.preventDefault(); }); }(); \ No newline at end of file diff --git a/lib/js/sliders.js b/lib/js/sliders.js index b659e83..9af153a 100644 --- a/lib/js/sliders.js +++ b/lib/js/sliders.js @@ -109,6 +109,6 @@ window.addEventListener('touchstart', onTouchStart); window.addEventListener('touchmove', onTouchMove); - window.addEventListener('touchend', onTouchEnd); + window.addEventListener(clickEvent, onTouchEnd); }(); diff --git a/lib/js/toggles.js b/lib/js/toggles.js index 5054de8..f790d60 100644 --- a/lib/js/toggles.js +++ b/lib/js/toggles.js @@ -65,7 +65,7 @@ toggle.classList[(distanceX > (toggleWidth/2 - handleWidth/2)) ? 'add' : 'remove']('active'); }); - window.addEventListener('touchend', function (e) { + window.addEventListener(clickEvent, function (e) { if (!toggle) return; var handle = toggle.querySelector('.toggle-handle');