westures-core 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +18 -14
- package/src/Gesture.js +1 -1
- package/src/Input.js +9 -2
- package/src/Point2D.js +12 -0
- package/src/constants.js +9 -0
- package/.travis.yml +0 -6
package/dist/index.js
CHANGED
|
@@ -3,13 +3,13 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcel
|
|
|
3
3
|
},{}],"Qs2Z":[function(require,module,exports) {
|
|
4
4
|
"use strict";function n(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function e(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function t(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}var r=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;n(this,e),this.x=t,this.y=r}return t(e,[{key:"angleTo",value:function(n){return Math.atan2(n.y-this.y,n.x-this.x)}},{key:"averageDistanceTo",value:function(n){return this.totalDistanceTo(n)/n.length}},{key:"clone",value:function(){return new e(this.x,this.y)}},{key:"distanceTo",value:function(n){return Math.hypot(n.x-this.x,n.y-this.y)}},{key:"minus",value:function(n){return new e(this.x-n.x,this.y-n.y)}},{key:"plus",value:function(n){return new e(this.x+n.x,this.y+n.y)}},{key:"totalDistanceTo",value:function(n){var e=this;return n.reduce(function(n,t){return n+e.distanceTo(t)},0)}}],[{key:"centroid",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(0===n.length)return null;var t=e.sum(n);return t.x/=n.length,t.y/=n.length,t}},{key:"sum",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce(function(n,e){return n.x+=e.x,n.y+=e.y,n},new e(0,0))}}]),e}();module.exports=r;
|
|
5
5
|
},{}],"p3SI":[function(require,module,exports) {
|
|
6
|
-
"use strict";var e=["blur","pointercancel","touchcancel","mouseleave"],o=["keydown","keyup"],t=["mousedown","mousemove","mouseup"],u=["pointerdown","pointermove","pointerup"],
|
|
6
|
+
"use strict";var e=["blur","pointercancel","touchcancel","mouseleave"],o=["keydown","keyup"],t=["mousedown","mousemove","mouseup"],u=["pointerdown","pointermove","pointerup"],E=["touchend","touchmove","touchstart"],n=["altKey","ctrlKey","metaKey","shiftKey"],c=["Alt","Control","Meta","Shift"],r="cancel",m="end",S="move",p="start",s=[p,S,m,r],T={blur:r,pointercancel:r,touchcancel:r,mouseup:m,pointerup:m,touchend:m,mousemove:S,pointermove:S,touchmove:S,mousedown:p,pointerdown:p,touchstart:p};module.exports={CANCEL_EVENTS:e,KEYBOARD_EVENTS:o,MOUSE_EVENTS:t,POINTER_EVENTS:u,TOUCH_EVENTS:E,STATE_KEYS:n,STATE_KEY_STRINGS:c,CANCEL:r,END:m,MOVE:S,START:p,PHASE:T,PHASES:s};
|
|
7
7
|
},{}],"zSto":[function(require,module,exports) {
|
|
8
8
|
"use strict";function n(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}var t=require("./Point2D.js"),e=require("./constants.js"),i=e.PHASE;function r(n,t){return n.changedTouches?Array.from(n.changedTouches).find(function(n){return n.identifier===t}):n}var o=function e(o,s){n(this,e);var c=r(o,s),a=c.clientX,u=c.clientY;this.event=o,this.type=i[o.type],this.time=Date.now(),this.point=new t(a,u)};module.exports=o;
|
|
9
9
|
},{"./Point2D.js":"Qs2Z","./constants.js":"p3SI"}],"K0yk":[function(require,module,exports) {
|
|
10
10
|
"use strict";var t=2*Math.PI,e=-Math.PI;function n(n,r){var o=n-r;return o<e?o+=t:o>Math.PI&&(o-=t),o}function r(t){if("function"==typeof t.composedPath)return t.composedPath();for(var e=[],n=t.target;n!==document;n=n.parentNode)e.push(n);return e.push(document),e.push(window),e}function o(t,e){var n=new Set;return t.forEach(function(t){e(t)&&n.add(t)}),n}function u(t,e){return o(t,function(t){return!e.has(t)})}module.exports={angularDifference:n,getPropagationPath:r,setDifference:u,setFilter:o};
|
|
11
11
|
},{}],"W3UA":[function(require,module,exports) {
|
|
12
|
-
"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}var n=require("./PointerData.js"),r=require("./utils.js"),a=r.getPropagationPath,u=function(){function e(i,r){t(this,e);var u=new n(i,r);this.initialElements=new WeakSet(a(i)),this.initial=u,this.current=u,this.previous=u,this.identifier=r}return i(e,[{key:"
|
|
12
|
+
"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}var n=require("./PointerData.js"),r=require("./utils.js"),a=r.getPropagationPath,u=function(){function e(i,r){t(this,e);var u=new n(i,r);this.initialElements=new WeakSet(a(i)),this.initial=u,this.current=u,this.previous=u,this.identifier=r}return i(e,[{key:"phase",get:function(){return this.current.type}},{key:"startTime",get:function(){return this.initial.time}},{key:"totalDistance",value:function(){return this.initial.point.distanceTo(this.current.point)}},{key:"update",value:function(t){this.previous=this.current,this.current=new n(t,this.identifier)}}]),e}();module.exports=u;
|
|
13
13
|
},{"./PointerData.js":"zSto","./utils.js":"K0yk"}],"x00L":[function(require,module,exports) {
|
|
14
14
|
"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function n(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}var i=require("./constants.js"),s=i.CANCEL,u=i.END,r=i.MOVE,a=i.PHASE,o=i.START,c=require("./Input.js"),h=require("./Point2D.js"),p={inputs:Symbol.for("inputs")},l={TouchEvent:function(t){var e=this;Array.from(t.changedTouches).forEach(function(n){e.updateInput(t,n.identifier)})},PointerEvent:function(t){this.updateInput(t,t.pointerId)},MouseEvent:function(t){0===t.button&&this.updateInput(t,t.button)}},f=function(){function e(n){t(this,e),this.element=n,this[p.inputs]=new Map,this.inputs=[],this.active=[],this.activePoints=[],this.centroid={},this.event=null}return n(e,[{key:"clearEndedInputs",value:function(){var t=this;this[p.inputs].forEach(function(e,n){"end"===e.phase&&t[p.inputs].delete(n)})}},{key:"getInputsInPhase",value:function(t){return this.inputs.filter(function(e){return e.phase===t})}},{key:"getInputsNotInPhase",value:function(t){return this.inputs.filter(function(e){return e.phase!==t})}},{key:"hasNoInputs",value:function(){return 0===this[p.inputs].size}},{key:"updateInput",value:function(t,e){switch(a[t.type]){case o:this[p.inputs].set(e,new c(t,e));try{this.element.setPointerCapture(e)}catch(n){}break;case u:try{this.element.releasePointerCapture(e)}catch(n){}case s:case r:this[p.inputs].has(e)&&this[p.inputs].get(e).update(t);break;default:console.warn("Unrecognized event type: ".concat(t.type))}}},{key:"updateAllInputs",value:function(t){l[t.constructor.name].call(this,t),this.updateFields(t)}},{key:"updateFields",value:function(t){this.inputs=Array.from(this[p.inputs].values()),this.active=this.getInputsNotInPhase("end"),this.activePoints=this.active.map(function(t){return t.current.point}),this.centroid=h.centroid(this.activePoints),this.event=t}}]),e}();module.exports=f;
|
|
15
15
|
},{"./constants.js":"p3SI","./Input.js":"W3UA","./Point2D.js":"Qs2Z"}],"e28u":[function(require,module,exports) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["src/Gesture.js","src/Point2D.js","src/constants.js","src/PointerData.js","src/utils.js","src/Input.js","src/State.js","src/Region.js","src/Smoothable.js","index.js"],"names":["g_id","Gesture","type","element","handler","options","TypeError","id","DEFAULTS","state","count","active","length","event","enableKeys","disableKeys","minInputs","maxInputs","some","k","hook","data","recognize","centroid","phase","target","Number","MAX_VALUE","module","exports","Point2D","x","y","point","Math","atan2","points","totalDistanceTo","hypot","reduce","d","p","distanceTo","total","sum","pt","CANCEL_EVENTS","KEYBOARD_EVENTS","MOUSE_EVENTS","POINTER_EVENTS","TOUCH_EVENTS","STATE_KEYS","STATE_KEY_STRINGS","CANCEL","END","MOVE","START","PHASE","blur","pointercancel","touchcancel","mouseup","pointerup","touchend","mousemove","pointermove","touchmove","mousedown","pointerdown","touchstart","require","getEventObject","identifier","changedTouches","Array","from","find","touch","PointerData","clientX","clientY","time","Date","now","PI_2","PI","PI_NVE","angularDifference","a","b","diff","getPropagationPath","composedPath","path","node","document","parentNode","push","window","setFilter","set","predicate","result","Set","forEach","add","setDifference","left","right","has","Input","currentData","initialElements","WeakSet","initial","current","previous","symbols","inputs","Symbol","for","update_fns","TouchEvent","updateInput","PointerEvent","pointerId","MouseEvent","button","State","Map","activePoints","v","delete","filter","i","size","setPointerCapture","e","releasePointerCapture","get","update","console","warn","constructor","name","call","updateFields","values","getInputsNotInPhase","map","Region","gestures","activeGestures","potentialGestures","activate","eventNames","preferPointer","concat","arbitrate","bind","eventName","addEventListener","capture","once","passive","cancel","handleKeyboardEvent","preventDefault","input","gesture","evaluateHook","resetActiveGestures","indexOf","key","oldActiveGestures","setActiveGestures","isEnabled","isInitial","setPotentialGestures","hasNoInputs","updateAllInputs","updateActiveGestures","clearEndedInputs","pruneActiveGestures","style","touchAction","getGesturesByElement","g","removeGesture","cascade","smooth","smoothingIsApplicable","isRequested","matchMedia","matches","Smoothable","final_options","next","applySmoothing","identity","average","constants","utils"],"mappings":";AAAA,aA8LA,SAAA,EAAA,EAAA,GAAA,IAAA,E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cAAA,EAAA,KAAA,MAAA,EAAA,GAAA,OAAA,EAAA,SAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,UAAA,OAAA,IAAA,CAAA,IAAA,EAAA,MAAA,UAAA,GAAA,UAAA,GAAA,GAAA,EAAA,EAAA,EAAA,OAAA,IAAA,GAAA,QAAA,SAAA,GAAA,EAAA,EAAA,EAAA,EAAA,MAAA,OAAA,0BAAA,OAAA,iBAAA,EAAA,OAAA,0BAAA,IAAA,EAAA,OAAA,IAAA,QAAA,SAAA,GAAA,OAAA,eAAA,EAAA,EAAA,OAAA,yBAAA,EAAA,MAAA,OAAA,EAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,KAAA,EAAA,OAAA,eAAA,EAAA,EAAA,CAAA,MAAA,EAAA,YAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,GAAA,EAAA,EAVA,IAAMlM,EAAUqE,QAAQ,oBAClBwC,EAAQxC,QAAQ,kBAChBxC,EAAUwC,QAAQ,oBAClBQ,EAAcR,QAAQ,wBACtBgF,EAAShF,QAAQ,mBACjB6H,EAAa7H,QAAQ,uBACrB0D,EAAQ1D,QAAQ,kBAChBmI,EAAYnI,QAAQ,sBACpBoI,EAAQpI,QAAQ,kBAEtB1C,OAAOC,QAAP,EAAA,EAAA,CACE5B,QAAAA,EACA6G,MAAAA,EACAhF,QAAAA,EACAgD,YAAAA,EACAwE,OAAAA,EACA6C,WAAAA,EACAnE,MAAAA,GACGyE,GACAC","file":"index.js","sourceRoot":"..","sourcesContent":["'use strict';\n\nlet g_id = 0;\n\n/**\n * The Gesture class that all gestures inherit from. A custom gesture class will\n * need to override some or all of the four phase \"hooks\": start, move, end, and\n * cancel.\n *\n * @memberof westures-core\n *\n * @param {string} type - The name of the gesture.\n * @param {Element} element - The element to which to associate the gesture.\n * @param {Function} handler - The function handler to execute when a gesture\n * is recognized on the associated element.\n * @param {object} [options] - Generic gesture options\n * @param {westures-core.STATE_KEYS[]} [options.enableKeys=[]] - List of keys\n * which will enable the gesture. The gesture will not be recognized unless one\n * of these keys is pressed while the interaction occurs. If not specified or an\n * empty list, the gesture is treated as though the enable key is always down.\n * @param {westures-core.STATE_KEYS[]} [options.disableKeys=[]] - List of keys\n * which will disable the gesture. The gesture will not be recognized if one of\n * these keys is pressed while the interaction occurs. If not specified or an\n * empty list, the gesture is treated as though the disable key is never down.\n * @param {number} [options.minInputs=1] - The minimum number of pointers that\n * must be active for the gesture to be recognized. Uses >=.\n * @param {number} [options.maxInputs=Number.MAX_VALUE] - The maximum number of\n * pointers that may be active for the gesture to be recognized. Uses <=.\n */\nclass Gesture {\n constructor(type, element, handler, options = {}) {\n if (typeof type !== 'string') {\n throw new TypeError('Gestures require a string type / name');\n }\n\n /**\n * The name of the gesture. (e.g. 'pan' or 'tap' or 'pinch').\n *\n * @type {string}\n */\n this.type = type;\n\n /**\n * The unique identifier for each gesture. This allows for distinctions\n * across instances of Gestures that are created on the fly (e.g.\n * gesture-tap-1, gesture-tap-2).\n *\n * @type {string}\n */\n this.id = `gesture-${this.type}-${g_id++}`;\n\n /**\n * The element to which to associate the gesture.\n *\n * @type {Element}\n */\n this.element = element;\n\n /**\n * The function handler to execute when the gesture is recognized on the\n * associated element.\n *\n * @type {Function}\n */\n this.handler = handler;\n\n /**\n * The options settings.\n *\n * @type {object}\n */\n this.options = { ...Gesture.DEFAULTS, ...options };\n }\n\n /**\n * Determines whether this gesture is enabled.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {boolean} true if enabled, false otherwise.\n */\n isEnabled(state) {\n const count = state.active.length;\n const event = state.event;\n const { enableKeys, disableKeys, minInputs, maxInputs } = this.options;\n\n return (minInputs <= count) && (maxInputs >= count) &&\n (enableKeys.length === 0 || enableKeys.some(k => event[k])) &&\n !disableKeys.some(k => event[k]);\n }\n\n /**\n * Event hook for the start phase of a gesture.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n start() {\n return null;\n }\n\n /**\n * Event hook for the move phase of a gesture.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n move() {\n return null;\n }\n\n /**\n * Event hook for the end phase of a gesture.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n end() {\n return null;\n }\n\n /**\n * Event hook for when an input is cancelled.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n cancel() {\n return null;\n }\n\n /**\n * Evalutes the given gesture hook, and dispatches any data that is produced\n * by calling [recognize]{@link westures-core.Gesture#recognize}.\n *\n * @param {string} hook - Must be one of 'start', 'move', 'end', or 'cancel'.\n * @param {westures-core.State} state - The current State instance.\n */\n evaluateHook(hook, state) {\n const data = this[hook](state);\n if (data) {\n this.recognize(hook, state, data);\n }\n }\n\n /**\n * Recognize a Gesture by calling the handler. Standardizes the way the\n * handler is called so that classes extending Gesture can circumvent the\n * evaluateHook approach but still provide results that have a common format.\n *\n * Note that the properties in the \"data\" object will receive priority when\n * constructing the results. This can be used to override standard results\n * such as the phase or the centroid.\n *\n * @param {string} hook - Must be one of 'start', 'move', 'end', or 'cancel'.\n * @param {westures-core.State} state - current input state.\n * @param {Object} data - Results data specific to the recognized gesture.\n */\n recognize(hook, state, data) {\n this.handler({\n centroid: state.centroid,\n event: state.event,\n phase: hook,\n type: this.type,\n target: this.element,\n ...data,\n });\n }\n}\n\nGesture.DEFAULTS = {\n enableKeys: [],\n disableKeys: [],\n minInputs: 1,\n maxInputs: Number.MAX_VALUE,\n};\n\nmodule.exports = Gesture;\n\n","'use strict';\n\n/**\n * The Point2D class stores and operates on 2-dimensional points, represented as\n * x and y coordinates.\n *\n * @memberof westures-core\n *\n * @param {number} [ x=0 ] - The x coordinate of the point.\n * @param {number} [ y=0 ] - The y coordinate of the point.\n */\nclass Point2D {\n constructor(x = 0, y = 0) {\n /**\n * The x coordinate of the point.\n *\n * @type {number}\n */\n this.x = x;\n\n /**\n * The y coordinate of the point.\n *\n * @type {number}\n */\n this.y = y;\n }\n\n /**\n * Calculates the angle between this point and the given point.\n *\n * @param {!westures-core.Point2D} point - Projected point for calculating the\n * angle.\n *\n * @return {number} Radians along the unit circle where the projected\n * point lies.\n */\n angleTo(point) {\n return Math.atan2(point.y - this.y, point.x - this.x);\n }\n\n /**\n * Determine the average distance from this point to the provided array of\n * points.\n *\n * @param {!westures-core.Point2D[]} points - the Point2D objects to calculate\n * the average distance to.\n *\n * @return {number} The average distance from this point to the provided\n * points.\n */\n averageDistanceTo(points) {\n return this.totalDistanceTo(points) / points.length;\n }\n\n /**\n * Clone this point.\n *\n * @return {westures-core.Point2D} A new Point2D, identical to this point.\n */\n clone() {\n return new Point2D(this.x, this.y);\n }\n\n /**\n * Calculates the distance between two points.\n *\n * @param {!westures-core.Point2D} point - Point to which the distance is\n * calculated.\n *\n * @return {number} The distance between the two points, a.k.a. the\n * hypoteneuse.\n */\n distanceTo(point) {\n return Math.hypot(point.x - this.x, point.y - this.y);\n }\n\n /**\n * Subtract the given point from this point.\n *\n * @param {!westures-core.Point2D} point - Point to subtract from this point.\n *\n * @return {westures-core.Point2D} A new Point2D, which is the result of (this\n * - point).\n */\n minus(point) {\n return new Point2D(\n this.x - point.x,\n this.y - point.y,\n );\n }\n\n /**\n * Return the summation of this point to the given point.\n *\n * @param {!westures-core.Point2D} point - Point to add to this point.\n *\n * @return {westures-core.Point2D} A new Point2D, which is the addition of the\n * two points.\n */\n plus(point) {\n return new Point2D(\n this.x + point.x,\n this.y + point.y,\n );\n }\n\n /**\n * Calculates the total distance from this point to an array of points.\n *\n * @param {!westures-core.Point2D[]} points - The array of Point2D objects to\n * calculate the total distance to.\n *\n * @return {number} The total distance from this point to the provided points.\n */\n totalDistanceTo(points) {\n return points.reduce((d, p) => d + this.distanceTo(p), 0);\n }\n\n /**\n * Calculates the centroid of a list of points.\n *\n * @param {westures-core.Point2D[]} points - The array of Point2D objects for\n * which to calculate the centroid.\n *\n * @return {westures-core.Point2D} The centroid of the provided points.\n */\n static centroid(points = []) {\n if (points.length === 0) return null;\n\n const total = Point2D.sum(points);\n total.x /= points.length;\n total.y /= points.length;\n return total;\n }\n\n /**\n * Calculates the sum of the given points.\n *\n * @param {westures-core.Point2D[]} points - The Point2D objects to sum up.\n *\n * @return {westures-core.Point2D} A new Point2D representing the sum of the\n * given points.\n */\n static sum(points = []) {\n return points.reduce(\n (total, pt) => {\n total.x += pt.x;\n total.y += pt.y;\n return total;\n },\n new Point2D(0, 0),\n );\n }\n}\n\nmodule.exports = Point2D;\n\n","'use strict';\n\n/**\n * List of events that trigger the cancel phase.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst CANCEL_EVENTS = [\n 'blur',\n 'pointercancel',\n 'touchcancel',\n 'mouseleave',\n];\n\n/**\n * List of keyboard events that trigger a restart.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst KEYBOARD_EVENTS = [\n 'keydown',\n 'keyup',\n];\n\n/**\n * List of mouse events to listen to.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst MOUSE_EVENTS = [\n 'mousedown',\n 'mousemove',\n 'mouseup',\n];\n\n/**\n * List of pointer events to listen to.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst POINTER_EVENTS = [\n 'pointerdown',\n 'pointermove',\n 'pointerup',\n];\n\n/**\n * List of touch events to listen to.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst TOUCH_EVENTS = [\n 'touchend',\n 'touchmove',\n 'touchstart',\n];\n\n/**\n * List of potentially state-modifying keys.\n * Entries are: ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst STATE_KEYS = [\n 'altKey',\n 'ctrlKey',\n 'metaKey',\n 'shiftKey',\n];\n\n/**\n * List of the 'key' values on KeyboardEvent objects of the potentially\n * state-modifying keys.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst STATE_KEY_STRINGS = [\n 'Alt',\n 'Control',\n 'Meta',\n 'Shift',\n];\n\n/**\n * The cancel phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst CANCEL = 'cancel';\n\n/**\n * The end phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst END = 'end';\n\n/**\n * The move phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst MOVE = 'move';\n\n/**\n * The start phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst START = 'start';\n\n/**\n * Object that normalizes the names of window events to be either of type start,\n * move, end, or cancel.\n *\n * @memberof westures-core\n * @type {object}\n */\nconst PHASE = {\n blur: CANCEL,\n pointercancel: CANCEL,\n touchcancel: CANCEL,\n\n mouseup: END,\n pointerup: END,\n touchend: END,\n\n mousemove: MOVE,\n pointermove: MOVE,\n touchmove: MOVE,\n\n mousedown: START,\n pointerdown: START,\n touchstart: START,\n};\n\nmodule.exports = {\n CANCEL_EVENTS,\n KEYBOARD_EVENTS,\n MOUSE_EVENTS,\n POINTER_EVENTS,\n TOUCH_EVENTS,\n\n STATE_KEYS,\n STATE_KEY_STRINGS,\n\n CANCEL,\n END,\n MOVE,\n START,\n\n PHASE,\n};\n\n","'use strict';\n\nconst Point2D = require('./Point2D.js');\nconst { PHASE } = require('./constants.js');\n\n/**\n * @private\n * @inner\n * @memberof westures-core.PointerData\n *\n * @return {Event} The Event object which corresponds to the given identifier.\n * Contains clientX, clientY values.\n */\nfunction getEventObject(event, identifier) {\n if (event.changedTouches) {\n return Array.from(event.changedTouches).find(touch => {\n return touch.identifier === identifier;\n });\n }\n return event;\n}\n\n/**\n * Low-level storage of pointer data based on incoming data from an interaction\n * event.\n *\n * @memberof westures-core\n *\n * @param {Event} event - The event object being wrapped.\n * @param {number} identifier - The index of touch if applicable\n */\nclass PointerData {\n constructor(event, identifier) {\n const { clientX, clientY } = getEventObject(event, identifier);\n\n /**\n * The original event object.\n *\n * @type {Event}\n */\n this.event = event;\n\n /**\n * The type or 'phase' of this batch of pointer data. 'start' or 'move' or\n * 'end' or 'cancel'\n *\n * @type {string}\n */\n this.type = PHASE[event.type];\n\n /**\n * The timestamp of the event in milliseconds elapsed since January 1, 1970,\n * 00:00:00 UTC.\n *\n * @type {number}\n */\n this.time = Date.now();\n\n /**\n * The (x,y) coordinate of the event, wrapped in a Point2D.\n *\n * @type {westures-core.Point2D}\n */\n this.point = new Point2D(clientX, clientY);\n }\n}\n\nmodule.exports = PointerData;\n\n","'use strict';\n\nconst PI_2 = 2 * Math.PI;\nconst PI_NVE = -Math.PI;\n\n/**\n * Helper function to regulate angular differences, so they don't jump from 0 to\n * 2 * PI or vice versa.\n *\n * @memberof westures-core\n *\n * @param {number} a - Angle in radians.\n * @param {number} b - Angle in radians.\n\n * @return {number} c, given by: c = a - b such that |c| < PI\n */\nfunction angularDifference(a, b) {\n let diff = a - b;\n if (diff < PI_NVE) {\n diff += PI_2;\n } else if (diff > Math.PI) {\n diff -= PI_2;\n }\n return diff;\n}\n\n/**\n * In case event.composedPath() is not available.\n *\n * @memberof westures-core\n *\n * @param {Event} event\n *\n * @return {Element[]} The elements along the composed path of the event.\n */\nfunction getPropagationPath(event) {\n if (typeof event.composedPath === 'function') {\n return event.composedPath();\n }\n\n const path = [];\n for (let node = event.target; node !== document; node = node.parentNode) {\n path.push(node);\n }\n path.push(document);\n path.push(window);\n\n return path;\n}\n\n/**\n * Performs a set filter operation.\n *\n * @memberof westures-core\n *\n * @param {Set} set - The set to filter.\n * @param {Function} predicate - Function to test elements of 'set'. Receives\n * one argument: the current set element.\n *\n * @return {Set} Set consisting of elements in 'set' for which 'predicate' is\n * true.\n */\nfunction setFilter(set, predicate) {\n const result = new Set();\n set.forEach(element => {\n if (predicate(element)) {\n result.add(element);\n }\n });\n return result;\n}\n\n/**\n * Performs a set difference operation.\n *\n * @memberof westures-core\n *\n * @param {Set} left - Base set.\n * @param {Set} right - Set of elements to remove from 'left'.\n *\n * @return {Set} Set consisting of elements in 'left' that are not in\n * 'right'.\n */\nfunction setDifference(left, right) {\n return setFilter(left, element => !right.has(element));\n}\n\nmodule.exports = {\n angularDifference,\n getPropagationPath,\n setDifference,\n setFilter,\n};\n\n","'use strict';\n\nconst PointerData = require('./PointerData.js');\nconst { getPropagationPath } = require('./utils.js');\n\n/**\n * Tracks a single input and contains information about the current, previous,\n * and initial events. Contains the progress of each Input and its associated\n * gestures.\n *\n * @memberof westures-core\n *\n * @param {(PointerEvent | MouseEvent | TouchEvent)} event - The input event\n * which will initialize this Input object.\n * @param {number} identifier - The identifier for this input, so that it can\n * be located in subsequent Event objects.\n */\nclass Input {\n constructor(event, identifier) {\n const currentData = new PointerData(event, identifier);\n\n /**\n * The set of elements along the original event's propagation path at the\n * time it was dispatched.\n *\n * @type {WeakSet.<Element>}\n */\n this.initialElements = new WeakSet(getPropagationPath(event));\n\n /**\n * Holds the initial data from the mousedown / touchstart / pointerdown that\n * began this input.\n *\n * @type {westures-core.PointerData}\n */\n this.initial = currentData;\n\n /**\n * Holds the most current pointer data for this Input.\n *\n * @type {westures-core.PointerData}\n */\n this.current = currentData;\n\n /**\n * Holds the previous pointer data for this Input.\n *\n * @type {westures-core.PointerData}\n */\n this.previous = currentData;\n\n /**\n * The identifier for the pointer / touch / mouse button associated with\n * this input.\n *\n * @type {number}\n */\n this.identifier = identifier;\n }\n\n /**\n * The phase of the input: 'start' or 'move' or 'end' or 'cancel'\n *\n * @type {string}\n */\n get phase() { return this.current.type; }\n\n /**\n * The timestamp of the initiating event for this input.\n *\n * @type {number}\n */\n get startTime() { return this.initial.time; }\n\n /**\n * @return {number} The distance between the initiating event for this input\n * and its current event.\n */\n totalDistance() {\n return this.initial.point.distanceTo(this.current.point);\n }\n\n /**\n * Saves the given raw event in PointerData form as the current data for this\n * input, pushing the old current data into the previous slot, and tossing\n * out the old previous data.\n *\n * @param {Event} event - The event object to wrap with a PointerData.\n */\n update(event) {\n this.previous = this.current;\n this.current = new PointerData(event, this.identifier);\n }\n}\n\nmodule.exports = Input;\n\n","'use strict';\n\nconst {\n CANCEL,\n END,\n MOVE,\n PHASE,\n START,\n} = require('./constants.js');\nconst Input = require('./Input.js');\nconst Point2D = require('./Point2D.js');\n\nconst symbols = {\n inputs: Symbol.for('inputs'),\n};\n\n/**\n * Set of helper functions for updating inputs based on type of input.\n * Must be called with a bound 'this', via bind(), or call(), or apply().\n *\n * @private\n * @inner\n * @memberof westure-core.State\n */\nconst update_fns = {\n TouchEvent: function TouchEvent(event) {\n Array.from(event.changedTouches).forEach(touch => {\n this.updateInput(event, touch.identifier);\n });\n },\n\n PointerEvent: function PointerEvent(event) {\n this.updateInput(event, event.pointerId);\n },\n\n MouseEvent: function MouseEvent(event) {\n if (event.button === 0) {\n this.updateInput(event, event.button);\n }\n },\n};\n\n/**\n * Keeps track of currently active and ending input points on the interactive\n * surface.\n *\n * @memberof westures-core\n *\n * @param {Element} element - The element underpinning the associated Region.\n */\nclass State {\n constructor(element) {\n /**\n * Keep a reference to the element for the associated region.\n *\n * @type {Element}\n */\n this.element = element;\n\n /**\n * Keeps track of the current Input objects.\n *\n * @alias [@@inputs]\n * @type {Map.<westures-core.Input>}\n * @memberof westure-core.State\n */\n this[symbols.inputs] = new Map();\n\n /**\n * All currently valid inputs, including those that have ended.\n *\n * @type {westures-core.Input[]}\n */\n this.inputs = [];\n\n /**\n * The array of currently active inputs, sourced from the current Input\n * objects. \"Active\" is defined as not being in the 'end' phase.\n *\n * @type {westures-core.Input[]}\n */\n this.active = [];\n\n /**\n * The array of latest point data for the currently active inputs, sourced\n * from this.active.\n *\n * @type {westures-core.Point2D[]}\n */\n this.activePoints = [];\n\n /**\n * The centroid of the currently active points.\n *\n * @type {westures-core.Point2D}\n */\n this.centroid = {};\n\n /**\n * The latest event that the state processed.\n *\n * @type {Event}\n */\n this.event = null;\n }\n\n /**\n * Deletes all inputs that are in the 'end' phase.\n */\n clearEndedInputs() {\n this[symbols.inputs].forEach((v, k) => {\n if (v.phase === 'end') this[symbols.inputs].delete(k);\n });\n }\n\n /**\n * @param {string} phase - One of 'start', 'move', 'end', or 'cancel'.\n *\n * @return {westures-core.Input[]} Inputs in the given phase.\n */\n getInputsInPhase(phase) {\n return this.inputs.filter(i => i.phase === phase);\n }\n\n /**\n * @param {string} phase - One of 'start', 'move', 'end', or 'cancel'.\n *\n * @return {westures-core.Input[]} Inputs <b>not</b> in the given phase.\n */\n getInputsNotInPhase(phase) {\n return this.inputs.filter(i => i.phase !== phase);\n }\n\n /**\n * @return {boolean} True if there are no active inputs. False otherwise.\n */\n hasNoInputs() {\n return this[symbols.inputs].size === 0;\n }\n\n /**\n * Update the input with the given identifier using the given event.\n *\n * @private\n *\n * @param {Event} event - The event being captured.\n * @param {number} identifier - The identifier of the input to update.\n */\n updateInput(event, identifier) {\n switch (PHASE[event.type]) {\n case START:\n this[symbols.inputs].set(\n identifier,\n new Input(event, identifier),\n );\n try {\n this.element.setPointerCapture(identifier);\n } catch (e) {\n // NOP: Optional operation failed.\n }\n break;\n\n // All of 'end', 'move', and 'cancel' perform updates, hence the\n // following fall-throughs\n case END:\n try {\n this.element.releasePointerCapture(identifier);\n } catch (e) {\n // NOP: Optional operation failed.\n }\n case CANCEL:\n case MOVE:\n if (this[symbols.inputs].has(identifier)) {\n this[symbols.inputs].get(identifier).update(event);\n }\n break;\n\n default:\n console.warn(`Unrecognized event type: ${event.type}`);\n }\n }\n\n /**\n * Updates the inputs with new information based upon a new event being fired.\n *\n * @private\n * @param {Event} event - The event being captured.\n */\n updateAllInputs(event) {\n update_fns[event.constructor.name].call(this, event);\n this.updateFields(event);\n }\n\n /**\n * Updates the convenience fields.\n *\n * @private\n * @param {Event} event - Event with which to update the convenience fields.\n */\n updateFields(event) {\n this.inputs = Array.from(this[symbols.inputs].values());\n this.active = this.getInputsNotInPhase('end');\n this.activePoints = this.active.map(i => i.current.point);\n this.centroid = Point2D.centroid(this.activePoints);\n this.event = event;\n }\n}\n\nmodule.exports = State;\n\n","'use strict';\n\nconst State = require('./State.js');\nconst {\n CANCEL_EVENTS,\n KEYBOARD_EVENTS,\n MOUSE_EVENTS,\n POINTER_EVENTS,\n TOUCH_EVENTS,\n\n STATE_KEY_STRINGS,\n\n PHASE,\n\n CANCEL,\n END,\n START,\n} = require('./constants.js');\nconst {\n setDifference,\n setFilter,\n} = require('./utils.js');\n\n/**\n * Allows the user to specify the control region which will listen for user\n * input events.\n *\n * @memberof westures-core\n *\n * @param {Element} element=window - The element which should listen to input\n * events.\n * @param {object} [options]\n * @param {boolean} [options.capture=false] - Whether the region uses the\n * capture phase of input events. If false, uses the bubbling phase.\n * @param {boolean} [options.preferPointer=true] - If false, the region listens\n * to mouse/touch events instead of pointer events.\n * @param {boolean} [options.preventDefault=true] - Whether the default\n * browser functionality should be disabled. This option should most likely be\n * ignored. Here there by dragons if set to false.\n * @param {string} [options.touchAction='none'] - Value to set the CSS\n * 'touch-action' property to on elements added to the region.\n */\nclass Region {\n constructor(element = window, options = {}) {\n options = { ...Region.DEFAULTS, ...options };\n\n /**\n * The list of relations between elements, their gestures, and the handlers.\n *\n * @type {Set.<westures-core.Gesture>}\n */\n this.gestures = new Set();\n\n /**\n * The list of active gestures for the current input session.\n *\n * @type {Set.<westures-core.Gesture>}\n */\n this.activeGestures = new Set();\n\n /**\n * The base list of potentially active gestures for the current input\n * session.\n *\n * @type {Set.<westures-core.Gesture>}\n */\n this.potentialGestures = new Set();\n\n /**\n * The element being bound to.\n *\n * @type {Element}\n */\n this.element = element;\n\n /**\n * The user-supplied options for the Region.\n *\n * @type {object}\n */\n this.options = options;\n\n /**\n * The internal state object for a Region. Keeps track of inputs.\n *\n * @type {westures-core.State}\n */\n this.state = new State(this.element);\n\n // Begin operating immediately.\n this.activate();\n }\n\n /**\n * Activates the region by adding event listeners for all appropriate input\n * events to the region's element.\n *\n * @private\n */\n activate() {\n /*\n * Listening to both mouse and touch comes with the difficulty that\n * preventDefault() must be called to prevent both events from iterating\n * through the system. However I have left it as an option to the end user,\n * which defaults to calling preventDefault(), in case there's a use-case I\n * haven't considered or am not aware of.\n *\n * It also may be a good idea to keep regions small in large pages.\n *\n * See:\n * https://www.html5rocks.com/en/mobile/touchandmouse/\n * https://developer.mozilla.org/en-US/docs/Web/API/Touch_events\n * https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events\n */\n let eventNames = [];\n if (this.options.preferPointer && window.PointerEvent) {\n eventNames = POINTER_EVENTS;\n } else {\n eventNames = MOUSE_EVENTS.concat(TOUCH_EVENTS);\n }\n\n // Bind detected browser events to the region element.\n const arbitrate = this.arbitrate.bind(this);\n eventNames.forEach(eventName => {\n this.element.addEventListener(eventName, arbitrate, {\n capture: this.options.capture,\n once: false,\n passive: false,\n });\n });\n\n const cancel = this.cancel.bind(this);\n CANCEL_EVENTS.forEach(eventName => {\n window.addEventListener(eventName, cancel);\n });\n\n const handleKeyboardEvent = this.handleKeyboardEvent.bind(this);\n KEYBOARD_EVENTS.forEach(eventName => {\n window.addEventListener(eventName, handleKeyboardEvent);\n });\n }\n\n /**\n * Handles a cancel event. Resets the state and the active / potential gesture\n * lists.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n */\n cancel(event) {\n if (this.options.preventDefault) event.preventDefault();\n this.state.inputs.forEach(input => {\n input.update(event);\n });\n this.activeGestures.forEach(gesture => {\n gesture.evaluateHook(CANCEL, this.state);\n });\n this.state = new State(this.element);\n this.resetActiveGestures();\n }\n\n /**\n * Handles a keyboard event, triggering a restart of any gestures that need\n * it.\n *\n * @private\n * @param {KeyboardEvent} event - The keyboard event.\n */\n handleKeyboardEvent(event) {\n if (STATE_KEY_STRINGS.indexOf(event.key) >= 0) {\n this.state.event = event;\n const oldActiveGestures = this.activeGestures;\n this.setActiveGestures();\n\n setDifference(oldActiveGestures, this.activeGestures).forEach(gesture => {\n gesture.evaluateHook(END, this.state);\n });\n setDifference(this.activeGestures, oldActiveGestures).forEach(gesture => {\n gesture.evaluateHook(START, this.state);\n });\n }\n }\n\n /**\n * Resets the active gestures.\n *\n * @private\n */\n resetActiveGestures() {\n this.potentialGestures = new Set();\n this.activeGestures = new Set();\n }\n\n /**\n * Selects active gestures from the list of potentially active gestures.\n *\n * @private\n */\n setActiveGestures() {\n this.activeGestures = setFilter(this.potentialGestures, gesture => {\n return gesture.isEnabled(this.state);\n });\n }\n\n /**\n * Selects the potentially active gestures.\n *\n * @private\n */\n setPotentialGestures() {\n const input = this.state.inputs[0];\n this.potentialGestures = setFilter(this.gestures, gesture => {\n return input.initialElements.has(gesture.element);\n });\n }\n\n /**\n * Selects the gestures that are active for the current input sequence.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n * @param {boolean} isInitial - Whether this is an initial contact.\n */\n updateActiveGestures(event, isInitial) {\n if (PHASE[event.type] === START) {\n if (isInitial) {\n this.setPotentialGestures();\n }\n this.setActiveGestures();\n }\n }\n\n /**\n * Evaluates whether the current input session has completed.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n */\n pruneActiveGestures(event) {\n if (PHASE[event.type] === END) {\n if (this.state.hasNoInputs()) {\n this.resetActiveGestures();\n } else {\n this.setActiveGestures();\n }\n }\n }\n\n /**\n * All input events flow through this function. It makes sure that the input\n * state is maintained, determines which gestures to analyze based on the\n * initial position of the inputs, calls the relevant gesture hooks, and\n * dispatches gesture data.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n */\n arbitrate(event) {\n const isInitial = this.state.hasNoInputs();\n this.state.updateAllInputs(event);\n this.updateActiveGestures(event, isInitial);\n\n if (this.activeGestures.size > 0) {\n if (this.options.preventDefault) event.preventDefault();\n\n this.activeGestures.forEach(gesture => {\n gesture.evaluateHook(PHASE[event.type], this.state);\n });\n }\n\n this.state.clearEndedInputs();\n this.pruneActiveGestures(event);\n }\n\n /**\n * Adds the given gesture to the region.\n *\n * @param {westures-core.Gesture} gesture - Instantiated gesture to add.\n */\n addGesture(gesture) {\n gesture.element.style.touchAction = this.options.touchAction;\n this.gestures.add(gesture);\n }\n\n /**\n * Removes the given gesture from the region.\n *\n * @param {westures-core.Gesture} gesture - Instantiated gesture to add.\n */\n removeGesture(gesture) {\n this.gestures.delete(gesture);\n this.potentialGestures.delete(gesture);\n this.activeGestures.delete(gesture);\n }\n\n /**\n * Retrieves Gestures by their associated element.\n *\n * @param {Element} element - The element for which to find gestures.\n *\n * @return {westures-core.Gesture[]} Gestures to which the element is bound.\n */\n getGesturesByElement(element) {\n return setFilter(this.gestures, gesture => gesture.element === element);\n }\n\n /**\n * Remove all gestures bound to the given element.\n *\n * @param {Element} element - The element to unbind.\n */\n removeGesturesByElement(element) {\n this.getGesturesByElement(element).forEach(g => this.removeGesture(g));\n }\n}\n\nRegion.DEFAULTS = {\n capture: false,\n preferPointer: true,\n preventDefault: true,\n touchAction: 'none',\n};\n\nmodule.exports = Region;\n","'use strict';\n\nconst cascade = Symbol('cascade');\nconst smooth = Symbol('smooth');\n\n/**\n * Determines whether to apply smoothing. Smoothing is on by default but turned\n * off if either:<br>\n * 1. The user explicitly requests that it be turned off.<br>\n * 2. The active pointer is not \"coarse\".<br>\n *\n * @see {@link\n * https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia}\n *\n * @inner\n * @memberof westures-core.Smoothable\n *\n * @param {boolean} isRequested - Whether smoothing was requested by the user.\n *\n * @returns {boolean} Whether to apply smoothing.\n */\nfunction smoothingIsApplicable(isRequested) {\n if (isRequested) {\n try {\n return window.matchMedia('(pointer: coarse)').matches;\n } catch (e) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * A Smoothable datatype is one that is capable of smoothing out a series of\n * values as they come in, one at a time, providing a more consistent series. It\n * does this by creating some inertia in the values using a cascading average.\n * (For those who are interested in such things, this effectively means that it\n * provides a practical application of Zeno's Dichotomy).\n *\n * @example\n * const x = new Smoothable({ identity: 1 });\n * const a = x.next(1); // 1.0\n * const b = x.next(1.2); // 1.1\n * const c = x.next(0.9); // 1.0\n * const d = x.next(0.6); // 0.8\n * const e = x.next(1.2); // 1.0\n * const f = x.next(1.6); // 1.3\n * x.restart();\n * const g = x.next(0); // 0.5\n *\n * @memberof westures-core\n *\n * @param {Object} [options]\n * @param {boolean} [options.applySmoothing=true] Whether to apply smoothing to\n * the data.\n * @param {*} [options.identity=0] The identity value of this smoothable data.\n */\nclass Smoothable {\n constructor(options = {}) {\n const final_options = { ...Smoothable.DEFAULTS, ...options };\n\n /**\n * The function through which smoothed emits are passed.\n *\n * @method\n * @param {*} data - The data to emit.\n *\n * @return {*} The smoothed out data.\n */\n this.next = null;\n if (smoothingIsApplicable(final_options.applySmoothing)) {\n this.next = this[smooth].bind(this);\n } else {\n this.next = data => data;\n }\n\n /**\n * The \"identity\" value of the data that will be smoothed.\n *\n * @type {*}\n * @default 0\n */\n this.identity = final_options.identity;\n\n /**\n * The cascading average of outgoing values.\n *\n * @memberof westures-core.Smoothable\n * @alias [@@cascade]\n * @type {object}\n */\n this[cascade] = this.identity;\n }\n\n /**\n * Restart the Smoothable gesture.\n */\n restart() {\n this[cascade] = this.identity;\n }\n\n /**\n * Smooth out the outgoing data.\n *\n * @memberof westures-core.Smoothable\n * @alias [@@smooth]\n * @param {object} data - The next batch of data to emit.\n *\n * @return {?object}\n */\n [smooth](data) {\n const average = this.average(this[cascade], data);\n this[cascade] = average;\n return average;\n }\n\n /**\n * Average out two values, as part of the smoothing algorithm. Override this\n * method if the data being smoothed is not a Number.\n *\n * @param {number} a\n * @param {number} b\n *\n * @return {number} The average of 'a' and 'b'\n */\n average(a, b) {\n return (a + b) / 2;\n }\n}\n\nSmoothable.DEFAULTS = {\n applySmoothing: true,\n identity: 0,\n};\n\nmodule.exports = Smoothable;\n\n","/**\n * The global API interface for westures-core. Exposes all classes, constants,\n * and routines used by the package. Use responsibly.\n *\n * @namespace westures-core\n */\n\n'use strict';\n\nconst Gesture = require('./src/Gesture.js');\nconst Input = require('./src/Input.js');\nconst Point2D = require('./src/Point2D.js');\nconst PointerData = require('./src/PointerData.js');\nconst Region = require('./src/Region.js');\nconst Smoothable = require('./src/Smoothable.js');\nconst State = require('./src/State.js');\nconst constants = require('./src/constants.js');\nconst utils = require('./src/utils.js');\n\nmodule.exports = {\n Gesture,\n Input,\n Point2D,\n PointerData,\n Region,\n Smoothable,\n State,\n ...constants,\n ...utils,\n};\n\n"]}
|
|
1
|
+
{"version":3,"sources":["src/Gesture.js","src/Point2D.js","src/constants.js","src/PointerData.js","src/utils.js","src/Input.js","src/State.js","src/Region.js","src/Smoothable.js","index.js"],"names":["g_id","Gesture","type","element","handler","options","TypeError","id","DEFAULTS","state","count","active","length","event","enableKeys","disableKeys","minInputs","maxInputs","some","k","hook","data","recognize","centroid","phase","target","Number","MAX_VALUE","module","exports","Point2D","x","y","point","Math","atan2","points","totalDistanceTo","hypot","reduce","d","p","distanceTo","total","sum","pt","CANCEL_EVENTS","KEYBOARD_EVENTS","MOUSE_EVENTS","POINTER_EVENTS","TOUCH_EVENTS","STATE_KEYS","STATE_KEY_STRINGS","CANCEL","END","MOVE","START","PHASES","PHASE","blur","pointercancel","touchcancel","mouseup","pointerup","touchend","mousemove","pointermove","touchmove","mousedown","pointerdown","touchstart","require","getEventObject","identifier","changedTouches","Array","from","find","touch","PointerData","clientX","clientY","time","Date","now","PI_2","PI","PI_NVE","angularDifference","a","b","diff","getPropagationPath","composedPath","path","node","document","parentNode","push","window","setFilter","set","predicate","result","Set","forEach","add","setDifference","left","right","has","Input","currentData","initialElements","WeakSet","initial","current","previous","symbols","inputs","Symbol","for","update_fns","TouchEvent","updateInput","PointerEvent","pointerId","MouseEvent","button","State","Map","activePoints","v","delete","filter","i","size","setPointerCapture","e","releasePointerCapture","get","update","console","warn","constructor","name","call","updateFields","values","getInputsNotInPhase","map","Region","gestures","activeGestures","potentialGestures","activate","eventNames","preferPointer","concat","arbitrate","bind","eventName","addEventListener","capture","once","passive","cancel","handleKeyboardEvent","preventDefault","input","gesture","evaluateHook","resetActiveGestures","indexOf","key","oldActiveGestures","setActiveGestures","isEnabled","isInitial","setPotentialGestures","hasNoInputs","updateAllInputs","updateActiveGestures","clearEndedInputs","pruneActiveGestures","style","touchAction","getGesturesByElement","g","removeGesture","cascade","smooth","smoothingIsApplicable","isRequested","matchMedia","matches","Smoothable","final_options","next","applySmoothing","identity","average","constants","utils"],"mappings":";AAAA,aA8LA,SAAA,EAAA,EAAA,GAAA,IAAA,EAAA,OAAA,KAAA,GAAA,GAAA,OAAA,sBAAA,CAAA,IAAA,EAAA,OAAA,sBAAA,GAAA,IAAA,EAAA,EAAA,OAAA,SAAA,GAAA,OAAA,OAAA,yBAAA,EAAA,GAAA,cAAA,EAAA,KAAA,MAAA,EAAA,GAAA,OAAA,EAAA,SAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,UAAA,OAAA,IAAA,CAAA,IAAA,EAAA,MAAA,UAAA,GAAA,UAAA,GAAA,GAAA,EAAA,EAAA,EAAA,OAAA,IAAA,GAAA,QAAA,SAAA,GAAA,EAAA,EAAA,EAAA,EAAA,MAAA,OAAA,0BAAA,OAAA,iBAAA,EAAA,OAAA,0BAAA,IAAA,EAAA,OAAA,IAAA,QAAA,SAAA,GAAA,OAAA,eAAA,EAAA,EAAA,OAAA,yBAAA,EAAA,MAAA,OAAA,EAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,KAAA,EAAA,OAAA,eAAA,EAAA,EAAA,CAAA,MAAA,EAAA,YAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,GAAA,EAAA,EAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,IAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,E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K;;AChIjB,aAYA,SAAA,EAAA,EAAA,GAAA,IAAA,EAAA,OAAA,KAAA,GAAA,GAAA,OAAA,sBAAA,CAAA,IAAA,EAAA,OAAA,sBAAA,GAAA,IAAA,EAAA,EAAA,OAAA,SAAA,GAAA,OAAA,OAAA,yBAAA,EAAA,GAAA,cAAA,EAAA,KAAA,MAAA,EAAA,GAAA,OAAA,EAAA,SAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,UAAA,OAAA,IAAA,CAAA,IAAA,EAAA,MAAA,UAAA,GAAA,UAAA,GAAA,GAAA,EAAA,EAAA,EAAA,OAAA,IAAA,GAAA,QAAA,SAAA,GAAA,EAAA,EAAA,EAAA,EAAA,MAAA,OAAA,0BAAA,OAAA,iBAAA,EAAA,OAAA,0BAAA,IAAA,EAAA,OAAA,IAAA,QAAA,SAAA,GAAA,OAAA,eAAA,EAAA,EAAA,OAAA,yBAAA,EAAA,MAAA,OAAA,EAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,KAAA,EAAA,OAAA,eAAA,EAAA,EAAA,CAAA,MAAA,EAAA,YAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,GAAA,EAAA,EAVA,IAAMnM,EAAUsE,QAAQ,oBAClBwC,EAAQxC,QAAQ,kBAChBzC,EAAUyC,QAAQ,oBAClBQ,EAAcR,QAAQ,wBACtBgF,EAAShF,QAAQ,mBACjB6H,EAAa7H,QAAQ,uBACrB0D,EAAQ1D,QAAQ,kBAChBmI,EAAYnI,QAAQ,sBACpBoI,EAAQpI,QAAQ,kBAEtB3C,OAAOC,QAAP,EAAA,EAAA,CACE5B,QAAAA,EACA8G,MAAAA,EACAjF,QAAAA,EACAiD,YAAAA,EACAwE,OAAAA,EACA6C,WAAAA,EACAnE,MAAAA,GACGyE,GACAC","file":"index.js","sourceRoot":"..","sourcesContent":["'use strict';\n\nlet g_id = 0;\n\n/**\n * The Gesture class that all gestures inherit from. A custom gesture class will\n * need to override some or all of the four phase \"hooks\": start, move, end, and\n * cancel.\n *\n * @memberof westures-core\n *\n * @param {string} type - The name of the gesture.\n * @param {Element} element - The element to which to associate the gesture.\n * @param {Function} handler - The function handler to execute when a gesture\n * is recognized on the associated element.\n * @param {object} [options] - Generic gesture options\n * @param {westures-core.STATE_KEYS[]} [options.enableKeys=[]] - List of keys\n * which will enable the gesture. The gesture will not be recognized unless one\n * of these keys is pressed while the interaction occurs. If not specified or an\n * empty list, the gesture is treated as though the enable key is always down.\n * @param {westures-core.STATE_KEYS[]} [options.disableKeys=[]] - List of keys\n * which will disable the gesture. The gesture will not be recognized if one of\n * these keys is pressed while the interaction occurs. If not specified or an\n * empty list, the gesture is treated as though the disable key is never down.\n * @param {number} [options.minInputs=1] - The minimum number of pointers that\n * must be active for the gesture to be recognized. Uses >=.\n * @param {number} [options.maxInputs=Number.MAX_VALUE] - The maximum number of\n * pointers that may be active for the gesture to be recognized. Uses <=.\n */\nclass Gesture {\n constructor(type, element, handler, options = {}) {\n if (typeof type !== 'string') {\n throw new TypeError('Gestures require a string type / name');\n }\n\n /**\n * The name of the gesture. (e.g. 'pan' or 'tap' or 'pinch').\n *\n * @type {string}\n */\n this.type = type;\n\n /**\n * The unique identifier for each gesture. This allows for distinctions\n * across instances of Gestures that are created on the fly (e.g.\n * gesture-tap-1, gesture-tap-2).\n *\n * @type {string}\n */\n this.id = `gesture-${this.type}-${g_id++}`;\n\n /**\n * The element to which to associate the gesture.\n *\n * @type {Element}\n */\n this.element = element;\n\n /**\n * The function handler to execute when the gesture is recognized on the\n * associated element.\n *\n * @type {Function}\n */\n this.handler = handler;\n\n /**\n * The options settings.\n *\n * @type {object}\n */\n this.options = { ...Gesture.DEFAULTS, ...options };\n }\n\n /**\n * Determines whether this gesture is enabled.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {boolean} true if enabled, false otherwise.\n */\n isEnabled(state) {\n const count = state.active.length;\n const event = state.event;\n const { enableKeys, disableKeys, minInputs, maxInputs } = this.options;\n\n return (minInputs <= count) && (maxInputs >= count) &&\n (enableKeys.length === 0 || enableKeys.some(k => event[k])) &&\n !disableKeys.some(k => event[k]);\n }\n\n /**\n * Event hook for the start phase of a gesture.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n start() {\n return null;\n }\n\n /**\n * Event hook for the move phase of a gesture.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n move() {\n return null;\n }\n\n /**\n * Event hook for the end phase of a gesture.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n end() {\n return null;\n }\n\n /**\n * Event hook for when an input is cancelled.\n *\n * @param {westures-core.State} state - The input state object of the current\n * region.\n *\n * @return {?Object} Gesture is considered recognized if an Object is\n * returned.\n */\n cancel() {\n return null;\n }\n\n /**\n * Evalutes the given gesture hook, and dispatches any data that is produced\n * by calling [recognize]{@link westures-core.Gesture#recognize}.\n *\n * @param {string} hook - Must be one of 'start', 'move', 'end', or 'cancel'.\n * @param {westures-core.State} state - The current State instance.\n */\n evaluateHook(hook, state) {\n const data = this[hook](state);\n if (data) {\n this.recognize(hook, state, data);\n }\n }\n\n /**\n * Recognize a Gesture by calling the handler. Standardizes the way the\n * handler is called so that classes extending Gesture can circumvent the\n * evaluateHook approach but still provide results that have a common format.\n *\n * Note that the properties in the \"data\" object will receive priority when\n * constructing the results. This can be used to override standard results\n * such as the phase or the centroid.\n *\n * @param {string} hook - Must be one of 'start', 'move', 'end', or 'cancel'.\n * @param {westures-core.State} state - current input state.\n * @param {Object} data - Results data specific to the recognized gesture.\n */\n recognize(hook, state, data) {\n this.handler({\n centroid: state.centroid,\n event: state.event,\n phase: hook,\n type: this.type,\n target: this.element,\n ...data,\n });\n }\n}\n\nGesture.DEFAULTS = {\n enableKeys: [],\n disableKeys: [],\n minInputs: 1,\n maxInputs: Number.MAX_VALUE,\n};\n\nmodule.exports = Gesture;\n\n","'use strict';\n\n/**\n * The Point2D class stores and operates on 2-dimensional points, represented as\n * x and y coordinates.\n *\n * @memberof westures-core\n *\n * @param {number} [ x=0 ] - The x coordinate of the point.\n * @param {number} [ y=0 ] - The y coordinate of the point.\n */\nclass Point2D {\n constructor(x = 0, y = 0) {\n /**\n * The x coordinate of the point.\n *\n * @type {number}\n */\n this.x = x;\n\n /**\n * The y coordinate of the point.\n *\n * @type {number}\n */\n this.y = y;\n }\n\n /**\n * Calculates the angle between this point and the given point.\n *\n * @param {!westures-core.Point2D} point - Projected point for calculating the\n * angle.\n *\n * @return {number} Radians along the unit circle where the projected\n * point lies.\n */\n angleTo(point) {\n return Math.atan2(point.y - this.y, point.x - this.x);\n }\n\n /**\n * Determine the average distance from this point to the provided array of\n * points.\n *\n * @param {!westures-core.Point2D[]} points - the Point2D objects to calculate\n * the average distance to.\n *\n * @return {number} The average distance from this point to the provided\n * points.\n */\n averageDistanceTo(points) {\n return this.totalDistanceTo(points) / points.length;\n }\n\n /**\n * Clone this point.\n *\n * @return {westures-core.Point2D} A new Point2D, identical to this point.\n */\n clone() {\n return new Point2D(this.x, this.y);\n }\n\n /**\n * Calculates the distance between two points.\n *\n * @param {!westures-core.Point2D} point - Point to which the distance is\n * calculated.\n *\n * @return {number} The distance between the two points, a.k.a. the\n * hypoteneuse.\n */\n distanceTo(point) {\n return Math.hypot(point.x - this.x, point.y - this.y);\n }\n\n /**\n * Subtract the given point from this point.\n *\n * @param {!westures-core.Point2D} point - Point to subtract from this point.\n *\n * @return {westures-core.Point2D} A new Point2D, which is the result of (this\n * - point).\n */\n minus(point) {\n return new Point2D(\n this.x - point.x,\n this.y - point.y,\n );\n }\n\n /**\n * Return the summation of this point to the given point.\n *\n * @param {!westures-core.Point2D} point - Point to add to this point.\n *\n * @return {westures-core.Point2D} A new Point2D, which is the addition of the\n * two points.\n */\n plus(point) {\n return new Point2D(\n this.x + point.x,\n this.y + point.y,\n );\n }\n\n /**\n * Calculates the total distance from this point to an array of points.\n *\n * @param {!westures-core.Point2D[]} points - The array of Point2D objects to\n * calculate the total distance to.\n *\n * @return {number} The total distance from this point to the provided points.\n */\n totalDistanceTo(points) {\n return points.reduce((d, p) => d + this.distanceTo(p), 0);\n }\n\n /**\n * Calculates the centroid of a list of points.\n *\n * @param {westures-core.Point2D[]} points - The array of Point2D objects for\n * which to calculate the centroid.\n *\n * @return {westures-core.Point2D} The centroid of the provided points.\n */\n static centroid(points = []) {\n if (points.length === 0) return null;\n\n const total = Point2D.sum(points);\n total.x /= points.length;\n total.y /= points.length;\n return total;\n }\n\n /**\n * Calculates the sum of the given points.\n *\n * @param {westures-core.Point2D[]} points - The Point2D objects to sum up.\n *\n * @return {westures-core.Point2D} A new Point2D representing the sum of the\n * given points.\n */\n static sum(points = []) {\n return points.reduce(\n (total, pt) => {\n total.x += pt.x;\n total.y += pt.y;\n return total;\n },\n new Point2D(0, 0),\n );\n }\n}\n\nmodule.exports = Point2D;\n\n","'use strict';\n\n/**\n * List of events that trigger the cancel phase.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst CANCEL_EVENTS = [\n 'blur',\n 'pointercancel',\n 'touchcancel',\n 'mouseleave',\n];\n\n/**\n * List of keyboard events that trigger a restart.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst KEYBOARD_EVENTS = [\n 'keydown',\n 'keyup',\n];\n\n/**\n * List of mouse events to listen to.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst MOUSE_EVENTS = [\n 'mousedown',\n 'mousemove',\n 'mouseup',\n];\n\n/**\n * List of pointer events to listen to.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst POINTER_EVENTS = [\n 'pointerdown',\n 'pointermove',\n 'pointerup',\n];\n\n/**\n * List of touch events to listen to.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst TOUCH_EVENTS = [\n 'touchend',\n 'touchmove',\n 'touchstart',\n];\n\n/**\n * List of potentially state-modifying keys.\n * Entries are: ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst STATE_KEYS = [\n 'altKey',\n 'ctrlKey',\n 'metaKey',\n 'shiftKey',\n];\n\n/**\n * List of the 'key' values on KeyboardEvent objects of the potentially\n * state-modifying keys.\n *\n * @memberof westures-core\n * @type {string[]}\n */\nconst STATE_KEY_STRINGS = [\n 'Alt',\n 'Control',\n 'Meta',\n 'Shift',\n];\n\n/**\n * The cancel phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst CANCEL = 'cancel';\n\n/**\n * The end phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst END = 'end';\n\n/**\n * The move phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst MOVE = 'move';\n\n/**\n * The start phase.\n *\n * @memberof westures-core\n * @type {string}\n */\nconst START = 'start';\n\n/**\n * The recognized phases.\n *\n * @memberof westures-core\n * @type {list.<string>}\n */\nconst PHASES = [START, MOVE, END, CANCEL];\n\n/**\n * Object that normalizes the names of window events to be either of type start,\n * move, end, or cancel.\n *\n * @memberof westures-core\n * @type {object}\n */\nconst PHASE = {\n blur: CANCEL,\n pointercancel: CANCEL,\n touchcancel: CANCEL,\n\n mouseup: END,\n pointerup: END,\n touchend: END,\n\n mousemove: MOVE,\n pointermove: MOVE,\n touchmove: MOVE,\n\n mousedown: START,\n pointerdown: START,\n touchstart: START,\n};\n\nmodule.exports = {\n CANCEL_EVENTS,\n KEYBOARD_EVENTS,\n MOUSE_EVENTS,\n POINTER_EVENTS,\n TOUCH_EVENTS,\n\n STATE_KEYS,\n STATE_KEY_STRINGS,\n\n CANCEL,\n END,\n MOVE,\n START,\n\n PHASE,\n PHASES,\n};\n\n","'use strict';\n\nconst Point2D = require('./Point2D.js');\nconst { PHASE } = require('./constants.js');\n\n/**\n * @private\n * @inner\n * @memberof westures-core.PointerData\n *\n * @return {Event} The Event object which corresponds to the given identifier.\n * Contains clientX, clientY values.\n */\nfunction getEventObject(event, identifier) {\n if (event.changedTouches) {\n return Array.from(event.changedTouches).find(touch => {\n return touch.identifier === identifier;\n });\n }\n return event;\n}\n\n/**\n * Low-level storage of pointer data based on incoming data from an interaction\n * event.\n *\n * @memberof westures-core\n *\n * @param {Event} event - The event object being wrapped.\n * @param {number} identifier - The index of touch if applicable\n */\nclass PointerData {\n constructor(event, identifier) {\n const { clientX, clientY } = getEventObject(event, identifier);\n\n /**\n * The original event object.\n *\n * @type {Event}\n */\n this.event = event;\n\n /**\n * The type or 'phase' of this batch of pointer data. 'start' or 'move' or\n * 'end' or 'cancel'\n *\n * @type {string}\n */\n this.type = PHASE[event.type];\n\n /**\n * The timestamp of the event in milliseconds elapsed since January 1, 1970,\n * 00:00:00 UTC.\n *\n * @type {number}\n */\n this.time = Date.now();\n\n /**\n * The (x,y) coordinate of the event, wrapped in a Point2D.\n *\n * @type {westures-core.Point2D}\n */\n this.point = new Point2D(clientX, clientY);\n }\n}\n\nmodule.exports = PointerData;\n\n","'use strict';\n\nconst PI_2 = 2 * Math.PI;\nconst PI_NVE = -Math.PI;\n\n/**\n * Helper function to regulate angular differences, so they don't jump from 0 to\n * 2 * PI or vice versa.\n *\n * @memberof westures-core\n *\n * @param {number} a - Angle in radians.\n * @param {number} b - Angle in radians.\n\n * @return {number} c, given by: c = a - b such that |c| < PI\n */\nfunction angularDifference(a, b) {\n let diff = a - b;\n if (diff < PI_NVE) {\n diff += PI_2;\n } else if (diff > Math.PI) {\n diff -= PI_2;\n }\n return diff;\n}\n\n/**\n * In case event.composedPath() is not available.\n *\n * @memberof westures-core\n *\n * @param {Event} event\n *\n * @return {Element[]} The elements along the composed path of the event.\n */\nfunction getPropagationPath(event) {\n if (typeof event.composedPath === 'function') {\n return event.composedPath();\n }\n\n const path = [];\n for (let node = event.target; node !== document; node = node.parentNode) {\n path.push(node);\n }\n path.push(document);\n path.push(window);\n\n return path;\n}\n\n/**\n * Performs a set filter operation.\n *\n * @memberof westures-core\n *\n * @param {Set} set - The set to filter.\n * @param {Function} predicate - Function to test elements of 'set'. Receives\n * one argument: the current set element.\n *\n * @return {Set} Set consisting of elements in 'set' for which 'predicate' is\n * true.\n */\nfunction setFilter(set, predicate) {\n const result = new Set();\n set.forEach(element => {\n if (predicate(element)) {\n result.add(element);\n }\n });\n return result;\n}\n\n/**\n * Performs a set difference operation.\n *\n * @memberof westures-core\n *\n * @param {Set} left - Base set.\n * @param {Set} right - Set of elements to remove from 'left'.\n *\n * @return {Set} Set consisting of elements in 'left' that are not in\n * 'right'.\n */\nfunction setDifference(left, right) {\n return setFilter(left, element => !right.has(element));\n}\n\nmodule.exports = {\n angularDifference,\n getPropagationPath,\n setDifference,\n setFilter,\n};\n\n","'use strict';\n\nconst PointerData = require('./PointerData.js');\nconst { getPropagationPath } = require('./utils.js');\n\n/**\n * Tracks a single input and contains information about the current, previous,\n * and initial events.\n *\n * @memberof westures-core\n *\n * @param {(PointerEvent | MouseEvent | TouchEvent)} event - The input event\n * which will initialize this Input object.\n * @param {number} identifier - The identifier for this input, so that it can\n * be located in subsequent Event objects.\n */\nclass Input {\n constructor(event, identifier) {\n const currentData = new PointerData(event, identifier);\n\n /**\n * The set of elements along the original event's propagation path at the\n * time it was dispatched.\n *\n * @type {WeakSet.<Element>}\n */\n this.initialElements = new WeakSet(getPropagationPath(event));\n\n /**\n * Holds the initial data from the mousedown / touchstart / pointerdown that\n * began this input.\n *\n * @type {westures-core.PointerData}\n */\n this.initial = currentData;\n\n /**\n * Holds the most current pointer data for this Input.\n *\n * @type {westures-core.PointerData}\n */\n this.current = currentData;\n\n /**\n * Holds the previous pointer data for this Input.\n *\n * @type {westures-core.PointerData}\n */\n this.previous = currentData;\n\n /**\n * The identifier for the pointer / touch / mouse button associated with\n * this input.\n *\n * @type {number}\n */\n this.identifier = identifier;\n }\n\n /**\n * The phase of the input: 'start' or 'move' or 'end' or 'cancel'\n *\n * @type {string}\n */\n get phase() { return this.current.type; }\n\n /**\n * The timestamp of the initiating event for this input.\n *\n * @type {number}\n */\n get startTime() { return this.initial.time; }\n\n /**\n * @return {number} The distance between the initiating event for this input\n * and its current event.\n */\n totalDistance() {\n return this.initial.point.distanceTo(this.current.point);\n }\n\n /**\n * Saves the given raw event in PointerData form as the current data for this\n * input, pushing the old current data into the previous slot, and tossing\n * out the old previous data.\n *\n * @param {Event} event - The event object to wrap with a PointerData.\n */\n update(event) {\n this.previous = this.current;\n this.current = new PointerData(event, this.identifier);\n }\n}\n\nmodule.exports = Input;\n\n","'use strict';\n\nconst {\n CANCEL,\n END,\n MOVE,\n PHASE,\n START,\n} = require('./constants.js');\nconst Input = require('./Input.js');\nconst Point2D = require('./Point2D.js');\n\nconst symbols = {\n inputs: Symbol.for('inputs'),\n};\n\n/**\n * Set of helper functions for updating inputs based on type of input.\n * Must be called with a bound 'this', via bind(), or call(), or apply().\n *\n * @private\n * @inner\n * @memberof westure-core.State\n */\nconst update_fns = {\n TouchEvent: function TouchEvent(event) {\n Array.from(event.changedTouches).forEach(touch => {\n this.updateInput(event, touch.identifier);\n });\n },\n\n PointerEvent: function PointerEvent(event) {\n this.updateInput(event, event.pointerId);\n },\n\n MouseEvent: function MouseEvent(event) {\n if (event.button === 0) {\n this.updateInput(event, event.button);\n }\n },\n};\n\n/**\n * Keeps track of currently active and ending input points on the interactive\n * surface.\n *\n * @memberof westures-core\n *\n * @param {Element} element - The element underpinning the associated Region.\n */\nclass State {\n constructor(element) {\n /**\n * Keep a reference to the element for the associated region.\n *\n * @type {Element}\n */\n this.element = element;\n\n /**\n * Keeps track of the current Input objects.\n *\n * @alias [@@inputs]\n * @type {Map.<westures-core.Input>}\n * @memberof westure-core.State\n */\n this[symbols.inputs] = new Map();\n\n /**\n * All currently valid inputs, including those that have ended.\n *\n * @type {westures-core.Input[]}\n */\n this.inputs = [];\n\n /**\n * The array of currently active inputs, sourced from the current Input\n * objects. \"Active\" is defined as not being in the 'end' phase.\n *\n * @type {westures-core.Input[]}\n */\n this.active = [];\n\n /**\n * The array of latest point data for the currently active inputs, sourced\n * from this.active.\n *\n * @type {westures-core.Point2D[]}\n */\n this.activePoints = [];\n\n /**\n * The centroid of the currently active points.\n *\n * @type {westures-core.Point2D}\n */\n this.centroid = {};\n\n /**\n * The latest event that the state processed.\n *\n * @type {Event}\n */\n this.event = null;\n }\n\n /**\n * Deletes all inputs that are in the 'end' phase.\n */\n clearEndedInputs() {\n this[symbols.inputs].forEach((v, k) => {\n if (v.phase === 'end') this[symbols.inputs].delete(k);\n });\n }\n\n /**\n * @param {string} phase - One of 'start', 'move', 'end', or 'cancel'.\n *\n * @return {westures-core.Input[]} Inputs in the given phase.\n */\n getInputsInPhase(phase) {\n return this.inputs.filter(i => i.phase === phase);\n }\n\n /**\n * @param {string} phase - One of 'start', 'move', 'end', or 'cancel'.\n *\n * @return {westures-core.Input[]} Inputs <b>not</b> in the given phase.\n */\n getInputsNotInPhase(phase) {\n return this.inputs.filter(i => i.phase !== phase);\n }\n\n /**\n * @return {boolean} True if there are no active inputs. False otherwise.\n */\n hasNoInputs() {\n return this[symbols.inputs].size === 0;\n }\n\n /**\n * Update the input with the given identifier using the given event.\n *\n * @private\n *\n * @param {Event} event - The event being captured.\n * @param {number} identifier - The identifier of the input to update.\n */\n updateInput(event, identifier) {\n switch (PHASE[event.type]) {\n case START:\n this[symbols.inputs].set(\n identifier,\n new Input(event, identifier),\n );\n try {\n this.element.setPointerCapture(identifier);\n } catch (e) {\n // NOP: Optional operation failed.\n }\n break;\n\n // All of 'end', 'move', and 'cancel' perform updates, hence the\n // following fall-throughs\n case END:\n try {\n this.element.releasePointerCapture(identifier);\n } catch (e) {\n // NOP: Optional operation failed.\n }\n case CANCEL:\n case MOVE:\n if (this[symbols.inputs].has(identifier)) {\n this[symbols.inputs].get(identifier).update(event);\n }\n break;\n\n default:\n console.warn(`Unrecognized event type: ${event.type}`);\n }\n }\n\n /**\n * Updates the inputs with new information based upon a new event being fired.\n *\n * @private\n * @param {Event} event - The event being captured.\n */\n updateAllInputs(event) {\n update_fns[event.constructor.name].call(this, event);\n this.updateFields(event);\n }\n\n /**\n * Updates the convenience fields.\n *\n * @private\n * @param {Event} event - Event with which to update the convenience fields.\n */\n updateFields(event) {\n this.inputs = Array.from(this[symbols.inputs].values());\n this.active = this.getInputsNotInPhase('end');\n this.activePoints = this.active.map(i => i.current.point);\n this.centroid = Point2D.centroid(this.activePoints);\n this.event = event;\n }\n}\n\nmodule.exports = State;\n\n","'use strict';\n\nconst State = require('./State.js');\nconst {\n CANCEL_EVENTS,\n KEYBOARD_EVENTS,\n MOUSE_EVENTS,\n POINTER_EVENTS,\n TOUCH_EVENTS,\n\n STATE_KEY_STRINGS,\n\n PHASE,\n\n CANCEL,\n END,\n START,\n} = require('./constants.js');\nconst {\n setDifference,\n setFilter,\n} = require('./utils.js');\n\n/**\n * Allows the user to specify the control region which will listen for user\n * input events.\n *\n * @memberof westures-core\n *\n * @param {Element} element=window - The element which should listen to input\n * events.\n * @param {object} [options]\n * @param {boolean} [options.capture=false] - Whether the region uses the\n * capture phase of input events. If false, uses the bubbling phase.\n * @param {boolean} [options.preferPointer=true] - If false, the region listens\n * to mouse/touch events instead of pointer events.\n * @param {boolean} [options.preventDefault=true] - Whether the default\n * browser functionality should be disabled. This option should most likely be\n * ignored. Here there by dragons if set to false.\n * @param {string} [options.touchAction='none'] - Value to set the CSS\n * 'touch-action' property to on elements added to the region.\n */\nclass Region {\n constructor(element = window, options = {}) {\n options = { ...Region.DEFAULTS, ...options };\n\n /**\n * The list of relations between elements, their gestures, and the handlers.\n *\n * @type {Set.<westures-core.Gesture>}\n */\n this.gestures = new Set();\n\n /**\n * The list of active gestures for the current input session.\n *\n * @type {Set.<westures-core.Gesture>}\n */\n this.activeGestures = new Set();\n\n /**\n * The base list of potentially active gestures for the current input\n * session.\n *\n * @type {Set.<westures-core.Gesture>}\n */\n this.potentialGestures = new Set();\n\n /**\n * The element being bound to.\n *\n * @type {Element}\n */\n this.element = element;\n\n /**\n * The user-supplied options for the Region.\n *\n * @type {object}\n */\n this.options = options;\n\n /**\n * The internal state object for a Region. Keeps track of inputs.\n *\n * @type {westures-core.State}\n */\n this.state = new State(this.element);\n\n // Begin operating immediately.\n this.activate();\n }\n\n /**\n * Activates the region by adding event listeners for all appropriate input\n * events to the region's element.\n *\n * @private\n */\n activate() {\n /*\n * Listening to both mouse and touch comes with the difficulty that\n * preventDefault() must be called to prevent both events from iterating\n * through the system. However I have left it as an option to the end user,\n * which defaults to calling preventDefault(), in case there's a use-case I\n * haven't considered or am not aware of.\n *\n * It also may be a good idea to keep regions small in large pages.\n *\n * See:\n * https://www.html5rocks.com/en/mobile/touchandmouse/\n * https://developer.mozilla.org/en-US/docs/Web/API/Touch_events\n * https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events\n */\n let eventNames = [];\n if (this.options.preferPointer && window.PointerEvent) {\n eventNames = POINTER_EVENTS;\n } else {\n eventNames = MOUSE_EVENTS.concat(TOUCH_EVENTS);\n }\n\n // Bind detected browser events to the region element.\n const arbitrate = this.arbitrate.bind(this);\n eventNames.forEach(eventName => {\n this.element.addEventListener(eventName, arbitrate, {\n capture: this.options.capture,\n once: false,\n passive: false,\n });\n });\n\n const cancel = this.cancel.bind(this);\n CANCEL_EVENTS.forEach(eventName => {\n window.addEventListener(eventName, cancel);\n });\n\n const handleKeyboardEvent = this.handleKeyboardEvent.bind(this);\n KEYBOARD_EVENTS.forEach(eventName => {\n window.addEventListener(eventName, handleKeyboardEvent);\n });\n }\n\n /**\n * Handles a cancel event. Resets the state and the active / potential gesture\n * lists.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n */\n cancel(event) {\n if (this.options.preventDefault) event.preventDefault();\n this.state.inputs.forEach(input => {\n input.update(event);\n });\n this.activeGestures.forEach(gesture => {\n gesture.evaluateHook(CANCEL, this.state);\n });\n this.state = new State(this.element);\n this.resetActiveGestures();\n }\n\n /**\n * Handles a keyboard event, triggering a restart of any gestures that need\n * it.\n *\n * @private\n * @param {KeyboardEvent} event - The keyboard event.\n */\n handleKeyboardEvent(event) {\n if (STATE_KEY_STRINGS.indexOf(event.key) >= 0) {\n this.state.event = event;\n const oldActiveGestures = this.activeGestures;\n this.setActiveGestures();\n\n setDifference(oldActiveGestures, this.activeGestures).forEach(gesture => {\n gesture.evaluateHook(END, this.state);\n });\n setDifference(this.activeGestures, oldActiveGestures).forEach(gesture => {\n gesture.evaluateHook(START, this.state);\n });\n }\n }\n\n /**\n * Resets the active gestures.\n *\n * @private\n */\n resetActiveGestures() {\n this.potentialGestures = new Set();\n this.activeGestures = new Set();\n }\n\n /**\n * Selects active gestures from the list of potentially active gestures.\n *\n * @private\n */\n setActiveGestures() {\n this.activeGestures = setFilter(this.potentialGestures, gesture => {\n return gesture.isEnabled(this.state);\n });\n }\n\n /**\n * Selects the potentially active gestures.\n *\n * @private\n */\n setPotentialGestures() {\n const input = this.state.inputs[0];\n this.potentialGestures = setFilter(this.gestures, gesture => {\n return input.initialElements.has(gesture.element);\n });\n }\n\n /**\n * Selects the gestures that are active for the current input sequence.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n * @param {boolean} isInitial - Whether this is an initial contact.\n */\n updateActiveGestures(event, isInitial) {\n if (PHASE[event.type] === START) {\n if (isInitial) {\n this.setPotentialGestures();\n }\n this.setActiveGestures();\n }\n }\n\n /**\n * Evaluates whether the current input session has completed.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n */\n pruneActiveGestures(event) {\n if (PHASE[event.type] === END) {\n if (this.state.hasNoInputs()) {\n this.resetActiveGestures();\n } else {\n this.setActiveGestures();\n }\n }\n }\n\n /**\n * All input events flow through this function. It makes sure that the input\n * state is maintained, determines which gestures to analyze based on the\n * initial position of the inputs, calls the relevant gesture hooks, and\n * dispatches gesture data.\n *\n * @private\n * @param {Event} event - The event emitted from the window object.\n */\n arbitrate(event) {\n const isInitial = this.state.hasNoInputs();\n this.state.updateAllInputs(event);\n this.updateActiveGestures(event, isInitial);\n\n if (this.activeGestures.size > 0) {\n if (this.options.preventDefault) event.preventDefault();\n\n this.activeGestures.forEach(gesture => {\n gesture.evaluateHook(PHASE[event.type], this.state);\n });\n }\n\n this.state.clearEndedInputs();\n this.pruneActiveGestures(event);\n }\n\n /**\n * Adds the given gesture to the region.\n *\n * @param {westures-core.Gesture} gesture - Instantiated gesture to add.\n */\n addGesture(gesture) {\n gesture.element.style.touchAction = this.options.touchAction;\n this.gestures.add(gesture);\n }\n\n /**\n * Removes the given gesture from the region.\n *\n * @param {westures-core.Gesture} gesture - Instantiated gesture to add.\n */\n removeGesture(gesture) {\n this.gestures.delete(gesture);\n this.potentialGestures.delete(gesture);\n this.activeGestures.delete(gesture);\n }\n\n /**\n * Retrieves Gestures by their associated element.\n *\n * @param {Element} element - The element for which to find gestures.\n *\n * @return {westures-core.Gesture[]} Gestures to which the element is bound.\n */\n getGesturesByElement(element) {\n return setFilter(this.gestures, gesture => gesture.element === element);\n }\n\n /**\n * Remove all gestures bound to the given element.\n *\n * @param {Element} element - The element to unbind.\n */\n removeGesturesByElement(element) {\n this.getGesturesByElement(element).forEach(g => this.removeGesture(g));\n }\n}\n\nRegion.DEFAULTS = {\n capture: false,\n preferPointer: true,\n preventDefault: true,\n touchAction: 'none',\n};\n\nmodule.exports = Region;\n","'use strict';\n\nconst cascade = Symbol('cascade');\nconst smooth = Symbol('smooth');\n\n/**\n * Determines whether to apply smoothing. Smoothing is on by default but turned\n * off if either:<br>\n * 1. The user explicitly requests that it be turned off.<br>\n * 2. The active pointer is not \"coarse\".<br>\n *\n * @see {@link\n * https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia}\n *\n * @inner\n * @memberof westures-core.Smoothable\n *\n * @param {boolean} isRequested - Whether smoothing was requested by the user.\n *\n * @returns {boolean} Whether to apply smoothing.\n */\nfunction smoothingIsApplicable(isRequested) {\n if (isRequested) {\n try {\n return window.matchMedia('(pointer: coarse)').matches;\n } catch (e) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * A Smoothable datatype is one that is capable of smoothing out a series of\n * values as they come in, one at a time, providing a more consistent series. It\n * does this by creating some inertia in the values using a cascading average.\n * (For those who are interested in such things, this effectively means that it\n * provides a practical application of Zeno's Dichotomy).\n *\n * @example\n * const x = new Smoothable({ identity: 1 });\n * const a = x.next(1); // 1.0\n * const b = x.next(1.2); // 1.1\n * const c = x.next(0.9); // 1.0\n * const d = x.next(0.6); // 0.8\n * const e = x.next(1.2); // 1.0\n * const f = x.next(1.6); // 1.3\n * x.restart();\n * const g = x.next(0); // 0.5\n *\n * @memberof westures-core\n *\n * @param {Object} [options]\n * @param {boolean} [options.applySmoothing=true] Whether to apply smoothing to\n * the data.\n * @param {*} [options.identity=0] The identity value of this smoothable data.\n */\nclass Smoothable {\n constructor(options = {}) {\n const final_options = { ...Smoothable.DEFAULTS, ...options };\n\n /**\n * The function through which smoothed emits are passed.\n *\n * @method\n * @param {*} data - The data to emit.\n *\n * @return {*} The smoothed out data.\n */\n this.next = null;\n if (smoothingIsApplicable(final_options.applySmoothing)) {\n this.next = this[smooth].bind(this);\n } else {\n this.next = data => data;\n }\n\n /**\n * The \"identity\" value of the data that will be smoothed.\n *\n * @type {*}\n * @default 0\n */\n this.identity = final_options.identity;\n\n /**\n * The cascading average of outgoing values.\n *\n * @memberof westures-core.Smoothable\n * @alias [@@cascade]\n * @type {object}\n */\n this[cascade] = this.identity;\n }\n\n /**\n * Restart the Smoothable gesture.\n */\n restart() {\n this[cascade] = this.identity;\n }\n\n /**\n * Smooth out the outgoing data.\n *\n * @memberof westures-core.Smoothable\n * @alias [@@smooth]\n * @param {object} data - The next batch of data to emit.\n *\n * @return {?object}\n */\n [smooth](data) {\n const average = this.average(this[cascade], data);\n this[cascade] = average;\n return average;\n }\n\n /**\n * Average out two values, as part of the smoothing algorithm. Override this\n * method if the data being smoothed is not a Number.\n *\n * @param {number} a\n * @param {number} b\n *\n * @return {number} The average of 'a' and 'b'\n */\n average(a, b) {\n return (a + b) / 2;\n }\n}\n\nSmoothable.DEFAULTS = {\n applySmoothing: true,\n identity: 0,\n};\n\nmodule.exports = Smoothable;\n\n","/**\n * The global API interface for westures-core. Exposes all classes, constants,\n * and routines used by the package. Use responsibly.\n *\n * @namespace westures-core\n */\n\n'use strict';\n\nconst Gesture = require('./src/Gesture.js');\nconst Input = require('./src/Input.js');\nconst Point2D = require('./src/Point2D.js');\nconst PointerData = require('./src/PointerData.js');\nconst Region = require('./src/Region.js');\nconst Smoothable = require('./src/Smoothable.js');\nconst State = require('./src/State.js');\nconst constants = require('./src/constants.js');\nconst utils = require('./src/utils.js');\n\nmodule.exports = {\n Gesture,\n Input,\n Point2D,\n PointerData,\n Region,\n Smoothable,\n State,\n ...constants,\n ...utils,\n};\n\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "westures-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The core engine of Westures, a robust n-pointer multitouch gesture detection library for JavaScript.",
|
|
5
|
+
"author": "Michael van der Kamp <michael.vanderkamp@usask.ca>",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"multitouch",
|
|
7
8
|
"gesture",
|
|
@@ -20,11 +21,11 @@
|
|
|
20
21
|
"mouse",
|
|
21
22
|
"pointer"
|
|
22
23
|
],
|
|
23
|
-
"
|
|
24
|
+
"source": "index.js",
|
|
25
|
+
"main": "dist/index.js",
|
|
24
26
|
"directories": {
|
|
25
27
|
"test": "test"
|
|
26
28
|
},
|
|
27
|
-
"author": "Michael van der Kamp <michael.vanderkamp@usask.ca>",
|
|
28
29
|
"repository": {
|
|
29
30
|
"type": "git",
|
|
30
31
|
"url": "https://github.com/mvanderkamp/westures-core"
|
|
@@ -32,7 +33,10 @@
|
|
|
32
33
|
"homepage": "https://mvanderkamp.github.io/westures-core/index.html",
|
|
33
34
|
"license": "MIT",
|
|
34
35
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
+
"build": "PARCEL_WORKER_BACKEND=process parcel build",
|
|
37
|
+
"coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls",
|
|
38
|
+
"test": "jest",
|
|
39
|
+
"test:debug": "node inspect $(npm bin)/jest --runInBand"
|
|
36
40
|
},
|
|
37
41
|
"jest": {
|
|
38
42
|
"modulePaths": [
|
|
@@ -44,16 +48,16 @@
|
|
|
44
48
|
]
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "^7.10
|
|
48
|
-
"@babel/preset-env": "^7.
|
|
51
|
+
"@babel/core": "^7.12.10",
|
|
52
|
+
"@babel/preset-env": "^7.12.11",
|
|
49
53
|
"arkit": "^1.6.4",
|
|
50
54
|
"coveralls": "^3.1.0",
|
|
51
|
-
"eslint": "^7.
|
|
52
|
-
"jest": "^26.
|
|
53
|
-
"jsdoc": "^3.6.
|
|
54
|
-
"lodash": "^4.17.
|
|
55
|
-
"parcel
|
|
56
|
-
"tui-jsdoc-template": "^1.2.2"
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
"eslint": "^7.17.0",
|
|
56
|
+
"jest": "^26.6.3",
|
|
57
|
+
"jsdoc": "^3.6.6",
|
|
58
|
+
"lodash": "^4.17.20",
|
|
59
|
+
"parcel": "^2.2.1",
|
|
60
|
+
"tui-jsdoc-template": "^1.2.2",
|
|
61
|
+
"underscore": "^1.13.2"
|
|
62
|
+
}
|
|
59
63
|
}
|
package/src/Gesture.js
CHANGED
package/src/Input.js
CHANGED
|
@@ -5,8 +5,7 @@ const { getPropagationPath } = require('./utils.js');
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Tracks a single input and contains information about the current, previous,
|
|
8
|
-
* and initial events.
|
|
9
|
-
* gestures.
|
|
8
|
+
* and initial events.
|
|
10
9
|
*
|
|
11
10
|
* @memberof westures-core
|
|
12
11
|
*
|
|
@@ -72,6 +71,14 @@ class Input {
|
|
|
72
71
|
*/
|
|
73
72
|
get startTime() { return this.initial.time; }
|
|
74
73
|
|
|
74
|
+
/**
|
|
75
|
+
* The amount of time elapsed between the start of this input and its latest
|
|
76
|
+
* event.
|
|
77
|
+
*
|
|
78
|
+
* @type {number}
|
|
79
|
+
*/
|
|
80
|
+
get elapsedTime() { return this.current.time - this.initial.time; }
|
|
81
|
+
|
|
75
82
|
/**
|
|
76
83
|
* @return {number} The distance between the initiating event for this input
|
|
77
84
|
* and its current event.
|
package/src/Point2D.js
CHANGED
|
@@ -39,6 +39,18 @@ class Point2D {
|
|
|
39
39
|
return Math.atan2(point.y - this.y, point.x - this.x);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Determine the angle from the centroid to each of the points.
|
|
44
|
+
*
|
|
45
|
+
* @param {!westures-core.Point2D[]} points - the Point2D objects to calculate
|
|
46
|
+
* the angles to.
|
|
47
|
+
*
|
|
48
|
+
* @returns {number[]}
|
|
49
|
+
*/
|
|
50
|
+
anglesTo(points) {
|
|
51
|
+
return points.map(point => this.angleTo(point));
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
/**
|
|
43
55
|
* Determine the average distance from this point to the provided array of
|
|
44
56
|
* points.
|
package/src/constants.js
CHANGED
|
@@ -120,6 +120,14 @@ const MOVE = 'move';
|
|
|
120
120
|
*/
|
|
121
121
|
const START = 'start';
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* The recognized phases.
|
|
125
|
+
*
|
|
126
|
+
* @memberof westures-core
|
|
127
|
+
* @type {list.<string>}
|
|
128
|
+
*/
|
|
129
|
+
const PHASES = [START, MOVE, END, CANCEL];
|
|
130
|
+
|
|
123
131
|
/**
|
|
124
132
|
* Object that normalizes the names of window events to be either of type start,
|
|
125
133
|
* move, end, or cancel.
|
|
@@ -161,5 +169,6 @@ module.exports = {
|
|
|
161
169
|
START,
|
|
162
170
|
|
|
163
171
|
PHASE,
|
|
172
|
+
PHASES,
|
|
164
173
|
};
|
|
165
174
|
|