5 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			5 lines
		
	
	
		
			5.0 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";function install(e){const{actions:t,browser:r,Interactable:i,defaults:s}=e;resize.cursors=initCursors(r),resize.defaultMargin=r.supportsTouch||r.supportsPointerEvent?20:10,i.prototype.resizable=function(t){return resizable(this,t,e)},t.map.resize=resize,t.methodDict.resize="resizable",s.actions.resize=resize.defaults}function resizeChecker(e){const{interaction:t,interactable:r,element:i,rect:s,buttons:o}=e;if(!s)return;const n=extend({},t.coords.cur.page),a=r.options.resize;if(a&&a.enabled&&(!t.pointerIsDown||!/mouse|pointer/.test(t.pointerType)||0!=(o&a.mouseButtons))){if(is.object(a.edges)){const r={left:!1,right:!1,top:!1,bottom:!1};for(const e in r)r[e]=checkResizeEdge(e,a.edges[e],n,t._latestPointer.eventTarget,i,s,a.margin||resize.defaultMargin);r.left=r.left&&!r.right,r.top=r.top&&!r.bottom,(r.left||r.right||r.top||r.bottom)&&(e.action={name:"resize",edges:r})}else{const t="y"!==a.axis&&n.x>s.right-resize.defaultMargin,r="x"!==a.axis&&n.y>s.bottom-resize.defaultMargin;(t||r)&&(e.action={name:"resize",axes:(t?"x":"")+(r?"y":"")})}return!e.action&&void 0}}function resizable(e,t,r){return is.object(t)?(e.options.resize.enabled=!1!==t.enabled,e.setPerAction("resize",t),e.setOnEvents("resize",t),is.string(t.axis)&&/^x$|^y$|^xy$/.test(t.axis)?e.options.resize.axis=t.axis:null===t.axis&&(e.options.resize.axis=r.defaults.actions.resize.axis),is.bool(t.preserveAspectRatio)?e.options.resize.preserveAspectRatio=t.preserveAspectRatio:is.bool(t.square)&&(e.options.resize.square=t.square),e):is.bool(t)?(e.options.resize.enabled=t,e):e.options.resize}function checkResizeEdge(e,t,r,i,s,o,n){if(!t)return!1;if(!0===t){const t=is.number(o.width)?o.width:o.right-o.left,i=is.number(o.height)?o.height:o.bottom-o.top;if(n=Math.min(n,Math.abs(("left"===e||"right"===e?t:i)/2)),t<0&&("left"===e?e="right":"right"===e&&(e="left")),i<0&&("top"===e?e="bottom":"bottom"===e&&(e="top")),"left"===e){const e=t>=0?o.left:o.right;return r.x<e+n}if("top"===e){const e=i>=0?o.top:o.bottom;return r.y<e+n}if("right"===e)return r.x>(t>=0?o.right:o.left)-n;if("bottom"===e)return r.y>(i>=0?o.bottom:o.top)-n}return!!is.element(i)&&(is.element(t)?t===i:domUtils.matchesUpTo(i,t,s))}function initCursors(e){return e.isIe9?{x:"e-resize",y:"s-resize",xy:"se-resize",top:"n-resize",left:"w-resize",bottom:"s-resize",right:"e-resize",topleft:"se-resize",bottomright:"se-resize",topright:"ne-resize",bottomleft:"ne-resize"}:{x:"ew-resize",y:"ns-resize",xy:"nwse-resize",top:"ns-resize",left:"ew-resize",bottom:"ns-resize",right:"ew-resize",topleft:"nwse-resize",bottomright:"nwse-resize",topright:"nesw-resize",bottomleft:"nesw-resize"}}function start(e){let{iEvent:t,interaction:r}=e;if("resize"!==r.prepared.name||!r.prepared.edges)return;const i=t,s=r.rect;r._rects={start:extend({},s),corrected:extend({},s),previous:extend({},s),delta:{left:0,right:0,width:0,top:0,bottom:0,height:0}},i.edges=r.prepared.edges,i.rect=r._rects.corrected,i.deltaRect=r._rects.delta}function move(e){let{iEvent:t,interaction:r}=e;if("resize"!==r.prepared.name||!r.prepared.edges)return;const i=t,s=r.interactable.options.resize.invert,o="reposition"===s||"negate"===s,n=r.rect,{start:a,corrected:l,delta:c,previous:p}=r._rects;if(extend(p,l),o){if(extend(l,n),"reposition"===s){if(l.top>l.bottom){const e=l.top;l.top=l.bottom,l.bottom=e}if(l.left>l.right){const e=l.left;l.left=l.right,l.right=e}}}else l.top=Math.min(n.top,a.bottom),l.bottom=Math.max(n.bottom,a.top),l.left=Math.min(n.left,a.right),l.right=Math.max(n.right,a.left);l.width=l.right-l.left,l.height=l.bottom-l.top;for(const e in l)c[e]=l[e]-p[e];i.edges=r.prepared.edges,i.rect=l,i.deltaRect=c}function end(e){let{iEvent:t,interaction:r}=e;if("resize"!==r.prepared.name||!r.prepared.edges)return;const i=t;i.edges=r.prepared.edges,i.rect=r._rects.corrected,i.deltaRect=r._rects.delta}function updateEventAxes(e){let{iEvent:t,interaction:r}=e;if("resize"!==r.prepared.name||!r.resizeAxes)return;const i=t;r.interactable.options.resize.square?("y"===r.resizeAxes?i.delta.x=i.delta.y:i.delta.y=i.delta.x,i.axes="xy"):(i.axes=r.resizeAxes,"x"===r.resizeAxes?i.delta.y=0:"y"===r.resizeAxes&&(i.delta.x=0))}const resize={id:"actions/resize",before:["actions/drag"],install:install,listeners:{"interactions:new"(e){let{interaction:t}=e;t.resizeAxes="xy"},"interactions:action-start"(e){start(e),updateEventAxes(e)},"interactions:action-move"(e){move(e),updateEventAxes(e)},"interactions:action-end":end,"auto-start:check":resizeChecker},defaults:{square:!1,preserveAspectRatio:!1,axis:"xy",margin:NaN,edges:null,invert:"none"},cursors:null,getCursor(e){let{edges:t,axis:r,name:i}=e;const s=resize.cursors;let o=null;if(r)o=s[i+r];else if(t){let e="";for(const r of["top","bottom","left","right"])t[r]&&(e+=r);o=s[e]}return o},filterEventType(e){return 0===e.search("resize")},defaultMargin:null};export{resize as default};
 | 
						|
//# sourceMappingURL=plugin.prod.js.map
 |