SafetyScreen-ui/node_modules/@interactjs/auto-start/base.prod.js

2 lines
3.2 KiB
JavaScript

import{Scope as t,SignalArgs as e}from"../core/scope.prod.js";import*as n from"../utils/domUtils.prod.js";import r from"../utils/extend.prod.js";import o from"../utils/is.prod.js";import{copyAction as a}from"../utils/misc.prod.js";import i from"./InteractableMethods.prod.js";function s(t,e,n,r,o){return e.testIgnoreAllow(e.options[t.name],n,r)&&e.options[t.name].enabled&&m(e,n,t,o)?t:null}function c(t,e,n,r,o,a,i){for(let c=0,l=r.length;c<l;c++){const l=r[c],u=o[c],m=l.getAction(e,n,t,u);if(!m)continue;const p=s(m,l,u,a,i);if(p)return{action:p,interactable:l,element:u}}return{action:null,interactable:null,element:null}}function l(t,e,r,a,i){let s=[],l=[],u=a;function m(t){s.push(t),l.push(u)}for(;o.element(u);){s=[],l=[],i.interactables.forEachMatch(u,m);const o=c(t,e,r,s,l,a,i);if(o.action&&!o.interactable.options[o.action.name].manualStart)return o;u=n.parentNode(u)}return{action:null,interactable:null,element:null}}function u(t,{action:e,interactable:n,element:r},o){e=e||{name:null},t.interactable=n,t.element=r,a(t.prepared,e),t.rect=n&&e.name?n.getRect(r):null,d(t,o),o.fire("autoStart:prepared",{interaction:t})}function m(t,e,n,r){const o=t.options,a=o[n.name].max,i=o[n.name].maxPerElement,s=r.autoStart.maxInteractions;let c=0,l=0,u=0;if(!(a&&i&&s))return!1;for(const o of r.interactions.list){const r=o.prepared.name;if(o.interacting()){if(c++,c>=s)return!1;if(o.interactable===t){if(l+=r===n.name?1:0,l>=a)return!1;if(o.element===e&&(u++,r===n.name&&u>=i))return!1}}}return s>0}function p(t,e){return o.number(t)?(e.autoStart.maxInteractions=t,this):e.autoStart.maxInteractions}function f(t,e,n){const{cursorElement:r}=n.autoStart;r&&r!==t&&(r.style.cursor=""),t.ownerDocument.documentElement.style.cursor=e,t.style.cursor=e,n.autoStart.cursorElement=e?t:null}function d(t,e){const{interactable:n,element:r,prepared:a}=t;if("mouse"!==t.pointerType||!n||!n.options.styleCursor)return void(e.autoStart.cursorElement&&f(e.autoStart.cursorElement,"",e));let i="";if(a.name){const s=n.options[a.name].cursorChecker;i=o.func(s)?s(a,n,r,t._interacting):e.actions.map[a.name].getCursor(a)}f(t.element,i||"",e)}const b={id:"auto-start/base",before:["actions"],install(t){const{interactStatic:e,defaults:n}=t;t.usePlugin(i),n.base.actionChecker=null,n.base.styleCursor=!0,r(n.perAction,{manualStart:!1,max:1/0,maxPerElement:1,allowFrom:null,ignoreFrom:null,mouseButtons:1}),e.maxInteractions=e=>p(e,t),t.autoStart={maxInteractions:1/0,withinInteractionLimit:m,cursorElement:null}},listeners:{"interactions:down"({interaction:t,pointer:e,event:n,eventTarget:r},o){t.interacting()||u(t,l(t,e,n,r,o),o)},"interactions:move"(t,e){(({interaction:t,pointer:e,event:n,eventTarget:r},o)=>{"mouse"!==t.pointerType||t.pointerIsDown||t.interacting()||u(t,l(t,e,n,r,o),o)})(t,e),((t,e)=>{const{interaction:n}=t;if(!n.pointerIsDown||n.interacting()||!n.pointerWasMoved||!n.prepared.name)return;e.fire("autoStart:before-start",t);const{interactable:r}=n,o=n.prepared.name;o&&r&&(r.options[o].manualStart||!m(r,n.element,n.prepared,e)?n.stop():(n.start(n.prepared,r,n.element),d(n,e)))})(t,e)},"interactions:stop"({interaction:t},e){const{interactable:n}=t;n&&n.options.styleCursor&&f(t.element,"",e)}},maxInteractions:p,withinInteractionLimit:m,validateAction:s};export default b;
//# sourceMappingURL=base.prod.js.map