5 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			5 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/* interact.js 1.10.27 | https://raw.github.com/taye/interact.js/main/LICENSE */
 | 
						|
 | 
						|
import*as domUtils from"../utils/domUtils.prod.js";import extend from"../utils/extend.prod.js";import is from"../utils/is.prod.js";import{copyAction}from"../utils/misc.prod.js";import InteractableMethods from"./InteractableMethods.prod.js";function install(t){const{interactStatic:e,defaults:n}=t;t.usePlugin(InteractableMethods),n.base.actionChecker=null,n.base.styleCursor=!0,extend(n.perAction,{manualStart:!1,max:1/0,maxPerElement:1,allowFrom:null,ignoreFrom:null,mouseButtons:1}),e.maxInteractions=e=>maxInteractions(e,t),t.autoStart={maxInteractions:1/0,withinInteractionLimit:withinInteractionLimit,cursorElement:null}}function prepareOnDown(t,e){let{interaction:n,pointer:r,event:o,eventTarget:a}=t;if(n.interacting())return;prepare(n,getActionInfo(n,r,o,a,e),e)}function prepareOnMove(t,e){let{interaction:n,pointer:r,event:o,eventTarget:a}=t;if("mouse"!==n.pointerType||n.pointerIsDown||n.interacting())return;prepare(n,getActionInfo(n,r,o,a,e),e)}function startOnMove(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||!withinInteractionLimit(r,n.element,n.prepared,e)?n.stop():(n.start(n.prepared,r,n.element),setInteractionCursor(n,e)))}function clearCursorOnStop(t,e){let{interaction:n}=t;const{interactable:r}=n;r&&r.options.styleCursor&&setCursor(n.element,"",e)}function validateAction(t,e,n,r,o){return e.testIgnoreAllow(e.options[t.name],n,r)&&e.options[t.name].enabled&&withinInteractionLimit(e,n,t,o)?t:null}function validateMatches(t,e,n,r,o,a,i){for(let s=0,c=r.length;s<c;s++){const c=r[s],l=o[s],u=c.getAction(e,n,t,l);if(!u)continue;const m=validateAction(u,c,l,a,i);if(m)return{action:m,interactable:c,element:l}}return{action:null,interactable:null,element:null}}function getActionInfo(t,e,n,r,o){let a=[],i=[],s=r;function c(t){a.push(t),i.push(s)}for(;is.element(s);){a=[],i=[],o.interactables.forEachMatch(s,c);const l=validateMatches(t,e,n,a,i,r,o);if(l.action&&!l.interactable.options[l.action.name].manualStart)return l;s=domUtils.parentNode(s)}return{action:null,interactable:null,element:null}}function prepare(t,e,n){let{action:r,interactable:o,element:a}=e;r=r||{name:null},t.interactable=o,t.element=a,copyAction(t.prepared,r),t.rect=o&&r.name?o.getRect(a):null,setInteractionCursor(t,n),n.fire("autoStart:prepared",{interaction:t})}function withinInteractionLimit(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 maxInteractions(t,e){return is.number(t)?(e.autoStart.maxInteractions=t,this):e.autoStart.maxInteractions}function setCursor(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 setInteractionCursor(t,e){const{interactable:n,element:r,prepared:o}=t;if("mouse"!==t.pointerType||!n||!n.options.styleCursor)return void(e.autoStart.cursorElement&&setCursor(e.autoStart.cursorElement,"",e));let a="";if(o.name){const i=n.options[o.name].cursorChecker;a=is.func(i)?i(o,n,r,t._interacting):e.actions.map[o.name].getCursor(o)}setCursor(t.element,a||"",e)}const autoStart={id:"auto-start/base",before:["actions"],install:install,listeners:{"interactions:down":prepareOnDown,"interactions:move"(t,e){prepareOnMove(t,e),startOnMove(t,e)},"interactions:stop":clearCursorOnStop},maxInteractions:maxInteractions,withinInteractionLimit:withinInteractionLimit,validateAction:validateAction};export{autoStart as default};
 | 
						|
//# sourceMappingURL=base.prod.js.map
 |