UNPKG

foundation-sites

Version:

The most advanced responsive front-end framework in the world.

3 lines (2 loc) 4.53 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./foundation.core"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery"],t):"object"==typeof exports?exports["foundation.util.touch"]=t(require("./foundation.core"),require("jquery")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.util.touch"]=t(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.jQuery))}(window,function(n,o){return u={"./foundation.core":function(e,t){e.exports=n},"./js/entries/plugins/foundation.util.touch.js":function(e,t,n){"use strict";n.r(t);var o=n("jquery"),o=n.n(o),i=n("./js/foundation.util.touch.js");n.d(t,"Touch",function(){return i.Touch});var u=n("./foundation.core");n.d(t,"Foundation",function(){return u.Foundation}),i.Touch.init(o.a),window.Foundation.Touch=i.Touch},"./js/foundation.util.touch.js":function(e,t,n){"use strict";n.r(t),n.d(t,"Touch",function(){return a});var t=n("jquery"),o=n.n(t);function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var u,r,c,s,a={},f=!1,p=!1;function l(e){this.removeEventListener("touchmove",d),this.removeEventListener("touchend",l),p||(e=o.a.Event("tap",s||e),o()(this).trigger(e)),s=null,p=f=!1}function d(e){var t,n;!0===o.a.spotSwipe.preventDefault&&e.preventDefault(),f&&(t=e.touches[0].pageX,t=u-t,p=!0,c=(new Date).getTime()-r,(n=Math.abs(t)>=o.a.spotSwipe.moveThreshold&&c<=o.a.spotSwipe.timeThreshold?0<t?"left":"right":n)&&(e.preventDefault(),l.apply(this,arguments),o()(this).trigger(o.a.Event("swipe",Object.assign({},e)),n).trigger(o.a.Event("swipe".concat(n),Object.assign({},e)))))}function h(e){1===e.touches.length&&(u=e.touches[0].pageX,e.touches[0].pageY,s=e,p=!(f=!0),r=(new Date).getTime(),this.addEventListener("touchmove",d,{passive:!0===o.a.spotSwipe.preventDefault}),this.addEventListener("touchend",l,!1))}function v(){this.addEventListener&&this.addEventListener("touchstart",h,{passive:!0})}var w=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.version="1.0.0",this.enabled="ontouchstart"in document.documentElement,this.preventDefault=!1,this.moveThreshold=75,this.timeThreshold=200,this.$=e,this._init()}var e,n,o;return e=t,(n=[{key:"_init",value:function(){var e=this.$;e.event.special.swipe={setup:v},e.event.special.tap={setup:v},e.each(["left","up","down","right"],function(){e.event.special["swipe".concat(this)]={setup:function(){e(this).on("swipe",e.noop)}}})}}])&&i(e.prototype,n),o&&i(e,o),t}();a.setupSpotSwipe=function(e){e.spotSwipe=new w(e)},a.setupTouchHandler=function(o){o.fn.addTouch=function(){this.each(function(e,t){o(t).bind("touchstart touchmove touchend touchcancel",function(e){n(e)})});var n=function(e){var t,n=e.changedTouches[0],e={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup"}[e.type];"MouseEvent"in window&&"function"==typeof window.MouseEvent?t=new window.MouseEvent(e,{bubbles:!0,cancelable:!0,screenX:n.screenX,screenY:n.screenY,clientX:n.clientX,clientY:n.clientY}):(t=document.createEvent("MouseEvent")).initMouseEvent(e,!0,!0,window,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),n.target.dispatchEvent(t)}}},a.init=function(e){void 0===e.spotSwipe&&(a.setupSpotSwipe(e),a.setupTouchHandler(e))}},28:function(e,t,n){e.exports=n("./js/entries/plugins/foundation.util.touch.js")},jquery:function(e,t){e.exports=o}},r={},i.m=u,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=28);function i(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return u[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}var u,r}); //# sourceMappingURL=foundation.util.touch.min.js.map