From 6893349b6c611d6b5b0766a5c7e9031bce7ead6f Mon Sep 17 00:00:00 2001 From: Stuart Yamartino Date: Fri, 18 Mar 2016 22:43:53 -0400 Subject: [PATCH 1/2] Console.warn and return early if no window --- bower.json | 2 +- dist/jquery.pressure.js | 150 ++++++++++++++++++------------------ dist/jquery.pressure.min.js | 4 +- dist/pressure.js | 150 ++++++++++++++++++------------------ dist/pressure.min.js | 4 +- gulpfile.js | 23 +++--- package.json | 5 +- src/globalize.js | 6 +- 8 files changed, 176 insertions(+), 168 deletions(-) diff --git a/bower.json b/bower.json index 85a2993..9022707 100644 --- a/bower.json +++ b/bower.json @@ -25,5 +25,5 @@ "test", "tests" ], - "version": "1.0.0" + "version": "1.0.1" } diff --git a/dist/jquery.pressure.js b/dist/jquery.pressure.js index a4f29d3..1111021 100644 --- a/dist/jquery.pressure.js +++ b/dist/jquery.pressure.js @@ -1,17 +1,17 @@ -// Pressure v1.0.0 | Created By Stuart Yamartino | MIT License | 2015-Present +// Pressure v1.0.1 | Created By Stuart Yamartino | MIT License | 2015-Present ;(function(window, document, $) { -'use strict'; +"use strict"; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); -function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } + //--------------------- Public jQuery API Section ---------------------// if ($ !== false) { @@ -30,6 +30,38 @@ if ($ !== false) { throw new Error("Pressure jQuery requires jQuery is loaded before your jquery.pressure.min.js file"); } +// Assign the Pressure object to the global object (or module for npm) so it can be called from inside the self executing anonymous function +if (window !== false) { + // if Pressure is not defined, it is the jquery.pressure library and skip the next setup + if (typeof Pressure !== "undefined") { + // this if block came from: http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/ + if (typeof define === "function" && define.amd) { + // Now we're wrapping the factory and assigning the return + // value to the root (window) and returning it as well to + // the AMD loader. + var pressure = Pressure; + define(["pressure"], function (Pressure) { + return Pressure; + }); + } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" && module.exports) { + // I've not encountered a need for this yet, since I haven't + // run into a scenario where plain modules depend on CommonJS + // *and* I happen to be loading in a CJS browser environment + // but I'm including it for the sake of being thorough + var pressure = Pressure; + module.exports = pressure; + } else { + window.Pressure = Pressure; + } + } +} else { + console.warn("Pressure requires a window with a document"); + // I can't put 'return' here because babel blows up when it is compiled with gulp + // because it is not in a function. It is only put into the iife when gulp runs. + // The next line is replaced with 'return;' when gulp runs. + return; +} + var Element = (function () { function Element(element, block, options) { _classCallCheck(this, Element); @@ -42,7 +74,7 @@ var Element = (function () { } _createClass(Element, [{ - key: 'routeEvents', + key: "routeEvents", value: function routeEvents() { // if on desktop and requesting Force Touch or not requesting 3D Touch if (Support.mobile === false && (this.type === 'force' || this.type !== '3d')) { @@ -58,7 +90,7 @@ var Element = (function () { } } }, { - key: 'instantFail', + key: "instantFail", value: function instantFail() { var _this = this; @@ -83,27 +115,27 @@ var Adapter = (function () { } _createClass(Adapter, [{ - key: 'add', + key: "add", value: function add(event, set) { this.el.addEventListener(event, set, false); } }, { - key: 'remove', + key: "remove", value: function remove(event, set) { this.el.removeEventListener(event, set); } }, { - key: 'setPressed', + key: "setPressed", value: function setPressed(boolean) { this.pressed = boolean; } }, { - key: 'setDeepPressed', + key: "setDeepPressed", value: function setDeepPressed(boolean) { this.deepPressed = boolean; } }, { - key: 'failOrPolyfill', + key: "failOrPolyfill", value: function failOrPolyfill(event) { Support.didFail(); // is the polyfill option set @@ -117,7 +149,7 @@ var Adapter = (function () { // prevent the default action of text selection, "peak & pop", and force touch special feature }, { - key: 'preventDefault', + key: "preventDefault", value: function preventDefault(event) { if (Config.get('preventDefault', this.element.options) === true) { event.preventDefault(); @@ -148,20 +180,20 @@ var Adapter3DTouch = (function (_Adapter) { } _createClass(Adapter3DTouch, [{ - key: '$support', + key: "$support", value: function $support() { this.supportMethod = this.middleMan.bind(this); this.add('touchstart', this.supportMethod); } }, { - key: 'middleMan', + key: "middleMan", value: function middleMan(event) { this.setPressed(true); this.forceValueTest = event.touches[0].force; this.supportCallback(0, event); } }, { - key: 'supportCallback', + key: "supportCallback", value: function supportCallback(iter, event) { // this checks up to 10 times on a touch to see if the touch can read a force value or not to check "support" if (Support.hasRun === false && !(this.polyfill instanceof AdapterPolyfill)) { @@ -186,7 +218,7 @@ var Adapter3DTouch = (function (_Adapter) { } } }, { - key: '$start', + key: "$start", value: function $start() { var _this3 = this; @@ -200,12 +232,12 @@ var Adapter3DTouch = (function (_Adapter) { }); } }, { - key: '$change', + key: "$change", value: function $change() { this.add('touchstart', this.changeLogic.bind(this)); } }, { - key: 'changeLogic', + key: "changeLogic", value: function changeLogic(event) { if (Support.forPressure && this.pressed) { this.setPressed(true); @@ -213,7 +245,7 @@ var Adapter3DTouch = (function (_Adapter) { } } }, { - key: '$end', + key: "$end", value: function $end() { var _this4 = this; @@ -227,7 +259,7 @@ var Adapter3DTouch = (function (_Adapter) { }); } }, { - key: 'startDeepPress', + key: "startDeepPress", value: function startDeepPress(event) { if (this.deepPressed === false) { runClosure(this.block, 'startDeepPress', this.el, event); @@ -235,7 +267,7 @@ var Adapter3DTouch = (function (_Adapter) { this.setDeepPressed(true); } }, { - key: 'endDeepPress', + key: "endDeepPress", value: function endDeepPress() { if (this.deepPressed === true) { runClosure(this.block, 'endDeepPress', this.el); @@ -243,7 +275,7 @@ var Adapter3DTouch = (function (_Adapter) { this.setDeepPressed(false); } }, { - key: 'runForce', + key: "runForce", value: function runForce(event) { if (this.pressed) { this.touch = this.selectTouch(event); @@ -255,7 +287,7 @@ var Adapter3DTouch = (function (_Adapter) { // link up the touch point to the correct element, this is to support multitouch }, { - key: 'selectTouch', + key: "selectTouch", value: function selectTouch(event) { if (event.touches.length === 1) { return this.returnTouch(event.touches[0], event); @@ -272,7 +304,7 @@ var Adapter3DTouch = (function (_Adapter) { // return the touch and run a start or end for deep press }, { - key: 'returnTouch', + key: "returnTouch", value: function returnTouch(touch, event) { touch.force >= 0.5 ? this.startDeepPress(event) : this.endDeepPress(); return touch; @@ -302,19 +334,19 @@ var AdapterForceTouch = (function (_Adapter2) { // Support check methods _createClass(AdapterForceTouch, [{ - key: '$support', + key: "$support", value: function $support() { this.add('webkitmouseforcewillbegin', this.forceTouchEnabled); this.add('mousedown', this.supportCallback.bind(this)); } }, { - key: 'forceTouchEnabled', + key: "forceTouchEnabled", value: function forceTouchEnabled(event) { event.preventDefault(); Support.didSucceed('force'); } }, { - key: 'supportCallback', + key: "supportCallback", value: function supportCallback(event) { if (Support.forPressure === true || this.polyfill instanceof AdapterPolyfill) { this.remove('webkitmouseforcewillbegin', this.forceTouchEnabled); @@ -324,7 +356,7 @@ var AdapterForceTouch = (function (_Adapter2) { } } }, { - key: '$start', + key: "$start", value: function $start() { var _this6 = this; @@ -337,7 +369,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$change', + key: "$change", value: function $change() { var _this7 = this; @@ -348,7 +380,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$end', + key: "$end", value: function $end() { var _this8 = this; @@ -369,7 +401,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$startDeepPress', + key: "$startDeepPress", value: function $startDeepPress() { var _this9 = this; @@ -381,7 +413,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$endDeepPress', + key: "$endDeepPress", value: function $endDeepPress() { var _this10 = this; @@ -404,7 +436,7 @@ var AdapterForceTouch = (function (_Adapter2) { // make the force the standard 0 to 1 scale and not the 1 to 3 scale }, { - key: 'normalizeForce', + key: "normalizeForce", value: function normalizeForce(force) { return this.reachOne(map(force, 1, 3, 0, 1)); } @@ -412,7 +444,7 @@ var AdapterForceTouch = (function (_Adapter2) { // if the force value is above 0.999 set the force to 1 }, { - key: 'reachOne', + key: "reachOne", value: function reachOne(force) { return force > 0.999 ? 1 : force; } @@ -439,14 +471,14 @@ var AdapterPolyfill = (function (_Adapter3) { } _createClass(AdapterPolyfill, [{ - key: 'firstRun', + key: "firstRun", value: function firstRun(event) { this.preventDefault(event); this.startLogic(event); this.changeLogic(event); } }, { - key: '$start', + key: "$start", value: function $start() { var _this12 = this; @@ -456,18 +488,18 @@ var AdapterPolyfill = (function (_Adapter3) { }); } }, { - key: 'startLogic', + key: "startLogic", value: function startLogic(event) { this.setPressed(true); runClosure(this.block, 'start', this.el, event); } }, { - key: '$change', + key: "$change", value: function $change() { this.add(Support.mobile ? 'touchstart' : 'mousedown', this.changeLogic.bind(this)); } }, { - key: 'changeLogic', + key: "changeLogic", value: function changeLogic(event) { if (this.pressed) { this.setPressed(true); @@ -475,7 +507,7 @@ var AdapterPolyfill = (function (_Adapter3) { } } }, { - key: '$end', + key: "$end", value: function $end() { var _this13 = this; @@ -496,7 +528,7 @@ var AdapterPolyfill = (function (_Adapter3) { }); } }, { - key: 'startDeepPress', + key: "startDeepPress", value: function startDeepPress(event) { if (this.deepPressed === false) { runClosure(this.block, 'startDeepPress', this.el, event); @@ -504,7 +536,7 @@ var AdapterPolyfill = (function (_Adapter3) { this.setDeepPressed(true); } }, { - key: 'endDeepPress', + key: "endDeepPress", value: function endDeepPress() { if (this.deepPressed === true) { runClosure(this.block, 'endDeepPress', this.el); @@ -512,7 +544,7 @@ var AdapterPolyfill = (function (_Adapter3) { this.setDeepPressed(false); } }, { - key: 'runForce', + key: "runForce", value: function runForce(event) { if (this.pressed) { runClosure(this.block, 'change', this.el, this.force, event); @@ -602,8 +634,8 @@ var loopPressureElements = function loopPressureElements(selector, closure) { //Returns true if it is a DOM element var isElement = function isElement(o) { - return (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === "object" ? o instanceof HTMLElement : //DOM2 - o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"; + return (typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement)) === "object" ? o instanceof HTMLElement : //DOM2 + o && (typeof o === "undefined" ? "undefined" : _typeof(o)) === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"; }; // run the closure if the property exists in the object @@ -619,32 +651,4 @@ var runClosure = function runClosure(closure, method, element) { var map = function map(x, in_min, in_max, out_min, out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }; - -// Assign the Pressure object to the global object (or module for npm) so it can be called from inside the self executing anonymous function -if (window !== false) { - // if Pressure is not defined, it is the jquery.pressure library and skip the next setup - if (typeof Pressure !== "undefined") { - // this if block came from: http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/ - if (typeof define === "function" && define.amd) { - // Now we're wrapping the factory and assigning the return - // value to the root (window) and returning it as well to - // the AMD loader. - var pressure = Pressure; - define(["pressure"], function (Pressure) { - return Pressure; - }); - } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === "object" && module.exports) { - // I've not encountered a need for this yet, since I haven't - // run into a scenario where plain modules depend on CommonJS - // *and* I happen to be loading in a CJS browser environment - // but I'm including it for the sake of being thorough - var pressure = Pressure; - module.exports = pressure; - } else { - window.Pressure = Pressure; - } - } -} else { - throw new Error("Pressure requires a window with a document"); -} }(typeof window !== "undefined" ? window : false, typeof window !== "undefined" ? window.document : false, typeof jQuery !== "undefined" ? jQuery : false)); diff --git a/dist/jquery.pressure.min.js b/dist/jquery.pressure.min.js index 61886ae..548cc8a 100644 --- a/dist/jquery.pressure.min.js +++ b/dist/jquery.pressure.min.js @@ -1,2 +1,2 @@ -// Pressure v1.0.0 | Created By Stuart Yamartino | MIT License | 2015-Present -!function(e,t,s){"use strict";function n(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var u=function(){function e(e,t){for(var s=0;s=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){p.forPressure&&(e.setPressed(!0),e.preventDefault(t),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){p.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){p.forPressure&&(e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),P(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(l),a=function(e){function t(e){o(this,t);var s=r(this,Object.getPrototypeOf(t).call(this,e));return s.$support(),s.$start(),s.$change(),s.$startDeepPress(),s.$endDeepPress(),s.$end(),s}return i(t,e),u(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),p.didSucceed("force")}},{key:"supportCallback",value:function(e){p.forPressure===!0||this.polyfill instanceof f?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){p.forPressure&&(e.setPressed(!0),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){p.forPressure&&0!==t.webkitForce&&e.pressed&&P(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){p.forPressure&&(e.setPressed(!1),P(e.block,"end",e.el))}),this.add("mouseleave",function(){p.forPressure&&(e.pressed&&P(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){p.forPressure&&(e.setDeepPressed(!0),P(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){p.forPressure&&(e.setDeepPressed(!1),P(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){p.forPressure&&(e.deepPressed&&P(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(b(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(l),f=function(e){function t(e,s){o(this,t);var n=r(this,Object.getPrototypeOf(t).call(this,e));return n.$start(),n.$change(),n.$end(),n.force=0,n.increment=.01,n.firstRun(s),n}return i(t,e),u(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(p.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),P(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(p.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(p.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&P(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(P(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(l),d={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},p={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},y=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var r=t.querySelectorAll(e),i=0;i=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){y.forPressure&&(e.setPressed(!0),e.preventDefault(t),b(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){y.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){y.forPressure&&(e.endDeepPress(),e.setPressed(!1),b(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&b(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&b(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),b(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(h),f=function(e){function t(e){i(this,t);var s=n(this,Object.getPrototypeOf(t).call(this,e));return s.$support(),s.$start(),s.$change(),s.$startDeepPress(),s.$endDeepPress(),s.$end(),s}return r(t,e),u(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),y.didSucceed("force")}},{key:"supportCallback",value:function(e){y.forPressure===!0||this.polyfill instanceof d?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){y.forPressure&&(e.setPressed(!0),b(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){y.forPressure&&0!==t.webkitForce&&e.pressed&&b(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){y.forPressure&&(e.setPressed(!1),b(e.block,"end",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.pressed&&b(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){y.forPressure&&(e.setDeepPressed(!0),b(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){y.forPressure&&(e.setDeepPressed(!1),b(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.deepPressed&&b(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(k(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(h),d=function(e){function t(e,s){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this,e));return r.$start(),r.$change(),r.$end(),r.force=0,r.increment=.01,r.firstRun(s),r}return r(t,e),u(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(y.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),b(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(y.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(y.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),b(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&b(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&b(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&b(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(b(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(h),p={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},y={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},v=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var r=t.querySelectorAll(e),i=0;i= 0.5 ? this.startDeepPress(event) : this.endDeepPress(); return touch; @@ -307,19 +339,19 @@ var AdapterForceTouch = (function (_Adapter2) { // Support check methods _createClass(AdapterForceTouch, [{ - key: '$support', + key: "$support", value: function $support() { this.add('webkitmouseforcewillbegin', this.forceTouchEnabled); this.add('mousedown', this.supportCallback.bind(this)); } }, { - key: 'forceTouchEnabled', + key: "forceTouchEnabled", value: function forceTouchEnabled(event) { event.preventDefault(); Support.didSucceed('force'); } }, { - key: 'supportCallback', + key: "supportCallback", value: function supportCallback(event) { if (Support.forPressure === true || this.polyfill instanceof AdapterPolyfill) { this.remove('webkitmouseforcewillbegin', this.forceTouchEnabled); @@ -329,7 +361,7 @@ var AdapterForceTouch = (function (_Adapter2) { } } }, { - key: '$start', + key: "$start", value: function $start() { var _this6 = this; @@ -342,7 +374,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$change', + key: "$change", value: function $change() { var _this7 = this; @@ -353,7 +385,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$end', + key: "$end", value: function $end() { var _this8 = this; @@ -374,7 +406,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$startDeepPress', + key: "$startDeepPress", value: function $startDeepPress() { var _this9 = this; @@ -386,7 +418,7 @@ var AdapterForceTouch = (function (_Adapter2) { }); } }, { - key: '$endDeepPress', + key: "$endDeepPress", value: function $endDeepPress() { var _this10 = this; @@ -409,7 +441,7 @@ var AdapterForceTouch = (function (_Adapter2) { // make the force the standard 0 to 1 scale and not the 1 to 3 scale }, { - key: 'normalizeForce', + key: "normalizeForce", value: function normalizeForce(force) { return this.reachOne(_map(force, 1, 3, 0, 1)); } @@ -417,7 +449,7 @@ var AdapterForceTouch = (function (_Adapter2) { // if the force value is above 0.999 set the force to 1 }, { - key: 'reachOne', + key: "reachOne", value: function reachOne(force) { return force > 0.999 ? 1 : force; } @@ -444,14 +476,14 @@ var AdapterPolyfill = (function (_Adapter3) { } _createClass(AdapterPolyfill, [{ - key: 'firstRun', + key: "firstRun", value: function firstRun(event) { this.preventDefault(event); this.startLogic(event); this.changeLogic(event); } }, { - key: '$start', + key: "$start", value: function $start() { var _this12 = this; @@ -461,18 +493,18 @@ var AdapterPolyfill = (function (_Adapter3) { }); } }, { - key: 'startLogic', + key: "startLogic", value: function startLogic(event) { this.setPressed(true); runClosure(this.block, 'start', this.el, event); } }, { - key: '$change', + key: "$change", value: function $change() { this.add(Support.mobile ? 'touchstart' : 'mousedown', this.changeLogic.bind(this)); } }, { - key: 'changeLogic', + key: "changeLogic", value: function changeLogic(event) { if (this.pressed) { this.setPressed(true); @@ -480,7 +512,7 @@ var AdapterPolyfill = (function (_Adapter3) { } } }, { - key: '$end', + key: "$end", value: function $end() { var _this13 = this; @@ -501,7 +533,7 @@ var AdapterPolyfill = (function (_Adapter3) { }); } }, { - key: 'startDeepPress', + key: "startDeepPress", value: function startDeepPress(event) { if (this.deepPressed === false) { runClosure(this.block, 'startDeepPress', this.el, event); @@ -509,7 +541,7 @@ var AdapterPolyfill = (function (_Adapter3) { this.setDeepPressed(true); } }, { - key: 'endDeepPress', + key: "endDeepPress", value: function endDeepPress() { if (this.deepPressed === true) { runClosure(this.block, 'endDeepPress', this.el); @@ -517,7 +549,7 @@ var AdapterPolyfill = (function (_Adapter3) { this.setDeepPressed(false); } }, { - key: 'runForce', + key: "runForce", value: function runForce(event) { if (this.pressed) { runClosure(this.block, 'change', this.el, this.force, event); @@ -607,8 +639,8 @@ var loopPressureElements = function loopPressureElements(selector, closure) { //Returns true if it is a DOM element var isElement = function isElement(o) { - return (typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement)) === "object" ? o instanceof HTMLElement : //DOM2 - o && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"; + return (typeof HTMLElement === "undefined" ? "undefined" : _typeof(HTMLElement)) === "object" ? o instanceof HTMLElement : //DOM2 + o && (typeof o === "undefined" ? "undefined" : _typeof(o)) === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"; }; // run the closure if the property exists in the object @@ -624,32 +656,4 @@ var runClosure = function runClosure(closure, method, element) { var _map = function _map(x, in_min, in_max, out_min, out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }; - -// Assign the Pressure object to the global object (or module for npm) so it can be called from inside the self executing anonymous function -if (window !== false) { - // if Pressure is not defined, it is the jquery.pressure library and skip the next setup - if (typeof Pressure !== "undefined") { - // this if block came from: http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/ - if (typeof define === "function" && define.amd) { - // Now we're wrapping the factory and assigning the return - // value to the root (window) and returning it as well to - // the AMD loader. - var pressure = Pressure; - define(["pressure"], function (Pressure) { - return Pressure; - }); - } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === "object" && module.exports) { - // I've not encountered a need for this yet, since I haven't - // run into a scenario where plain modules depend on CommonJS - // *and* I happen to be loading in a CJS browser environment - // but I'm including it for the sake of being thorough - var pressure = Pressure; - module.exports = pressure; - } else { - window.Pressure = Pressure; - } - } -} else { - throw new Error("Pressure requires a window with a document"); -} }(typeof window !== "undefined" ? window : false, typeof window !== "undefined" ? window.document : false)); diff --git a/dist/pressure.min.js b/dist/pressure.min.js index 9a6ee9c..d08bdb5 100644 --- a/dist/pressure.min.js +++ b/dist/pressure.min.js @@ -1,2 +1,2 @@ -// Pressure v1.0.0 | Created By Stuart Yamartino | MIT License | 2015-Present -!function(e,t){"use strict";function s(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var s=0;s=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){p.forPressure&&(e.setPressed(!0),e.preventDefault(t),b(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){p.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){p.forPressure&&(e.endDeepPress(),e.setPressed(!1),b(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&b(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&b(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),b(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(l),a=function(e){function t(e){r(this,t);var s=n(this,Object.getPrototypeOf(t).call(this,e));return s.$support(),s.$start(),s.$change(),s.$startDeepPress(),s.$endDeepPress(),s.$end(),s}return i(t,e),o(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),p.didSucceed("force")}},{key:"supportCallback",value:function(e){p.forPressure===!0||this.polyfill instanceof f?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){p.forPressure&&(e.setPressed(!0),b(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){p.forPressure&&0!==t.webkitForce&&e.pressed&&b(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){p.forPressure&&(e.setPressed(!1),b(e.block,"end",e.el))}),this.add("mouseleave",function(){p.forPressure&&(e.pressed&&b(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){p.forPressure&&(e.setDeepPressed(!0),b(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){p.forPressure&&(e.setDeepPressed(!1),b(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){p.forPressure&&(e.deepPressed&&b(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(P(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(l),f=function(e){function t(e,s){r(this,t);var i=n(this,Object.getPrototypeOf(t).call(this,e));return i.$start(),i.$change(),i.$end(),i.force=0,i.increment=.01,i.firstRun(s),i}return i(t,e),o(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(p.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),b(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(p.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(p.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),b(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&b(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&b(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&b(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(b(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(l),d={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},p={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},y=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var i=t.querySelectorAll(e),r=0;r=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){y.forPressure&&(e.setPressed(!0),e.preventDefault(t),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){y.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){y.forPressure&&(e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),P(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(h),f=function(e){function t(e){i(this,t);var n=s(this,Object.getPrototypeOf(t).call(this,e));return n.$support(),n.$start(),n.$change(),n.$startDeepPress(),n.$endDeepPress(),n.$end(),n}return n(t,e),o(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),y.didSucceed("force")}},{key:"supportCallback",value:function(e){y.forPressure===!0||this.polyfill instanceof d?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){y.forPressure&&(e.setPressed(!0),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){y.forPressure&&0!==t.webkitForce&&e.pressed&&P(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){y.forPressure&&(e.setPressed(!1),P(e.block,"end",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.pressed&&P(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){y.forPressure&&(e.setDeepPressed(!0),P(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){y.forPressure&&(e.setDeepPressed(!1),P(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.deepPressed&&P(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(k(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(h),d=function(e){function t(e,n){i(this,t);var r=s(this,Object.getPrototypeOf(t).call(this,e));return r.$start(),r.$change(),r.$end(),r.force=0,r.increment=.01,r.firstRun(n),r}return n(t,e),o(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(y.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),P(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(y.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(y.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&P(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(P(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(h),p={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},y={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},v=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var i=t.querySelectorAll(e),r=0;r Date: Fri, 18 Mar 2016 22:59:39 -0400 Subject: [PATCH 2/2] Updated npm gulp libraries --- dist/jquery.pressure.js | 29 ++++++++++++++++------------- dist/jquery.pressure.min.js | 2 +- dist/pressure.js | 31 ++++++++++++++++++------------- dist/pressure.min.js | 2 +- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/dist/jquery.pressure.js b/dist/jquery.pressure.js index 1111021..ccb8acd 100644 --- a/dist/jquery.pressure.js +++ b/dist/jquery.pressure.js @@ -2,7 +2,9 @@ ;(function(window, document, $) { "use strict"; -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } @@ -10,8 +12,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } - //--------------------- Public jQuery API Section ---------------------// if ($ !== false) { @@ -62,7 +62,7 @@ if (window !== false) { return; } -var Element = (function () { +var Element = function () { function Element(element, block, options) { _classCallCheck(this, Element); @@ -101,9 +101,9 @@ var Element = (function () { }]); return Element; -})(); +}(); -var Adapter = (function () { +var Adapter = function () { function Adapter(element) { _classCallCheck(this, Adapter); @@ -162,9 +162,9 @@ var Adapter = (function () { }]); return Adapter; -})(); +}(); -var Adapter3DTouch = (function (_Adapter) { +var Adapter3DTouch = function (_Adapter) { _inherits(Adapter3DTouch, _Adapter); function Adapter3DTouch(element) { @@ -312,9 +312,9 @@ var Adapter3DTouch = (function (_Adapter) { }]); return Adapter3DTouch; -})(Adapter); +}(Adapter); -var AdapterForceTouch = (function (_Adapter2) { +var AdapterForceTouch = function (_Adapter2) { _inherits(AdapterForceTouch, _Adapter2); function AdapterForceTouch(element) { @@ -333,6 +333,7 @@ var AdapterForceTouch = (function (_Adapter2) { // Support check methods + _createClass(AdapterForceTouch, [{ key: "$support", value: function $support() { @@ -451,9 +452,9 @@ var AdapterForceTouch = (function (_Adapter2) { }]); return AdapterForceTouch; -})(Adapter); +}(Adapter); -var AdapterPolyfill = (function (_Adapter3) { +var AdapterPolyfill = function (_Adapter3) { _inherits(AdapterPolyfill, _Adapter3); function AdapterPolyfill(element, firstEvent) { @@ -556,10 +557,11 @@ var AdapterPolyfill = (function (_Adapter3) { }]); return AdapterPolyfill; -})(Adapter); +}(Adapter); // This class holds the states of the the Pressure config + var Config = { preventDefault: true, @@ -573,6 +575,7 @@ var Config = { return options.hasOwnProperty(option) ? options[option] : this[option]; }, + // this will set the global configs set: function set(options) { for (var k in options) { diff --git a/dist/jquery.pressure.min.js b/dist/jquery.pressure.min.js index 548cc8a..9967084 100644 --- a/dist/jquery.pressure.min.js +++ b/dist/jquery.pressure.min.js @@ -1,2 +1,2 @@ // Pressure v1.0.1 | Created By Stuart Yamartino | MIT License | 2015-Present -!function(e,t,s){"use strict";function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var u=function(){function e(e,t){for(var s=0;s=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){y.forPressure&&(e.setPressed(!0),e.preventDefault(t),b(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){y.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){y.forPressure&&(e.endDeepPress(),e.setPressed(!1),b(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&b(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&b(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),b(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(h),f=function(e){function t(e){i(this,t);var s=n(this,Object.getPrototypeOf(t).call(this,e));return s.$support(),s.$start(),s.$change(),s.$startDeepPress(),s.$endDeepPress(),s.$end(),s}return r(t,e),u(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),y.didSucceed("force")}},{key:"supportCallback",value:function(e){y.forPressure===!0||this.polyfill instanceof d?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){y.forPressure&&(e.setPressed(!0),b(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){y.forPressure&&0!==t.webkitForce&&e.pressed&&b(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){y.forPressure&&(e.setPressed(!1),b(e.block,"end",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.pressed&&b(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){y.forPressure&&(e.setDeepPressed(!0),b(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){y.forPressure&&(e.setDeepPressed(!1),b(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.deepPressed&&b(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(k(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(h),d=function(e){function t(e,s){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this,e));return r.$start(),r.$change(),r.$end(),r.force=0,r.increment=.01,r.firstRun(s),r}return r(t,e),u(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(y.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),b(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(y.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(y.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),b(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&b(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&b(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&b(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(b(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(h),p={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},y={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},v=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var r=t.querySelectorAll(e),i=0;i=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){y.forPressure&&(e.setPressed(!0),e.preventDefault(t),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){y.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){y.forPressure&&(e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),P(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(h),f=function(e){function t(e){i(this,t);var s=n(this,Object.getPrototypeOf(t).call(this,e));return s.$support(),s.$start(),s.$change(),s.$startDeepPress(),s.$endDeepPress(),s.$end(),s}return r(t,e),o(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),y.didSucceed("force")}},{key:"supportCallback",value:function(e){y.forPressure===!0||this.polyfill instanceof d?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){y.forPressure&&(e.setPressed(!0),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){y.forPressure&&0!==t.webkitForce&&e.pressed&&P(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){y.forPressure&&(e.setPressed(!1),P(e.block,"end",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.pressed&&P(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){y.forPressure&&(e.setDeepPressed(!0),P(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){y.forPressure&&(e.setDeepPressed(!1),P(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.deepPressed&&P(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(k(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(h),d=function(e){function t(e,s){i(this,t);var r=n(this,Object.getPrototypeOf(t).call(this,e));return r.$start(),r.$change(),r.$end(),r.force=0,r.increment=.01,r.firstRun(s),r}return r(t,e),o(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(y.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),P(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(y.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(y.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&P(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(P(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(h),p={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},y={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},v=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var r=t.querySelectorAll(e),i=0;i=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){y.forPressure&&(e.setPressed(!0),e.preventDefault(t),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){y.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){y.forPressure&&(e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),P(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(h),f=function(e){function t(e){i(this,t);var n=s(this,Object.getPrototypeOf(t).call(this,e));return n.$support(),n.$start(),n.$change(),n.$startDeepPress(),n.$endDeepPress(),n.$end(),n}return n(t,e),o(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),y.didSucceed("force")}},{key:"supportCallback",value:function(e){y.forPressure===!0||this.polyfill instanceof d?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){y.forPressure&&(e.setPressed(!0),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){y.forPressure&&0!==t.webkitForce&&e.pressed&&P(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){y.forPressure&&(e.setPressed(!1),P(e.block,"end",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.pressed&&P(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){y.forPressure&&(e.setDeepPressed(!0),P(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){y.forPressure&&(e.setDeepPressed(!1),P(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.deepPressed&&P(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(k(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(h),d=function(e){function t(e,n){i(this,t);var r=s(this,Object.getPrototypeOf(t).call(this,e));return r.$start(),r.$change(),r.$end(),r.force=0,r.increment=.01,r.firstRun(n),r}return n(t,e),o(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(y.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),P(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(y.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(y.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&P(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(P(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(h),p={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},y={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},v=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var i=t.querySelectorAll(e),r=0;r=e&&this.pressed?(e+=1,setTimeout(this.supportCallback.bind(this),10,e,t)):this.pressed&&this.failOrPolyfill(t)}},{key:"$start",value:function(){var e=this;this.add("touchstart",function(t){y.forPressure&&(e.setPressed(!0),e.preventDefault(t),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){this.add("touchstart",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){y.forPressure&&this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add("touchend",function(){y.forPressure&&(e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el))})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(this.touch=this.selectTouch(e),setTimeout(this.runForce.bind(this),10,e),P(this.block,"change",this.el,this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t=.5?this.startDeepPress(t):this.endDeepPress(),e}}]),t}(h),f=function(e){function t(e){i(this,t);var n=s(this,Object.getPrototypeOf(t).call(this,e));return n.$support(),n.$start(),n.$change(),n.$startDeepPress(),n.$endDeepPress(),n.$end(),n}return n(t,e),o(t,[{key:"$support",value:function(){this.add("webkitmouseforcewillbegin",this.forceTouchEnabled),this.add("mousedown",this.supportCallback.bind(this))}},{key:"forceTouchEnabled",value:function(e){e.preventDefault(),y.didSucceed("force")}},{key:"supportCallback",value:function(e){y.forPressure===!0||this.polyfill instanceof d?(this.remove("webkitmouseforcewillbegin",this.forceTouchEnabled),this.preventDefault(e)):this.failOrPolyfill(e)}},{key:"$start",value:function(){var e=this;this.add("mousedown",function(t){y.forPressure&&(e.setPressed(!0),P(e.block,"start",e.el,t))})}},{key:"$change",value:function(){var e=this;this.add("webkitmouseforcechanged",function(t){y.forPressure&&0!==t.webkitForce&&e.pressed&&P(e.block,"change",e.el,e.normalizeForce(t.webkitForce),t)})}},{key:"$end",value:function(){var e=this;this.add("mouseup",function(){y.forPressure&&(e.setPressed(!1),P(e.block,"end",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.pressed&&P(e.block,"end",e.el),e.setPressed(!1))})}},{key:"$startDeepPress",value:function(){var e=this;this.add("webkitmouseforcedown",function(t){y.forPressure&&(e.setDeepPressed(!0),P(e.block,"startDeepPress",e.el,t))})}},{key:"$endDeepPress",value:function(){var e=this;this.add("webkitmouseforceup",function(){y.forPressure&&(e.setDeepPressed(!1),P(e.block,"endDeepPress",e.el))}),this.add("mouseleave",function(){y.forPressure&&(e.deepPressed&&P(e.block,"endDeepPress",e.el),e.setDeepPressed(!1))})}},{key:"normalizeForce",value:function(e){return this.reachOne(k(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.999?1:e}}]),t}(h),d=function(e){function t(e,n){i(this,t);var o=s(this,Object.getPrototypeOf(t).call(this,e));return o.$start(),o.$change(),o.$end(),o.force=0,o.increment=.01,o.firstRun(n),o}return n(t,e),o(t,[{key:"firstRun",value:function(e){this.preventDefault(e),this.startLogic(e),this.changeLogic(e)}},{key:"$start",value:function(){var e=this;this.add(y.mobile?"touchstart":"mousedown",function(t){e.startLogic(t)})}},{key:"startLogic",value:function(e){this.setPressed(!0),P(this.block,"start",this.el,e)}},{key:"$change",value:function(){this.add(y.mobile?"touchstart":"mousedown",this.changeLogic.bind(this))}},{key:"changeLogic",value:function(e){this.pressed&&(this.setPressed(!0),this.runForce(e))}},{key:"$end",value:function(){var e=this;this.add(y.mobile?"touchend":"mouseup",function(){e.endDeepPress(),e.setPressed(!1),P(e.block,"end",e.el),e.force=0}),this.add("mouseleave",function(){e.endDeepPress(),e.pressed&&P(e.block,"end",e.el),e.setPressed(!1),e.force=0})}},{key:"startDeepPress",value:function(e){this.deepPressed===!1&&P(this.block,"startDeepPress",this.el,e),this.setDeepPressed(!0)}},{key:"endDeepPress",value:function(){this.deepPressed===!0&&P(this.block,"endDeepPress",this.el),this.setDeepPressed(!1)}},{key:"runForce",value:function(e){this.pressed&&(P(this.block,"change",this.el,this.force,e),this.force>=.5?this.startDeepPress(e):this.endDeepPress(),this.force=this.force+this.increment>1?1:this.force+this.increment,setTimeout(this.runForce.bind(this),10,e))}}]),t}(h),p={preventDefault:!0,only:null,polyfill:!1,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},y={hasRun:!1,forPressure:!1,type:!1,mobile:"ontouchstart"in t,didFail:function(){this.hasRun=!0,this.forPressure=!1},didSucceed:function(e){this.hasRun=!0,this.forPressure=!0,this.type=e}},v=function(e,s){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];if("string"==typeof e||e instanceof String)for(var i=t.querySelectorAll(e),o=0;o