Comparing version 0.6.0 to 0.6.1
@@ -19,5 +19,5 @@ define(["require", "exports", "tslib", "oribella-framework"], function (require, exports, tslib_1, oribella_framework_1) { | ||
_this.options = options; | ||
_this.listener = Object.assign({ | ||
_this.listener = oribella_framework_1.ensureProperties(listener, { | ||
timeEnd: function () { } | ||
}, _this.listener); | ||
}); | ||
return _this; | ||
@@ -24,0 +24,0 @@ } |
@@ -20,5 +20,5 @@ "use strict"; | ||
_this.options = options; | ||
_this.listener = Object.assign({ | ||
_this.listener = oribella_framework_1.ensureProperties(listener, { | ||
timeEnd: function () { } | ||
}, _this.listener); | ||
}); | ||
return _this; | ||
@@ -25,0 +25,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Options, RETURN_FLAG, Gesture, Listener } from 'oribella-framework'; | ||
import { Options, RETURN_FLAG, Gesture, Listener, ensureProperties } from 'oribella-framework'; | ||
export class LongtapOptions extends Options { | ||
@@ -13,5 +13,5 @@ constructor() { | ||
this.options = options; | ||
this.listener = Object.assign({ | ||
this.listener = ensureProperties(listener, { | ||
timeEnd() { } | ||
}, this.listener); | ||
}); | ||
} | ||
@@ -18,0 +18,0 @@ timeEnd() { return RETURN_FLAG.map(this.listener.timeEnd()); } |
@@ -15,3 +15,3 @@ define("oribella",[],function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=22)}([function(t,e,n){"use strict";function i(t,e){function n(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&(n[i[r]]=t[i[r]]);return n}function o(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var u=t.length-1;u>=0;u--)(r=t[u])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function s(t,e){return function(n,i){e(n,i,t)}}function u(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function a(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{a(i.next(t))}catch(t){o(t)}}function u(t){try{a(i.throw(t))}catch(t){o(t)}}function a(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,u)}a((i=i.apply(t,e||[])).next())})}function c(t,e){function n(t){return function(e){return i([t,e])}}function i(n){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,o&&(s=o[2&n[0]?"return":n[0]?"throw":"next"])&&!(s=s.call(o,n[1])).done)return s;switch(o=0,s&&(n=[0,s.value]),n[0]){case 0:case 1:s=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,o=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(s=u.trys,!(s=s.length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){u.label=n[1];break}if(6===n[0]&&u.label<s[1]){u.label=s[1],s=n;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(n);break}s[2]&&u.ops.pop(),u.trys.pop();continue}n=e.call(t,u)}catch(t){n=[6,t],o=0}finally{r=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var r,o,s,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return{next:n(0),throw:n(1),return:n(2)}}Object.defineProperty(e,"__esModule",{value:!0}),e.__extends=i,n.d(e,"__assign",function(){return h}),e.__rest=r,e.__decorate=o,e.__param=s,e.__metadata=u,e.__awaiter=a,e.__generator=c;/*! ***************************************************************************** | ||
***************************************************************************** */ | ||
var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},h=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}},function(t,e,n){"use strict";function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}i(n(8)),i(n(2)),i(n(7)),i(n(18)),i(n(20))},function(t,e,n){"use strict";function i(t,n){return void 0===n&&(n=e.SUPPORTS),!(!n.msPointerEnabled||t.pointerType!==t.MSPOINTER_TYPE_MOUSE)||(!(!n.pointerEnabled||"mouse"!==t.pointerType)||t.type.indexOf("mouse")!==-1)}function r(t,e){var n=t.button,i=t.which,r=i||void 0===n?i:1&n?1:2&n?3:4&n?2:0;return Array.isArray(e)?e.some(function(t){return r===t}):r===e}function o(t,e){return(t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector).call(t,e)}function s(t,e){for(var n in e)e[n]&&!t[n]&&(t[n]=e[n]);return t}var u=n(0);e.GESTURE_STRATEGY_FLAG={KEEP:0,REMOVE_IF_POINTERS_GT:1},e.RETURN_FLAG={map:function(t){switch(t){case!0:t=this.REMOVE_OTHERS;break;case!1:t=this.REMOVE;break;case 1:case 2:case 4:break;default:t=0}return t},IDLE:0,START_EMITTED:1,REMOVE:2,REMOVE_OTHERS:4,REMOVE_AND_CONTINUE:8,COMPOSE:16},e.SUPPORTS={get touchEnabled(){return"ontouchstart"in window},get pointerEnabled(){return window&&window.navigator.pointerEnabled},get msPointerEnabled(){return window&&window.navigator.msPointerEnabled}},e.isMouse=i,e.isValidMouseButton=r,e.matchesSelector=o;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u.__extends(e,t),e}(Map);e.PointerDataMap=a;var c=function(){function t(){this.pointers=1,this.which=1,this.prio=100,this.strategy=e.GESTURE_STRATEGY_FLAG.KEEP}return t}();e.Options=c;var p=function(){function t(){}return t}();e.Data=p,e.ensureProperties=s},function(t,e,n){"use strict";function i(t){t.registerGesture(a,s,u)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.radiusThreshold=2,e.timeThreshold=500,e}return r.__extends(e,t),e}(o.Options);e.LongtapOptions=s;var u=function(t){function e(e,n){var i=t.call(this,e,n)||this;return i.options=e,i.listener=Object.assign({timeEnd:function(){}},i.listener),i}return r.__extends(e,t),e.prototype.timeEnd=function(){return o.RETURN_FLAG.map(this.listener.timeEnd())},e}(o.Listener);e.LongtapListener=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeoutId=0,e.timeEndEmitted=!1,e}return r.__extends(e,t),e.prototype.start=function(t,e){var n=this;return this.startPoint=e.pointers[0].page,this.timeoutId=window.setTimeout(function(){n.listener.timeEnd(),n.timeEndEmitted=!0},this.listener.options.timeThreshold),this.listener.start(t,e,this.target)},e.prototype.update=function(t,e){var n=e.pointers[0].page;return n.distanceTo(this.startPoint)>this.listener.options.radiusThreshold?o.RETURN_FLAG.REMOVE:o.RETURN_FLAG.IDLE},e.prototype.end=function(t,e){return window.clearTimeout(this.timeoutId),this.timeEndEmitted?this.listener.end(t,e,this.target):o.RETURN_FLAG.REMOVE},e.prototype.cancel=function(){return window.clearTimeout(this.timeoutId),this.listener.cancel()},e}(o.Gesture);e.Longtap=a,e.registerLongtap=i},function(t,e,n){"use strict";function i(t){t.registerGesture(c,a,void 0,u)}var r=n(0),o=n(1),s=function(){function t(t,e){this.point=t,this.timeStamp=e}return t}();e.Observation=s;var u=function(t){function e(e){void 0===e&&(e=5);var n=t.call(this)||this;return n.maxObservations=e,n.timeSeries=[],n}return r.__extends(e,t),e.prototype.add=function(t,e){this.timeSeries.length===this.maxObservations&&this.timeSeries.shift(),this.timeSeries.push(new s(t,e))},e}(o.Data);e.SwipeData=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.radiusThreshold=2,e}return r.__extends(e,t),e}(o.Options);e.SwipeOptions=a;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.start=function(t,e){return this.startPoint=e.pointers[0].page,e.add(this.startPoint,t.timeStamp),this.listener.down(t,e,this.target)},e.prototype.update=function(t,e){var n=e.pointers[0].page;return n.distanceTo(this.startPoint)<this.listener.options.radiusThreshold?o.RETURN_FLAG.IDLE:(e.add(n,t.timeStamp),this.startEmitted?this.listener.update(t,e,this.target):this.listener.start(t,e,this.target))},e.prototype.end=function(t,e){var n=e.pointers[0].page;return e.add(n,t.timeStamp),this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Swipe=c,e.registerSwipe=i},function(t,e,n){"use strict";function i(t){t.registerGesture(u,s)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.radiusThreshold=2,e}return r.__extends(e,t),e}(o.Options);e.TapOptions=s;var u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.start=function(t,e){return this.startPoint=e.pointers[0].page,this.listener.start(t,e,this.target)},e.prototype.update=function(t,e){var n=e.pointers[0].page;return n.distanceTo(this.startPoint)>this.listener.options.radiusThreshold?o.RETURN_FLAG.REMOVE:o.RETURN_FLAG.IDLE},e.prototype.end=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Tap=u,e.registerTap=i},function(t,e,n){"use strict";var i=n(0),r=function(){function t(){this.listenerMap=new Map}return t.prototype.on=function(t,e){var n=this.listenerMap.get(t)||[];return n.push(e),this.listenerMap.set(t,n),this},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var i=this.listenerMap.get(t)||[];return i.forEach(function(t){return t.apply(null,e)}),!0},t}();e.EventEmitter=r;var o=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.events=t}return t.prototype.getEvents=function(){return this.events},t}();e.EventConfig=o;var s=function(t){function e(e,n){var i=t.call(this)||this;return i.element=e,i.startListen=[],i.continueListen=[],i.removeListeners=[],i.allPointers=new Map,i.changedPointers=new Map,i.pointers={all:i.allPointers,changed:i.changedPointers},i.config=n,i}return i.__extends(e,t),e.prototype.proxy=function(t,e){this.setPointers(e),t(e)},e.prototype.addDOMEventListener=function(t,e,n){var i=this.proxy.bind(this,n);return t.addEventListener(e,i,!1),this.removeDOMEventListener.bind(this,t,e,i)},e.prototype.removeDOMEventListener=function(t,e,n){t.removeEventListener(e,n,!1)},e.prototype.bind=function(t){var e=this;return this.startListen=t.start.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.start.bind(e))}),this.continueListen=t.update.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.update.bind(e))}),this.continueListen.push.apply(this.continueListen,t.end.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.end.bind(e))})),this.continueListen.push.apply(this.continueListen,t.cancel.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.cancel.bind(e))})),{startListen:this.startListen,continueListen:this.continueListen}},e.prototype.activate=function(){return this.bind(this.config).startListen.map(function(t){return t()})},e.prototype.setPointers=function(t){},e.prototype.start=function(t){this.emit("start",t,this.pointers)},e.prototype.update=function(t){this.emit("update",t,this.pointers)},e.prototype.end=function(t){this.emit("end",t,this.pointers),0===this.allPointers.size&&this.stop()},e.prototype.cancel=function(t){this.emit("cancel",t,this.pointers),this.stop()},e.prototype.continue=function(){this.removeListeners=this.continueListen.map(function(t){return t()})},e.prototype.stop=function(){this.removeListeners.forEach(function(t){return t()}),this.removeListeners=[],this.emit("stop")},e}(r);e.Flow=s},function(t,e,n){"use strict";var i=n(0),r=n(2),o=function(){function t(t,e){void 0===e&&(e={}),this.options=t,this.selector="",this.listener=r.ensureProperties(e,{selector:"",down:function(t,e,n){},start:function(t,e,n){},update:function(t,e,n){},end:function(t,e,n){},cancel:function(){}})}return t.prototype.down=function(t,e,n){return r.RETURN_FLAG.map(this.listener.down(t,e,n))},t.prototype.start=function(t,e,n){var i=r.RETURN_FLAG.map(this.listener.start(t,e,n));return i&r.RETURN_FLAG.START_EMITTED||(i+=r.RETURN_FLAG.START_EMITTED),i},t.prototype.update=function(t,e,n){return r.RETURN_FLAG.map(this.listener.update(t,e,n))},t.prototype.end=function(t,e,n){return r.RETURN_FLAG.map(this.listener.end(t,e,n))},t.prototype.cancel=function(){return r.RETURN_FLAG.map(this.listener.cancel())},t}();e.Listener=o;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e}(o);e.DefaultListener=s},function(t,e,n){"use strict";var i=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){var e=this.x-t.x,n=this.y-t.y,i=Math.sqrt(e*e+n*n);return i},t.prototype.deltaAngleTo=function(t){var e=t.x-this.x,n=t.y-this.y,i=Math.atan2(n,e),r=180*i/Math.PI;return r},t.prototype.clone=function(){return new t(this.x,this.y)},t}();e.Point=i},function(t,e,n){"use strict";function i(t){t.registerGesture(a,u)}var r=n(0),o=n(1),s=n(5),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeThreshold=250,e}return r.__extends(e,t),e}(o.Options);e.DoubletapOptions=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeoutId=0,e.count=0,e}return r.__extends(e,t),e.prototype.bind=function(t,e,n){this.unregisterTap=e(s.Tap,t,{selector:this.listener.selector,options:this.listener.options,end:this.tapEnd.bind(this)}),this.remove=n},e.prototype.unbind=function(){return this.count>1?(this.unregisterTap(),o.RETURN_FLAG.REMOVE):o.RETURN_FLAG.COMPOSE},e.prototype.tapEnd=function(t,e){var n=this;if(++this.count,1===this.count)this.timeoutId=window.setTimeout(function(){n.remove(),n.unregisterTap()},this.listener.options.timeThreshold);else if(2===this.count)return window.clearTimeout(this.timeoutId),this.listener.end(t,e,this.target);return o.RETURN_FLAG.IDLE},e}(o.Gesture);e.Doubletap=a,e.registerDoubletap=i},function(t,e,n){"use strict";function i(t){t.registerGesture(c,a)}var r=n(0),o=n(1),s=n(3),u=n(4),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeThreshold=500,e}return r.__extends(e,t),e}(o.Options);e.LongtapSwipeOptions=a;var c=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowSwipe=!1,e}return r.__extends(e,t),e.prototype.bind=function(t,e,n){var i=this;this.unregisterLongtap=e(s.Longtap,t,{selector:this.listener.selector,options:this.listener.options,down:function(){return i.longtapDown()},timeEnd:function(){return i.longtapTimeEnd()}}),this.unregisterSwipe=e(u.Swipe,t,{selector:this.listener.selector,options:this.listener.options,down:function(t,e){return i.swipeDown(t,e)},start:function(t,e){return i.swipeStart(t,e)},update:function(t,e){return i.swipeUpdate(t,e)},end:function(t,e){return i.swipeEnd(t,e)},cancel:function(){return i.swipeCancel()}}),this.remove=n},e.prototype.longtapDown=function(){return this.allowSwipe=!1,o.RETURN_FLAG.IDLE},e.prototype.longtapTimeEnd=function(){return this.allowSwipe=!0,o.RETURN_FLAG.IDLE},e.prototype.swipeDown=function(t,e){return this.listener.down(t,e,this.target)},e.prototype.swipeStart=function(t,e){return this.allowSwipe?this.listener.start(t,e,this.target):(this.remove(),o.RETURN_FLAG.REMOVE)},e.prototype.swipeUpdate=function(t,e){return this.listener.update(t,e,this.target)},e.prototype.swipeEnd=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.swipeCancel=function(){return this.listener.cancel()},e}(o.Gesture);e.LongtapSwipe=c,e.registerLongtapSwipe=i},function(t,e,n){"use strict";function i(t){t.registerGesture(a,s,void 0,u)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.pointers=2,e.pinchThreshold=10,e}return r.__extends(e,t),e}(o.Options);e.PinchOptions=s;var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.distance=0,e.scale=0,e.delta=0,e.centerPoint=new o.Point(0,0),e}return r.__extends(e,t),e}(o.Data);e.PinchData=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.startDistance=0,e}return r.__extends(e,t),e.prototype.calculateDistance=function(t,e){return e.distanceTo(t)},e.prototype.calculateStartDistance=function(){return this.startDistance||(this.startDistance=this.calculateDistance(this.startPoint0,this.startPoint1))},e.prototype.calculateCurrentDistance=function(){return this.calculateDistance(this.currentPoint0,this.currentPoint1)},e.prototype.setData=function(t){this.currentPoint0=t.pointers[0].page,this.currentPoint1=t.pointers[1].page;var e=this.calculateStartDistance(),n=this.calculateCurrentDistance(),i=Math.abs(e-n);t.distance=i,t.scale=n/e,t.delta=n-e,t.centerPoint.x=(this.currentPoint0.x+this.currentPoint1.x)/2,t.centerPoint.y=(this.currentPoint0.y+this.currentPoint1.y)/2},e.prototype.start=function(t,e){return this.startPoint0=e.pointers[0].page,this.startPoint1=e.pointers[1].page,this.listener.down(t,e,this.target)},e.prototype.update=function(t,e){return this.setData(e),Math.abs(e.distance)<this.listener.options.pinchThreshold?o.RETURN_FLAG.IDLE:this.startEmitted?this.listener.update(t,e,this.target):this.listener.start(t,e,this.target)},e.prototype.end=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Pinch=a,e.registerPinch=i},function(t,e,n){"use strict";function i(t){t.registerGesture(a,s,void 0,u)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.pointers=2,e.rotationThreshold=10,e}return r.__extends(e,t),e}(o.Options);e.RotateOptions=s;var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.rotation=0,e}return r.__extends(e,t),e}(o.Data);e.RotateData=u;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.calculateRotation=function(t,e,n,i){var r=t.deltaAngleTo(e),o=n.deltaAngleTo(i);return o-r},e.prototype.setData=function(t){this.currentPoint0=t.pointers[0].page,this.currentPoint1=t.pointers[1].page,t.rotation=this.calculateRotation(this.startPoint0,this.startPoint1,this.currentPoint0,this.currentPoint1)},e.prototype.start=function(t,e){return this.startPoint0=e.pointers[0].page,this.startPoint1=e.pointers[1].page,this.listener.down(t,e,this.target)},e.prototype.update=function(t,e){return this.setData(e),Math.abs(e.rotation)<this.listener.options.rotationThreshold?o.RETURN_FLAG.IDLE:this.startEmitted?this.listener.update(t,e,this.target):this.listener.start(t,e,this.target)},e.prototype.end=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Rotate=a,e.registerRotate=i},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(8);e.PointerConfig={start:new r.EventConfig("pointerdown"),update:new r.EventConfig("pointermove"),end:new r.EventConfig("pointerup"),cancel:new r.EventConfig("pointercancel","dragstart")};var s=function(t){function n(n,i){return void 0===i&&(i=e.PointerConfig),t.call(this,n,i)||this}return i.__extends(n,t),n.prototype.setPointers=function(t){this.changedPointers.clear();var e=new o.Point(t.pageX,t.pageY),n=new o.Point(t.clientX,t.clientY),i=t.pointerId,r={page:e,client:n};switch(this.changedPointers.set(i,r),t.type){case"pointerdown":case"pointermove":this.allPointers.set(i,r);break;default:this.allPointers.delete(i)}},n}(r.Flow);e.PointerFlow=s},function(t,e,n){"use strict";var i=n(21),r=n(7),o=n(2),s=n(19),u=function(){function t(t,e){void 0===e&&(e=new i.Registry),this.element=t,this.registry=e,this.flows=[],this.activeFlow=null,this.handles=[],this.gestures=[],this.composedGestures=[]}return t.prototype.registerGesture=function(t,e,n,i){void 0===e&&(e=o.Options),void 0===n&&(n=r.Listener),void 0===i&&(i=o.Data),this.registry.register(t,e,n,i)},t.prototype.registerFlow=function(t){var e=this;this.flows.push(t),t.on("start",function(n,i){return e.onStart(t,n,i)}),t.on("update",function(n,i){return e.onUpdate(t,n,i)}),t.on("end",function(n,i){return e.onEnd(t,n,i)}),t.on("cancel",function(n,i){return e.onCancel(t,n,i)}),t.on("stop",function(){return e.onStop()})},t.prototype.registerListener=function(t,e,n){var i=this,r=new s.ListenerHandle(t,e,n);return this.handles.push(r),function(){var t=i.handles.indexOf(r);t!==-1&&i.handles.splice(t,1)}},t.prototype.activate=function(){return this.flows.map(function(t){return t.activate()})},t.prototype.canActivateFlow=function(t){return null===this.activeFlow||this.activeFlow===t},t.prototype.getPointersDelta=function(t,e,n,i){if(o.isMouse(t)&&!o.isValidMouseButton(t,i))return{all:-1,changed:-1};var r=e.all.size-n,s=e.changed.size-n;return{all:r,changed:s}},t.prototype.removeGesture=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];t.startEmitted&&t.cancel(),t.unbind();for(var i;i=e.shift();){var r=i.indexOf(t);r!==-1&&i.splice(r,1)}},t.prototype.evaluateStrategyReturnFlag=function(t,e,n){if(n&o.RETURN_FLAG.START_EMITTED&&(e.startEmitted=!0),n&o.RETURN_FLAG.REMOVE&&this.removeGesture(e,this.gestures,this.composedGestures),n&o.RETURN_FLAG.REMOVE_OTHERS)for(var i=this.gestures.slice(),r=void 0;r=i.shift();)e!==r&&this.removeGesture(r,t,this.gestures,this.composedGestures)},t.prototype.whileGestures=function(t,e,n,i){for(var r;r=e.shift();){var s=r.listener.options,u=s.pointers,a=s.which,c=s.strategy,p=this.getPointersDelta(t,n,u,a);if(p.all>0&&c===o.GESTURE_STRATEGY_FLAG.REMOVE_IF_POINTERS_GT)this.removeGesture(r,this.gestures,this.composedGestures);else{var h=i({evt:t,gestures:e,gesture:r,pointers:n,pointersDelta:p});this.evaluateStrategyReturnFlag(e,r,h)}}},t.prototype.addPointerId=function(t,e){t.__POINTERIDS__.push(e)},t.prototype.removePointerIds=function(t,e,n){for(var i,r=this.getPointerIds(e);i=n.shift();){var o=r.indexOf(i);if(o!==-1){var s=r.splice(o,1)[0],u=this.getPointer(t,s);e.__REMOVED_POINTERS__.push(u)}}},t.prototype.getPointerIds=function(t){return t.__POINTERIDS__},t.prototype.getRemovedPointers=function(t){return t.__REMOVED_POINTERS__},t.prototype.getPointer=function(t,e){return t.get(e)},t.prototype.getPointers=function(t,e){var n=this;return e.map(function(e){return n.getPointer(t,e)})},t.prototype.isLockedPointers=function(t,e){var n=this.getPointerIds(t);return n.filter(function(t){return e.has(t)}).length===e.size},t.prototype.startStrategy=function(t){var e=this;return 0!==t.pointersDelta.all?o.RETURN_FLAG.IDLE:(t.pointers.all.forEach(function(n,i){return e.addPointerId(t.gesture,i)}),t.gesture.data.pointers=this.getPointers(t.pointers.all,this.getPointerIds(t.gesture)),t.gesture.start(t.evt,t.gesture.data))},t.prototype.updateStrategy=function(t){return this.isLockedPointers(t.gesture,t.pointers.all)?(t.gesture.data.pointers=this.getPointers(t.pointers.all,this.getPointerIds(t.gesture)),t.gesture.update(t.evt,t.gesture.data)):o.RETURN_FLAG.IDLE},t.prototype.endStrategy=function(t){return t.gesture.startEmitted?(this.removePointerIds(t.pointers.changed,t.gesture,Array.from(t.pointers.changed.keys())),0!==this.getPointerIds(t.gesture).length?o.RETURN_FLAG.IDLE:(t.gesture.data.pointers=this.getRemovedPointers(t.gesture),t.gesture.end(t.evt,t.gesture.data))):o.RETURN_FLAG.REMOVE},t.prototype.cancelStrategy=function(t){return t.gesture.cancel()},t.prototype.onStart=function(t,e,n){return!!this.canActivateFlow(t)&&(this.activeFlow=t,this.activeFlow.continue(),this.gestures=this.gestures.concat(this.match(e.target,e)).sort(function(t,e){return t.listener.options.prio-e.listener.options.prio}),!!this.gestures.length&&(this.whileGestures(e,this.gestures.slice(),n,this.startStrategy.bind(this)),!0))},t.prototype.onUpdate=function(t,e,n){this.activeFlow===t&&this.whileGestures(e,this.gestures.slice(),n,this.updateStrategy.bind(this))},t.prototype.onEnd=function(t,e,n){this.activeFlow===t&&this.whileGestures(e,this.gestures.slice(),n,this.endStrategy.bind(this))},t.prototype.onCancel=function(t,e,n){this.activeFlow===t&&this.whileGestures(e,this.gestures.slice(),n,this.cancelStrategy.bind(this))},t.prototype.onStop=function(){for(var t,e=this.gestures.slice();t=e.shift();)o.RETURN_FLAG.COMPOSE===t.unbind()?this.composedGestures.push(t):t.stop();this.gestures.length=0,this.activeFlow=null},t.prototype.addGesture=function(t,e,n,i){var r=this.registry.create(t,e,n.listener);return r.bind(n.element,this.registerListener.bind(this),this.removeGesture.bind(this,r,this.gestures,this.composedGestures),i),r},t.prototype.composeGesture=function(t,e,n,i){for(var r;(r=this.composedGestures.shift())&&r.listener!==n.listener;);return r||(r=this.addGesture(t,e,n,i)),r},t.prototype.matchesHandle=function(t,e){var n=e.element,i=e.listener.selector;return!!n.contains(t)&&((!i||n!==t)&&(!(i&&!o.matchesSelector(t,i))&&!(!i&&t!==n)))},t.prototype.matchHandle=function(t,e,n,i){if(this.matchesHandle(e,n))return this.composeGesture(t,e,n,i)},t.prototype.matchHandles=function(t,e,n){for(var i=0,r=this.handles;i<r.length;i++){var o=r[i],s=this.matchHandle(o.Type,t,o,n);s&&e.push(s)}return e},t.prototype.match=function(t,e){for(var n=[],i=t;i&&1===i.nodeType&&i!==this.element;i=i.parentNode)this.matchHandles(i,n,e);return n},t}();e.Engine=u},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(8);e.MouseConfig={start:new r.EventConfig("mousedown"),update:new r.EventConfig("mousemove"),end:new r.EventConfig("mouseup"),cancel:new r.EventConfig("dragstart","contextmenu")};var s=function(t){function n(n){return t.call(this,n,e.MouseConfig)||this}return i.__extends(n,t),n.prototype.setPointers=function(t){var e=new o.Point(t.pageX,t.pageY),n=new o.Point(t.clientX,t.clientY);switch(this.changedPointers.set(1,{page:e,client:n}),t.type){case"mousedown":case"mousemove":this.allPointers.set(1,{page:e,client:n});break;default:this.allPointers.clear()}},n}(r.Flow);e.MouseFlow=s},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(13);e.MSPointerConfig={start:new r.EventConfig("MSPointerDown"),update:new r.EventConfig("MSPointerMove"),end:new r.EventConfig("MSPointerUp"),cancel:new r.EventConfig("MSPointerCancel","dragstart")};var s=function(t){function n(n){return t.call(this,n,e.MSPointerConfig)||this}return i.__extends(n,t),n}(o.PointerFlow);e.MSPointerFlow=s},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(8);e.TouchConfig={start:new r.EventConfig("touchstart"),update:new r.EventConfig("touchmove"),end:new r.EventConfig("touchend"),cancel:new r.EventConfig("touchcancel","dragstart")};var s=function(t){function n(n){return t.call(this,n,e.TouchConfig)||this}return i.__extends(n,t),n.prototype.setPointerMapFromList=function(t,e){var n,i=t.length;for(n=0;n<i;++n){var r=t[n],s=new o.Point(r.pageX,r.pageY),u=new o.Point(r.clientX,r.clientY),a=r.identifier,c={page:s,client:u};e.set(a,c)}},n.prototype.setPointers=function(t){this.allPointers.clear(),this.changedPointers.clear(),this.setPointerMapFromList(t.touches,this.allPointers),this.setPointerMapFromList(t.changedTouches,this.changedPointers)},n}(r.Flow);e.TouchFlow=s},function(t,e,n){"use strict";var i=n(0),r=function(){function t(t,e,n){this.listener=t,this.data=e,this.target=n,this.__POINTERIDS__=[],this.__REMOVED_POINTERS__=[],this.startEmitted=!1}return t.prototype.bind=function(){},t.prototype.unbind=function(){return 0},t.prototype.start=function(){return 0},t.prototype.update=function(){return 0},t.prototype.end=function(){return 0},t.prototype.cancel=function(){return 0},t.prototype.stop=function(){},t}();e.Gesture=r;var o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e}(r);e.DefaultGesture=o},function(t,e,n){"use strict";var i=function(){function t(t,e,n){this.Type=t,this.element=e,this.listener=n}return t}();e.ListenerHandle=i},function(t,e,n){"use strict";var i=n(14),r=n(16),o=n(13),s=n(17),u=n(15),a=n(7),c=n(2),p=function(){function t(t){void 0===t&&(t=window&&window.document),this.element=t,this.deactivateFlows=null,this.engine=new i.Engine(this.element)}return t.prototype.registerDefaultFlowStrategy=function(t){void 0===t&&(t=c.SUPPORTS),t.msPointerEnabled&&this.engine.registerFlow(new r.MSPointerFlow(this.element)),t.pointerEnabled&&this.engine.registerFlow(new o.PointerFlow(this.element)),t.touchEnabled&&this.engine.registerFlow(new s.TouchFlow(this.element)),this.engine.registerFlow(new u.MouseFlow(this.element))},t.prototype.registerGesture=function(t,e,n,i){void 0===e&&(e=c.Options),void 0===n&&(n=a.Listener),void 0===i&&(i=c.Data),this.engine.registerGesture(t,e,n,i)},t.prototype.activate=function(){this.deactivateFlows=this.engine.activate()},t.prototype.deactivate=function(){this.deactivateFlows&&(this.deactivateFlows.forEach(function(t){return t.forEach(function(t){return t()})}),this.deactivateFlows=null)},t.prototype.on=function(t,e,n){return this.engine.registerListener(t,e,n)},t}();e.OribellaApi=p},function(t,e,n){"use strict";var i=n(7),r=n(2),o=function(){function t(){this.gestures=new Map}return t.prototype.register=function(t,e,n,o){void 0===e&&(e=r.Options),void 0===n&&(n=i.Listener),void 0===o&&(o=r.Data),this.gestures.set(t,{Gesture:t,GestureOptions:e,GestureListener:n,GestureData:o})},t.prototype.getTypes=function(){return Array.from(this.gestures.keys())},t.prototype.create=function(t,e,n){var i=this.gestures.get(t);if(!i)throw new Error("The type "+typeof t+" has not been registered");var r=Object.assign(new i.GestureOptions,n.options);return new i.Gesture(new i.GestureListener(r,n),new i.GestureData,e)},t}();e.Registry=o},function(t,e,n){"use strict";function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var r=n(1),o=n(5),s=n(9),u=n(3),a=n(4),c=n(10),p=n(12),h=n(11);i(n(1)),e.oribella=new r.OribellaApi,i(n(5)),i(n(9)),i(n(3)),i(n(4)),i(n(10)),i(n(12)),i(n(11)),e.oribella.registerDefaultFlowStrategy(),e.oribella.activate(),o.registerTap(e.oribella),s.registerDoubletap(e.oribella),u.registerLongtap(e.oribella),a.registerSwipe(e.oribella),c.registerLongtapSwipe(e.oribella),p.registerRotate(e.oribella),h.registerPinch(e.oribella)}])}); | ||
var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},h=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}},function(t,e,n){"use strict";function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}i(n(8)),i(n(2)),i(n(7)),i(n(18)),i(n(20))},function(t,e,n){"use strict";function i(t,n){return void 0===n&&(n=e.SUPPORTS),!(!n.msPointerEnabled||t.pointerType!==t.MSPOINTER_TYPE_MOUSE)||(!(!n.pointerEnabled||"mouse"!==t.pointerType)||t.type.indexOf("mouse")!==-1)}function r(t,e){var n=t.button,i=t.which,r=i||void 0===n?i:1&n?1:2&n?3:4&n?2:0;return Array.isArray(e)?e.some(function(t){return r===t}):r===e}function o(t,e){return(t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector).call(t,e)}function s(t,e){for(var n in e)e[n]&&!t[n]&&(t[n]=e[n]);return t}var u=n(0);e.GESTURE_STRATEGY_FLAG={KEEP:0,REMOVE_IF_POINTERS_GT:1},e.RETURN_FLAG={map:function(t){switch(t){case!0:t=this.REMOVE_OTHERS;break;case!1:t=this.REMOVE;break;case 1:case 2:case 4:break;default:t=0}return t},IDLE:0,START_EMITTED:1,REMOVE:2,REMOVE_OTHERS:4,REMOVE_AND_CONTINUE:8,COMPOSE:16},e.SUPPORTS={get touchEnabled(){return"ontouchstart"in window},get pointerEnabled(){return window&&window.navigator.pointerEnabled},get msPointerEnabled(){return window&&window.navigator.msPointerEnabled}},e.isMouse=i,e.isValidMouseButton=r,e.matchesSelector=o;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u.__extends(e,t),e}(Map);e.PointerDataMap=a;var c=function(){function t(){this.pointers=1,this.which=1,this.prio=100,this.strategy=e.GESTURE_STRATEGY_FLAG.KEEP}return t}();e.Options=c;var p=function(){function t(){}return t}();e.Data=p,e.ensureProperties=s},function(t,e,n){"use strict";function i(t){t.registerGesture(a,s,u)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.radiusThreshold=2,e.timeThreshold=500,e}return r.__extends(e,t),e}(o.Options);e.LongtapOptions=s;var u=function(t){function e(e,n){var i=t.call(this,e,n)||this;return i.options=e,i.listener=o.ensureProperties(n,{timeEnd:function(){}}),i}return r.__extends(e,t),e.prototype.timeEnd=function(){return o.RETURN_FLAG.map(this.listener.timeEnd())},e}(o.Listener);e.LongtapListener=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeoutId=0,e.timeEndEmitted=!1,e}return r.__extends(e,t),e.prototype.start=function(t,e){var n=this;return this.startPoint=e.pointers[0].page,this.timeoutId=window.setTimeout(function(){n.listener.timeEnd(),n.timeEndEmitted=!0},this.listener.options.timeThreshold),this.listener.start(t,e,this.target)},e.prototype.update=function(t,e){var n=e.pointers[0].page;return n.distanceTo(this.startPoint)>this.listener.options.radiusThreshold?o.RETURN_FLAG.REMOVE:o.RETURN_FLAG.IDLE},e.prototype.end=function(t,e){return window.clearTimeout(this.timeoutId),this.timeEndEmitted?this.listener.end(t,e,this.target):o.RETURN_FLAG.REMOVE},e.prototype.cancel=function(){return window.clearTimeout(this.timeoutId),this.listener.cancel()},e}(o.Gesture);e.Longtap=a,e.registerLongtap=i},function(t,e,n){"use strict";function i(t){t.registerGesture(c,a,void 0,u)}var r=n(0),o=n(1),s=function(){function t(t,e){this.point=t,this.timeStamp=e}return t}();e.Observation=s;var u=function(t){function e(e){void 0===e&&(e=5);var n=t.call(this)||this;return n.maxObservations=e,n.timeSeries=[],n}return r.__extends(e,t),e.prototype.add=function(t,e){this.timeSeries.length===this.maxObservations&&this.timeSeries.shift(),this.timeSeries.push(new s(t,e))},e}(o.Data);e.SwipeData=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.radiusThreshold=2,e}return r.__extends(e,t),e}(o.Options);e.SwipeOptions=a;var c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.start=function(t,e){return this.startPoint=e.pointers[0].page,e.add(this.startPoint,t.timeStamp),this.listener.down(t,e,this.target)},e.prototype.update=function(t,e){var n=e.pointers[0].page;return n.distanceTo(this.startPoint)<this.listener.options.radiusThreshold?o.RETURN_FLAG.IDLE:(e.add(n,t.timeStamp),this.startEmitted?this.listener.update(t,e,this.target):this.listener.start(t,e,this.target))},e.prototype.end=function(t,e){var n=e.pointers[0].page;return e.add(n,t.timeStamp),this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Swipe=c,e.registerSwipe=i},function(t,e,n){"use strict";function i(t){t.registerGesture(u,s)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.radiusThreshold=2,e}return r.__extends(e,t),e}(o.Options);e.TapOptions=s;var u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.start=function(t,e){return this.startPoint=e.pointers[0].page,this.listener.start(t,e,this.target)},e.prototype.update=function(t,e){var n=e.pointers[0].page;return n.distanceTo(this.startPoint)>this.listener.options.radiusThreshold?o.RETURN_FLAG.REMOVE:o.RETURN_FLAG.IDLE},e.prototype.end=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Tap=u,e.registerTap=i},function(t,e,n){"use strict";var i=n(0),r=function(){function t(){this.listenerMap=new Map}return t.prototype.on=function(t,e){var n=this.listenerMap.get(t)||[];return n.push(e),this.listenerMap.set(t,n),this},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var i=this.listenerMap.get(t)||[];return i.forEach(function(t){return t.apply(null,e)}),!0},t}();e.EventEmitter=r;var o=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.events=t}return t.prototype.getEvents=function(){return this.events},t}();e.EventConfig=o;var s=function(t){function e(e,n){var i=t.call(this)||this;return i.element=e,i.startListen=[],i.continueListen=[],i.removeListeners=[],i.allPointers=new Map,i.changedPointers=new Map,i.pointers={all:i.allPointers,changed:i.changedPointers},i.config=n,i}return i.__extends(e,t),e.prototype.proxy=function(t,e){this.setPointers(e),t(e)},e.prototype.addDOMEventListener=function(t,e,n){var i=this.proxy.bind(this,n);return t.addEventListener(e,i,!1),this.removeDOMEventListener.bind(this,t,e,i)},e.prototype.removeDOMEventListener=function(t,e,n){t.removeEventListener(e,n,!1)},e.prototype.bind=function(t){var e=this;return this.startListen=t.start.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.start.bind(e))}),this.continueListen=t.update.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.update.bind(e))}),this.continueListen.push.apply(this.continueListen,t.end.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.end.bind(e))})),this.continueListen.push.apply(this.continueListen,t.cancel.getEvents().map(function(t){return e.addDOMEventListener.bind(e,e.element,t,e.cancel.bind(e))})),{startListen:this.startListen,continueListen:this.continueListen}},e.prototype.activate=function(){return this.bind(this.config).startListen.map(function(t){return t()})},e.prototype.setPointers=function(t){},e.prototype.start=function(t){this.emit("start",t,this.pointers)},e.prototype.update=function(t){this.emit("update",t,this.pointers)},e.prototype.end=function(t){this.emit("end",t,this.pointers),0===this.allPointers.size&&this.stop()},e.prototype.cancel=function(t){this.emit("cancel",t,this.pointers),this.stop()},e.prototype.continue=function(){this.removeListeners=this.continueListen.map(function(t){return t()})},e.prototype.stop=function(){this.removeListeners.forEach(function(t){return t()}),this.removeListeners=[],this.emit("stop")},e}(r);e.Flow=s},function(t,e,n){"use strict";var i=n(0),r=n(2),o=function(){function t(t,e){void 0===e&&(e={}),this.options=t,this.selector="",this.listener=r.ensureProperties(e,{selector:"",down:function(t,e,n){},start:function(t,e,n){},update:function(t,e,n){},end:function(t,e,n){},cancel:function(){}})}return t.prototype.down=function(t,e,n){return r.RETURN_FLAG.map(this.listener.down(t,e,n))},t.prototype.start=function(t,e,n){var i=r.RETURN_FLAG.map(this.listener.start(t,e,n));return i&r.RETURN_FLAG.START_EMITTED||(i+=r.RETURN_FLAG.START_EMITTED),i},t.prototype.update=function(t,e,n){return r.RETURN_FLAG.map(this.listener.update(t,e,n))},t.prototype.end=function(t,e,n){return r.RETURN_FLAG.map(this.listener.end(t,e,n))},t.prototype.cancel=function(){return r.RETURN_FLAG.map(this.listener.cancel())},t}();e.Listener=o;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e}(o);e.DefaultListener=s},function(t,e,n){"use strict";var i=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){var e=this.x-t.x,n=this.y-t.y,i=Math.sqrt(e*e+n*n);return i},t.prototype.deltaAngleTo=function(t){var e=t.x-this.x,n=t.y-this.y,i=Math.atan2(n,e),r=180*i/Math.PI;return r},t.prototype.clone=function(){return new t(this.x,this.y)},t}();e.Point=i},function(t,e,n){"use strict";function i(t){t.registerGesture(a,u)}var r=n(0),o=n(1),s=n(5),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeThreshold=250,e}return r.__extends(e,t),e}(o.Options);e.DoubletapOptions=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeoutId=0,e.count=0,e}return r.__extends(e,t),e.prototype.bind=function(t,e,n){this.unregisterTap=e(s.Tap,t,{selector:this.listener.selector,options:this.listener.options,end:this.tapEnd.bind(this)}),this.remove=n},e.prototype.unbind=function(){return this.count>1?(this.unregisterTap(),o.RETURN_FLAG.REMOVE):o.RETURN_FLAG.COMPOSE},e.prototype.tapEnd=function(t,e){var n=this;if(++this.count,1===this.count)this.timeoutId=window.setTimeout(function(){n.remove(),n.unregisterTap()},this.listener.options.timeThreshold);else if(2===this.count)return window.clearTimeout(this.timeoutId),this.listener.end(t,e,this.target);return o.RETURN_FLAG.IDLE},e}(o.Gesture);e.Doubletap=a,e.registerDoubletap=i},function(t,e,n){"use strict";function i(t){t.registerGesture(c,a)}var r=n(0),o=n(1),s=n(3),u=n(4),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeThreshold=500,e}return r.__extends(e,t),e}(o.Options);e.LongtapSwipeOptions=a;var c=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allowSwipe=!1,e}return r.__extends(e,t),e.prototype.bind=function(t,e,n){var i=this;this.unregisterLongtap=e(s.Longtap,t,{selector:this.listener.selector,options:this.listener.options,down:function(){return i.longtapDown()},timeEnd:function(){return i.longtapTimeEnd()}}),this.unregisterSwipe=e(u.Swipe,t,{selector:this.listener.selector,options:this.listener.options,down:function(t,e){return i.swipeDown(t,e)},start:function(t,e){return i.swipeStart(t,e)},update:function(t,e){return i.swipeUpdate(t,e)},end:function(t,e){return i.swipeEnd(t,e)},cancel:function(){return i.swipeCancel()}}),this.remove=n},e.prototype.longtapDown=function(){return this.allowSwipe=!1,o.RETURN_FLAG.IDLE},e.prototype.longtapTimeEnd=function(){return this.allowSwipe=!0,o.RETURN_FLAG.IDLE},e.prototype.swipeDown=function(t,e){return this.listener.down(t,e,this.target)},e.prototype.swipeStart=function(t,e){return this.allowSwipe?this.listener.start(t,e,this.target):(this.remove(),o.RETURN_FLAG.REMOVE)},e.prototype.swipeUpdate=function(t,e){return this.listener.update(t,e,this.target)},e.prototype.swipeEnd=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.swipeCancel=function(){return this.listener.cancel()},e}(o.Gesture);e.LongtapSwipe=c,e.registerLongtapSwipe=i},function(t,e,n){"use strict";function i(t){t.registerGesture(a,s,void 0,u)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.pointers=2,e.pinchThreshold=10,e}return r.__extends(e,t),e}(o.Options);e.PinchOptions=s;var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.distance=0,e.scale=0,e.delta=0,e.centerPoint=new o.Point(0,0),e}return r.__extends(e,t),e}(o.Data);e.PinchData=u;var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.startDistance=0,e}return r.__extends(e,t),e.prototype.calculateDistance=function(t,e){return e.distanceTo(t)},e.prototype.calculateStartDistance=function(){return this.startDistance||(this.startDistance=this.calculateDistance(this.startPoint0,this.startPoint1))},e.prototype.calculateCurrentDistance=function(){return this.calculateDistance(this.currentPoint0,this.currentPoint1)},e.prototype.setData=function(t){this.currentPoint0=t.pointers[0].page,this.currentPoint1=t.pointers[1].page;var e=this.calculateStartDistance(),n=this.calculateCurrentDistance(),i=Math.abs(e-n);t.distance=i,t.scale=n/e,t.delta=n-e,t.centerPoint.x=(this.currentPoint0.x+this.currentPoint1.x)/2,t.centerPoint.y=(this.currentPoint0.y+this.currentPoint1.y)/2},e.prototype.start=function(t,e){return this.startPoint0=e.pointers[0].page,this.startPoint1=e.pointers[1].page,this.listener.down(t,e,this.target)},e.prototype.update=function(t,e){return this.setData(e),Math.abs(e.distance)<this.listener.options.pinchThreshold?o.RETURN_FLAG.IDLE:this.startEmitted?this.listener.update(t,e,this.target):this.listener.start(t,e,this.target)},e.prototype.end=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Pinch=a,e.registerPinch=i},function(t,e,n){"use strict";function i(t){t.registerGesture(a,s,void 0,u)}var r=n(0),o=n(1),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.pointers=2,e.rotationThreshold=10,e}return r.__extends(e,t),e}(o.Options);e.RotateOptions=s;var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.rotation=0,e}return r.__extends(e,t),e}(o.Data);e.RotateData=u;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.calculateRotation=function(t,e,n,i){var r=t.deltaAngleTo(e),o=n.deltaAngleTo(i);return o-r},e.prototype.setData=function(t){this.currentPoint0=t.pointers[0].page,this.currentPoint1=t.pointers[1].page,t.rotation=this.calculateRotation(this.startPoint0,this.startPoint1,this.currentPoint0,this.currentPoint1)},e.prototype.start=function(t,e){return this.startPoint0=e.pointers[0].page,this.startPoint1=e.pointers[1].page,this.listener.down(t,e,this.target)},e.prototype.update=function(t,e){return this.setData(e),Math.abs(e.rotation)<this.listener.options.rotationThreshold?o.RETURN_FLAG.IDLE:this.startEmitted?this.listener.update(t,e,this.target):this.listener.start(t,e,this.target)},e.prototype.end=function(t,e){return this.listener.end(t,e,this.target)},e.prototype.cancel=function(){return this.listener.cancel()},e}(o.Gesture);e.Rotate=a,e.registerRotate=i},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(8);e.PointerConfig={start:new r.EventConfig("pointerdown"),update:new r.EventConfig("pointermove"),end:new r.EventConfig("pointerup"),cancel:new r.EventConfig("pointercancel","dragstart")};var s=function(t){function n(n,i){return void 0===i&&(i=e.PointerConfig),t.call(this,n,i)||this}return i.__extends(n,t),n.prototype.setPointers=function(t){this.changedPointers.clear();var e=new o.Point(t.pageX,t.pageY),n=new o.Point(t.clientX,t.clientY),i=t.pointerId,r={page:e,client:n};switch(this.changedPointers.set(i,r),t.type){case"pointerdown":case"pointermove":this.allPointers.set(i,r);break;default:this.allPointers.delete(i)}},n}(r.Flow);e.PointerFlow=s},function(t,e,n){"use strict";var i=n(21),r=n(7),o=n(2),s=n(19),u=function(){function t(t,e){void 0===e&&(e=new i.Registry),this.element=t,this.registry=e,this.flows=[],this.activeFlow=null,this.handles=[],this.gestures=[],this.composedGestures=[]}return t.prototype.registerGesture=function(t,e,n,i){void 0===e&&(e=o.Options),void 0===n&&(n=r.Listener),void 0===i&&(i=o.Data),this.registry.register(t,e,n,i)},t.prototype.registerFlow=function(t){var e=this;this.flows.push(t),t.on("start",function(n,i){return e.onStart(t,n,i)}),t.on("update",function(n,i){return e.onUpdate(t,n,i)}),t.on("end",function(n,i){return e.onEnd(t,n,i)}),t.on("cancel",function(n,i){return e.onCancel(t,n,i)}),t.on("stop",function(){return e.onStop()})},t.prototype.registerListener=function(t,e,n){var i=this,r=new s.ListenerHandle(t,e,n);return this.handles.push(r),function(){var t=i.handles.indexOf(r);t!==-1&&i.handles.splice(t,1)}},t.prototype.activate=function(){return this.flows.map(function(t){return t.activate()})},t.prototype.canActivateFlow=function(t){return null===this.activeFlow||this.activeFlow===t},t.prototype.getPointersDelta=function(t,e,n,i){if(o.isMouse(t)&&!o.isValidMouseButton(t,i))return{all:-1,changed:-1};var r=e.all.size-n,s=e.changed.size-n;return{all:r,changed:s}},t.prototype.removeGesture=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];t.startEmitted&&t.cancel(),t.unbind();for(var i;i=e.shift();){var r=i.indexOf(t);r!==-1&&i.splice(r,1)}},t.prototype.evaluateStrategyReturnFlag=function(t,e,n){if(n&o.RETURN_FLAG.START_EMITTED&&(e.startEmitted=!0),n&o.RETURN_FLAG.REMOVE&&this.removeGesture(e,this.gestures,this.composedGestures),n&o.RETURN_FLAG.REMOVE_OTHERS)for(var i=this.gestures.slice(),r=void 0;r=i.shift();)e!==r&&this.removeGesture(r,t,this.gestures,this.composedGestures)},t.prototype.whileGestures=function(t,e,n,i){for(var r;r=e.shift();){var s=r.listener.options,u=s.pointers,a=s.which,c=s.strategy,p=this.getPointersDelta(t,n,u,a);if(p.all>0&&c===o.GESTURE_STRATEGY_FLAG.REMOVE_IF_POINTERS_GT)this.removeGesture(r,this.gestures,this.composedGestures);else{var h=i({evt:t,gestures:e,gesture:r,pointers:n,pointersDelta:p});this.evaluateStrategyReturnFlag(e,r,h)}}},t.prototype.addPointerId=function(t,e){t.__POINTERIDS__.push(e)},t.prototype.removePointerIds=function(t,e,n){for(var i,r=this.getPointerIds(e);i=n.shift();){var o=r.indexOf(i);if(o!==-1){var s=r.splice(o,1)[0],u=this.getPointer(t,s);e.__REMOVED_POINTERS__.push(u)}}},t.prototype.getPointerIds=function(t){return t.__POINTERIDS__},t.prototype.getRemovedPointers=function(t){return t.__REMOVED_POINTERS__},t.prototype.getPointer=function(t,e){return t.get(e)},t.prototype.getPointers=function(t,e){var n=this;return e.map(function(e){return n.getPointer(t,e)})},t.prototype.isLockedPointers=function(t,e){var n=this.getPointerIds(t);return n.filter(function(t){return e.has(t)}).length===e.size},t.prototype.startStrategy=function(t){var e=this;return 0!==t.pointersDelta.all?o.RETURN_FLAG.IDLE:(t.pointers.all.forEach(function(n,i){return e.addPointerId(t.gesture,i)}),t.gesture.data.pointers=this.getPointers(t.pointers.all,this.getPointerIds(t.gesture)),t.gesture.start(t.evt,t.gesture.data))},t.prototype.updateStrategy=function(t){return this.isLockedPointers(t.gesture,t.pointers.all)?(t.gesture.data.pointers=this.getPointers(t.pointers.all,this.getPointerIds(t.gesture)),t.gesture.update(t.evt,t.gesture.data)):o.RETURN_FLAG.IDLE},t.prototype.endStrategy=function(t){return t.gesture.startEmitted?(this.removePointerIds(t.pointers.changed,t.gesture,Array.from(t.pointers.changed.keys())),0!==this.getPointerIds(t.gesture).length?o.RETURN_FLAG.IDLE:(t.gesture.data.pointers=this.getRemovedPointers(t.gesture),t.gesture.end(t.evt,t.gesture.data))):o.RETURN_FLAG.REMOVE},t.prototype.cancelStrategy=function(t){return t.gesture.cancel()},t.prototype.onStart=function(t,e,n){return!!this.canActivateFlow(t)&&(this.activeFlow=t,this.activeFlow.continue(),this.gestures=this.gestures.concat(this.match(e.target,e)).sort(function(t,e){return t.listener.options.prio-e.listener.options.prio}),!!this.gestures.length&&(this.whileGestures(e,this.gestures.slice(),n,this.startStrategy.bind(this)),!0))},t.prototype.onUpdate=function(t,e,n){this.activeFlow===t&&this.whileGestures(e,this.gestures.slice(),n,this.updateStrategy.bind(this))},t.prototype.onEnd=function(t,e,n){this.activeFlow===t&&this.whileGestures(e,this.gestures.slice(),n,this.endStrategy.bind(this))},t.prototype.onCancel=function(t,e,n){this.activeFlow===t&&this.whileGestures(e,this.gestures.slice(),n,this.cancelStrategy.bind(this))},t.prototype.onStop=function(){for(var t,e=this.gestures.slice();t=e.shift();)o.RETURN_FLAG.COMPOSE===t.unbind()?this.composedGestures.push(t):t.stop();this.gestures.length=0,this.activeFlow=null},t.prototype.addGesture=function(t,e,n,i){var r=this.registry.create(t,e,n.listener);return r.bind(n.element,this.registerListener.bind(this),this.removeGesture.bind(this,r,this.gestures,this.composedGestures),i),r},t.prototype.composeGesture=function(t,e,n,i){for(var r;(r=this.composedGestures.shift())&&r.listener!==n.listener;);return r||(r=this.addGesture(t,e,n,i)),r},t.prototype.matchesHandle=function(t,e){var n=e.element,i=e.listener.selector;return!!n.contains(t)&&((!i||n!==t)&&(!(i&&!o.matchesSelector(t,i))&&!(!i&&t!==n)))},t.prototype.matchHandle=function(t,e,n,i){if(this.matchesHandle(e,n))return this.composeGesture(t,e,n,i)},t.prototype.matchHandles=function(t,e,n){for(var i=0,r=this.handles;i<r.length;i++){var o=r[i],s=this.matchHandle(o.Type,t,o,n);s&&e.push(s)}return e},t.prototype.match=function(t,e){for(var n=[],i=t;i&&1===i.nodeType&&i!==this.element;i=i.parentNode)this.matchHandles(i,n,e);return n},t}();e.Engine=u},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(8);e.MouseConfig={start:new r.EventConfig("mousedown"),update:new r.EventConfig("mousemove"),end:new r.EventConfig("mouseup"),cancel:new r.EventConfig("dragstart","contextmenu")};var s=function(t){function n(n){return t.call(this,n,e.MouseConfig)||this}return i.__extends(n,t),n.prototype.setPointers=function(t){var e=new o.Point(t.pageX,t.pageY),n=new o.Point(t.clientX,t.clientY);switch(this.changedPointers.set(1,{page:e,client:n}),t.type){case"mousedown":case"mousemove":this.allPointers.set(1,{page:e,client:n});break;default:this.allPointers.clear()}},n}(r.Flow);e.MouseFlow=s},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(13);e.MSPointerConfig={start:new r.EventConfig("MSPointerDown"),update:new r.EventConfig("MSPointerMove"),end:new r.EventConfig("MSPointerUp"),cancel:new r.EventConfig("MSPointerCancel","dragstart")};var s=function(t){function n(n){return t.call(this,n,e.MSPointerConfig)||this}return i.__extends(n,t),n}(o.PointerFlow);e.MSPointerFlow=s},function(t,e,n){"use strict";var i=n(0),r=n(6),o=n(8);e.TouchConfig={start:new r.EventConfig("touchstart"),update:new r.EventConfig("touchmove"),end:new r.EventConfig("touchend"),cancel:new r.EventConfig("touchcancel","dragstart")};var s=function(t){function n(n){return t.call(this,n,e.TouchConfig)||this}return i.__extends(n,t),n.prototype.setPointerMapFromList=function(t,e){var n,i=t.length;for(n=0;n<i;++n){var r=t[n],s=new o.Point(r.pageX,r.pageY),u=new o.Point(r.clientX,r.clientY),a=r.identifier,c={page:s,client:u};e.set(a,c)}},n.prototype.setPointers=function(t){this.allPointers.clear(),this.changedPointers.clear(),this.setPointerMapFromList(t.touches,this.allPointers),this.setPointerMapFromList(t.changedTouches,this.changedPointers)},n}(r.Flow);e.TouchFlow=s},function(t,e,n){"use strict";var i=n(0),r=function(){function t(t,e,n){this.listener=t,this.data=e,this.target=n,this.__POINTERIDS__=[],this.__REMOVED_POINTERS__=[],this.startEmitted=!1}return t.prototype.bind=function(){},t.prototype.unbind=function(){return 0},t.prototype.start=function(){return 0},t.prototype.update=function(){return 0},t.prototype.end=function(){return 0},t.prototype.cancel=function(){return 0},t.prototype.stop=function(){},t}();e.Gesture=r;var o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e}(r);e.DefaultGesture=o},function(t,e,n){"use strict";var i=function(){function t(t,e,n){this.Type=t,this.element=e,this.listener=n}return t}();e.ListenerHandle=i},function(t,e,n){"use strict";var i=n(14),r=n(16),o=n(13),s=n(17),u=n(15),a=n(7),c=n(2),p=function(){function t(t){void 0===t&&(t=window&&window.document),this.element=t,this.deactivateFlows=null,this.engine=new i.Engine(this.element)}return t.prototype.registerDefaultFlowStrategy=function(t){void 0===t&&(t=c.SUPPORTS),t.msPointerEnabled&&this.engine.registerFlow(new r.MSPointerFlow(this.element)),t.pointerEnabled&&this.engine.registerFlow(new o.PointerFlow(this.element)),t.touchEnabled&&this.engine.registerFlow(new s.TouchFlow(this.element)),this.engine.registerFlow(new u.MouseFlow(this.element))},t.prototype.registerGesture=function(t,e,n,i){void 0===e&&(e=c.Options),void 0===n&&(n=a.Listener),void 0===i&&(i=c.Data),this.engine.registerGesture(t,e,n,i)},t.prototype.activate=function(){this.deactivateFlows=this.engine.activate()},t.prototype.deactivate=function(){this.deactivateFlows&&(this.deactivateFlows.forEach(function(t){return t.forEach(function(t){return t()})}),this.deactivateFlows=null)},t.prototype.on=function(t,e,n){return this.engine.registerListener(t,e,n)},t}();e.OribellaApi=p},function(t,e,n){"use strict";var i=n(7),r=n(2),o=function(){function t(){this.gestures=new Map}return t.prototype.register=function(t,e,n,o){void 0===e&&(e=r.Options),void 0===n&&(n=i.Listener),void 0===o&&(o=r.Data),this.gestures.set(t,{Gesture:t,GestureOptions:e,GestureListener:n,GestureData:o})},t.prototype.getTypes=function(){return Array.from(this.gestures.keys())},t.prototype.create=function(t,e,n){var i=this.gestures.get(t);if(!i)throw new Error("The type "+typeof t+" has not been registered");var r=Object.assign(new i.GestureOptions,n.options);return new i.Gesture(new i.GestureListener(r,n),new i.GestureData,e)},t}();e.Registry=o},function(t,e,n){"use strict";function i(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}var r=n(1),o=n(5),s=n(9),u=n(3),a=n(4),c=n(10),p=n(12),h=n(11);i(n(1)),e.oribella=new r.OribellaApi,i(n(5)),i(n(9)),i(n(3)),i(n(4)),i(n(10)),i(n(12)),i(n(11)),e.oribella.registerDefaultFlowStrategy(),e.oribella.activate(),o.registerTap(e.oribella),s.registerDoubletap(e.oribella),u.registerLongtap(e.oribella),a.registerSwipe(e.oribella),c.registerLongtapSwipe(e.oribella),p.registerRotate(e.oribella),h.registerPinch(e.oribella)}])}); | ||
//# sourceMappingURL=oribella.js.map |
@@ -35,5 +35,5 @@ System.register(["tslib", "oribella-framework"], function (exports_1, context_1) { | ||
_this.options = options; | ||
_this.listener = Object.assign({ | ||
_this.listener = oribella_framework_1.ensureProperties(listener, { | ||
timeEnd: function () { } | ||
}, _this.listener); | ||
}); | ||
return _this; | ||
@@ -40,0 +40,0 @@ } |
{ | ||
"name": "oribella", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "A set of preconfigured gestures like tap, longtap, doubletap, swipe, longtap-swipe, pinch, rotate", | ||
@@ -68,3 +68,3 @@ "repository": { | ||
"dependencies": { | ||
"oribella-framework": "^0.8.0" | ||
"oribella-framework": "^0.8.1" | ||
}, | ||
@@ -71,0 +71,0 @@ "nyc": { |
@@ -1,2 +0,2 @@ | ||
import { OribellaApi, Options, Data, RETURN_FLAG, Gesture, Listener, Point } from 'oribella-framework'; | ||
import { OribellaApi, Options, Data, RETURN_FLAG, Gesture, Listener, Point, ensureProperties } from 'oribella-framework'; | ||
@@ -12,5 +12,5 @@ export class LongtapOptions extends Options { | ||
super(options, listener); | ||
this.listener = Object.assign({ | ||
this.listener = ensureProperties(listener, { | ||
timeEnd() { } | ||
} as LongtapListener, this.listener); | ||
} as LongtapListener); | ||
} | ||
@@ -17,0 +17,0 @@ public timeEnd(): number { return RETURN_FLAG.map(this.listener.timeEnd()); } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
712903
Updatedoribella-framework@^0.8.1