You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
10 KiB
23 lines
10 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("exports ../../chunks/tslib.es6 ../../core/Accessor ../../core/has ../../core/Logger ../../core/Queue ../../core/accessorSupport/decorators/property ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../3d/support/PropertiesPool ./keys ./handlers/LatestPointer ./handlers/MultiTouch".split(" "),function(g,k,r,E,t,p,l,F,u,v,q,w,x){g.InputManager=class extends r{constructor(a){super(a);this._pointerCaptures=new Map;this._nameToGroup={};this._handlers=[];this._handlersPriority= |
|
[];this._currentPropagation=null;this._updateDependenciesAfterPropagation=!1;this._sourceEvents=new Set;this._keyModifiers=new Set;this._activeKeyModifiers=new Set;this._stoppedPropagationEventIds=new Set;this.primaryKey=q.primaryKey;this._latestPointerType="mouse";this._propertiesPool=new v.PropertiesPool({latestPointerLocation:y},this);this.latestPointerLocation=null;this._paused=!1;this.test={timestamp:void 0,hasCurrentPropagation:()=>!!this._currentPropagation}}initialize(){this.eventSource.onEventReceived= |
|
this._onEventReceived.bind(this);this._installRecognizers()}destroy(){const a=Object.keys(this._nameToGroup);for(const b of a)this.uninstallHandlers(b);this.eventSource.destroy();this._currentPropagation=null;this._propertiesPool.destroy()}get hasPendingInputs(){return this._handlers.some(a=>a.handler.hasPendingInputs)}get latestPointerType(){return this._latestPointerType}get multiTouchActive(){return this._multiTouchHandler.multiTouchActive}get updating(){return this.hasPendingInputs||this._paused}installHandlers(a, |
|
b,c=n.INTERNAL){if(!this._nameToGroup[a]&&0!==b.length){var d={name:a,handlers:b.map(e=>({handler:e,active:!0,removed:!1,priorityIndex:0,groupPriority:c,eventCallback:null,uninstallCallback:null}))};this._nameToGroup[a]=d;for(a=d.handlers.length-1;0<=a;a--){const e=d.handlers[a];this._handlers.push(e);e.handler.onInstall({updateDependencies:()=>{this.updateDependencies()},emit:(f,h,z,A,B)=>{this._emitInputEvent(e.priorityIndex+1,f,h,z,B,A)},setPointerCapture:(f,h)=>{this._setPointerCapture(d,e,f, |
|
h)},setEventCallback:f=>{e.eventCallback=f},setUninstallCallback:f=>{e.uninstallCallback=f},refreshHasPendingInputs:()=>{this.notifyChange("hasPendingInputs")}})}this.updateDependencies()}}uninstallHandlers(a){const b=this._nameToGroup[a];b?(b.handlers.forEach(c=>{c.removed=!0;c.uninstallCallback?.()}),delete this._nameToGroup[a],this._currentPropagation?this._currentPropagation.needsHandlerGarbageCollect=!0:this._garbageCollectRemovedHandlers()):t.getLogger(this).error("There is no InputHandler group registered under the name `"+ |
|
a+"`")}hasHandlers(a){return void 0!==this._nameToGroup[a]}isModifierKeyDown(a){return this._activeKeyModifiers&&this._activeKeyModifiers.has(a)}updateDependencies(){if(this._currentPropagation)this._updateDependenciesAfterPropagation=!0;else{this._updateDependenciesAfterPropagation=!1;var a=new Set,b=new Set;this._handlersPriority=[];for(var c=this._handlers.length-1;0<=c;c--){var d=this._handlers[c];d.priorityIndex=c;this._handlersPriority.push(d)}this._handlersPriority=this._sortHandlersPriority(this._handlersPriority); |
|
for(c=this._handlersPriority.length-1;0<=c;c--){d=this._handlersPriority[c];d.priorityIndex=c;let e=d.handler.hasSideEffects;if(!e)for(const f of d.handler.outgoingEventTypes)if(a.has(f)){e=!0;break}if(e)for(const f of d.handler.incomingEventMatches){a.add(f.eventType);for(const h of f.keyModifiers)q.isSystemModifier(h)||b.add(h)}d.active=e}this._sourceEvents=a;this._keyModifiers=b;0<this._pointerCaptures.size&&this._sourceEvents.add("pointer-capture-lost");0<this._keyModifiers.size&&(this._sourceEvents.add("key-down"), |
|
this._sourceEvents.add("key-up"));this.eventSource&&(this.eventSource.activeEvents=this._sourceEvents)}}_setLatestPointer(a,b,c){this._latestPointerType=a;a=this._get("latestPointerLocation");if(null==a||a.x!==b||a.y!==c)a=this._propertiesPool.get("latestPointerLocation"),a.x=b,a.y=c,this._set("latestPointerLocation",a)}_onEventReceived(a,b){"pointer-capture-lost"===a&&this._pointerCaptures.delete(b.native.pointerId);this._updateKeyModifiers(a,b);this._emitInputEventFromSource(a,b,null!=this.test.timestamp? |
|
this.test.timestamp:b.native?b.native.timestamp:void 0,b.native?b.native.cancelable:void 0)}_updateKeyModifiers(a,b){if(b){var c=!1,d=()=>{if(!c){const f=new Set;this._activeKeyModifiers.forEach(h=>{f.add(h)});this._activeKeyModifiers=f;c=!0}},e=(f,h)=>{h&&!this._activeKeyModifiers.has(f)?(d(),this._activeKeyModifiers.add(f)):!h&&this._activeKeyModifiers.has(f)&&(d(),this._activeKeyModifiers.delete(f))};if("key-down"===a||"key-up"===a){const f=b.key;this._keyModifiers.has(f)&&e(f,"key-down"===a)}a= |
|
b.native;e("Alt",!(!a||!a.altKey));e("Control",!(!a||!a.ctrlKey));e("Ctrl",!(!a||!a.ctrlKey));e("Shift",!(!a||!a.shiftKey));e("Meta",!(!a||!a.metaKey));e("Primary",this._activeKeyModifiers.has(this.primaryKey))}}_installRecognizers(){this._latestPointerHandler=new w.LatestPointer((a,b,c)=>this._setLatestPointer(a,b,c));this._multiTouchHandler=new x.MultiTouch;this.installHandlers("input-manager-logic",[this._latestPointerHandler,this._multiTouchHandler],n.ALWAYS);0<this.recognizers.length&&this.installHandlers("default", |
|
this.recognizers,n.INTERNAL)}_setPointerCapture(a,b,c,d){a=a.name+"-"+b.priorityIndex;b=this._pointerCaptures.get(c.pointerId)||new Set;this._pointerCaptures.set(c.pointerId,b);d?(b.add(a),1===b.size&&this.eventSource&&this.eventSource.setPointerCapture(c,!0)):b.has(a)&&(b.delete(a),0===b.size&&(this._pointerCaptures.delete(c.pointerId),this.eventSource&&this.eventSource.setPointerCapture(c,!1)))}_garbageCollectRemovedHandlers(){this._handlers=this._handlers.filter(a=>!a.removed);this.updateDependencies()}_emitInputEventFromSource(a, |
|
b,c,d){this._emitInputEvent(0,a,b,c,d)}_emitInputEvent(a,b,c,d,e,f){d=void 0!==d?d:this._currentPropagation?this._currentPropagation.timestamp:performance.now();a={event:new C(b,c,d,f||this._activeKeyModifiers,void 0!==e?e:!1),priorityIndex:a};this._currentPropagation?this._currentPropagation.events.push(a):this._doNewPropagation(a)}_doNewPropagation(a){this._currentPropagation={events:new p,currentHandler:null,needsHandlerGarbageCollect:!1,timestamp:a.event.timestamp};this._currentPropagation.events.push(a); |
|
this._continuePropagation()}_continuePropagation(){this._paused=!1;const a=this._currentPropagation;if(a){for(;0<a.events.length;){const {event:b,priorityIndex:c}=a.events.pop(),d=b.data?.eventId;if(null==d||!this._stoppedPropagationEventIds.has(d))for(a.currentHandler=this._handlersPriority[c];a.currentHandler;){if(a.currentHandler.removed)a.needsHandlerGarbageCollect=!0;else{a.currentHandler.active&&!b.shouldStopPropagation()&&a.currentHandler.eventCallback?.(b);if(b.shouldStopPropagation()){null!= |
|
d&&this._stoppedPropagationEventIds.add(d);break}if(b.shouldPausePropagation(()=>this._continuePropagation())){this._pausePropagation({event:b,priorityIndex:a.currentHandler.priorityIndex+1});return}}a.currentHandler=this._handlersPriority[a.currentHandler.priorityIndex+1]}}a.needsHandlerGarbageCollect&&this._garbageCollectRemovedHandlers();this.hasPendingInputs||this._stoppedPropagationEventIds.clear();this._currentPropagation=null;this._updateDependenciesAfterPropagation&&this.updateDependencies()}}_pausePropagation(a){const b= |
|
new p;b.push(a);if(a=this._currentPropagation){for(;a.events.length;)b.push(a.events.pop());a.events=b;a.currentHandler=null;this._paused=!0}}_compareHandlerPriority(a,b){if(a.handler.hasSideEffects!==b.handler.hasSideEffects)return a.handler.hasSideEffects?1:-1;if(a.groupPriority!==b.groupPriority)return a.groupPriority>b.groupPriority?-1:1;for(const c of a.handler.incomingEventMatches)for(const d of b.handler.incomingEventMatches){if(c.eventType!==d.eventType)continue;const e=c.keyModifiers.filter(f=> |
|
d.keyModifiers.includes(f));if(e.length===c.keyModifiers.length!==(e.length===d.keyModifiers.length))return c.keyModifiers.length>d.keyModifiers.length?-1:1}return a.priorityIndex>b.priorityIndex?-1:1}_sortHandlersPriority(a){const b=[];for(const c of a){for(a=0;a<b.length&&0<=this._compareHandlerPriority(c,b[a]);)a++;b.splice(a,0,c)}return b}get debug(){const a=b=>{const c=this._setPointerCapture;this._setPointerCapture=()=>{};b();this._setPointerCapture=c};return{injectEvent:(b,c)=>{a(()=>{this._onEventReceived(b, |
|
c)})},disablePointerCapture:a}}};k.__decorate([l.property({readOnly:!0})],g.InputManager.prototype,"hasPendingInputs",null);k.__decorate([l.property({constructOnly:!0})],g.InputManager.prototype,"eventSource",void 0);k.__decorate([l.property({constructOnly:!0})],g.InputManager.prototype,"recognizers",void 0);k.__decorate([l.property()],g.InputManager.prototype,"_latestPointerType",void 0);k.__decorate([l.property()],g.InputManager.prototype,"latestPointerType",null);k.__decorate([l.property()],g.InputManager.prototype, |
|
"multiTouchActive",null);k.__decorate([l.property({readOnly:!0})],g.InputManager.prototype,"latestPointerLocation",void 0);k.__decorate([l.property()],g.InputManager.prototype,"_paused",void 0);k.__decorate([l.property({readOnly:!0})],g.InputManager.prototype,"updating",null);g.InputManager=k.__decorate([u.subclass("esri.views.input.InputManager")],g.InputManager);class C{constructor(a,b,c,d,e){this.type=a;this.data=b;this.timestamp=c;this.modifiers=d;this.cancelable=e;this._propagationState=m.NONE; |
|
this._resumeCallback=null}stopPropagation(){this._propagationState|=m.STOPPED}shouldStopPropagation(){return 0!==(this._propagationState&m.STOPPED)}async(a){this._propagationState|=m.PAUSED;const b=(c,d)=>{this._propagationState&=~m.PAUSED;const e=this._resumeCallback;this._resumeCallback=null;e&&e();if(d)throw c;return c};return("function"===typeof a?a():a).then(c=>b(c,!1),c=>b(c,!0))}shouldPausePropagation(a){return this._propagationState&m.PAUSED?(this._resumeCallback=a,!0):!1}preventDefault(){this.data.native.preventDefault()}} |
|
var m;(function(a){a[a.NONE=0]="NONE";a[a.STOPPED=1]="STOPPED";a[a.PAUSED=2]="PAUSED"})(m||={});const n={ALWAYS:1,DEFAULT:0,TOOL:-1,WIDGET:-2,INTERNAL:-3};class D{}const y=D;g.ViewEventPriorities=n;Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}); |