@interactjs/actions
Advanced tools
Comparing version 1.10.2 to 1.10.3
@@ -1,2 +0,1 @@ | ||
import { Interactable } from "../../core/Interactable.js"; | ||
import is from "../../utils/is.js"; | ||
@@ -19,6 +18,3 @@ | ||
}) { | ||
if (interaction.prepared.name !== 'drag') { | ||
return; | ||
} | ||
if (interaction.prepared.name !== 'drag') return; | ||
const axis = interaction.prepared.axis; | ||
@@ -43,6 +39,3 @@ | ||
}) { | ||
if (interaction.prepared.name !== 'drag') { | ||
return; | ||
} | ||
if (interaction.prepared.name !== 'drag') return; | ||
const axis = interaction.prepared.axis; | ||
@@ -49,0 +42,0 @@ |
@@ -1,2 +0,2 @@ | ||
import{Interactable as t}from"../../core/Interactable.prod.js";import o from"../../utils/is.prod.js";function e({interaction:t}){if("drag"!==t.prepared.name)return;const o=t.prepared.axis;"x"===o?(t.coords.cur.page.y=t.coords.start.page.y,t.coords.cur.client.y=t.coords.start.client.y,t.coords.velocity.client.y=0,t.coords.velocity.page.y=0):"y"===o&&(t.coords.cur.page.x=t.coords.start.page.x,t.coords.cur.client.x=t.coords.start.client.x,t.coords.velocity.client.x=0,t.coords.velocity.page.x=0)}function r({iEvent:t,interaction:o}){if("drag"!==o.prepared.name)return;const e=o.prepared.axis;if("x"===e||"y"===e){const r="x"===e?"y":"x";t.page[r]=o.coords.start.page[r],t.client[r]=o.coords.start.client[r],t.delta[r]=0}}const s={id:"actions/drag",install(t){const{actions:o,Interactable:e,defaults:r}=t;e.prototype.draggable=s.draggable,o.map.drag=s,o.methodDict.drag="draggable",r.actions.drag=s.defaults},listeners:{"interactions:before-action-move":e,"interactions:action-resume":e,"interactions:action-move":r,"auto-start:check"(t){const{interaction:o,interactable:e,buttons:r}=t,s=e.options.drag;if(s&&s.enabled&&(!o.pointerIsDown||!/mouse|pointer/.test(o.pointerType)||0!=(r&e.options.drag.mouseButtons)))return t.action={name:"drag",axis:"start"===s.lockAxis?s.startAxis:s.lockAxis},!1}},draggable(t){return o.object(t)?(this.options.drag.enabled=!1!==t.enabled,this.setPerAction("drag",t),this.setOnEvents("drag",t),/^(xy|x|y|start)$/.test(t.lockAxis)&&(this.options.drag.lockAxis=t.lockAxis),/^(xy|x|y)$/.test(t.startAxis)&&(this.options.drag.startAxis=t.startAxis),this):o.bool(t)?(this.options.drag.enabled=t,this):this.options.drag},beforeMove:e,move:r,defaults:{startAxis:"xy",lockAxis:"xy"},getCursor(){return"move"}};export default s; | ||
import t from"../../utils/is.prod.js";function o({interaction:t}){if("drag"!==t.prepared.name)return;const o=t.prepared.axis;"x"===o?(t.coords.cur.page.y=t.coords.start.page.y,t.coords.cur.client.y=t.coords.start.client.y,t.coords.velocity.client.y=0,t.coords.velocity.page.y=0):"y"===o&&(t.coords.cur.page.x=t.coords.start.page.x,t.coords.cur.client.x=t.coords.start.client.x,t.coords.velocity.client.x=0,t.coords.velocity.page.x=0)}function e({iEvent:t,interaction:o}){if("drag"!==o.prepared.name)return;const e=o.prepared.axis;if("x"===e||"y"===e){const r="x"===e?"y":"x";t.page[r]=o.coords.start.page[r],t.client[r]=o.coords.start.client[r],t.delta[r]=0}}const r={id:"actions/drag",install(t){const{actions:o,Interactable:e,defaults:s}=t;e.prototype.draggable=r.draggable,o.map.drag=r,o.methodDict.drag="draggable",s.actions.drag=r.defaults},listeners:{"interactions:before-action-move":o,"interactions:action-resume":o,"interactions:action-move":e,"auto-start:check"(t){const{interaction:o,interactable:e,buttons:r}=t,s=e.options.drag;if(s&&s.enabled&&(!o.pointerIsDown||!/mouse|pointer/.test(o.pointerType)||0!=(r&e.options.drag.mouseButtons)))return t.action={name:"drag",axis:"start"===s.lockAxis?s.startAxis:s.lockAxis},!1}},draggable(o){return t.object(o)?(this.options.drag.enabled=!1!==o.enabled,this.setPerAction("drag",o),this.setOnEvents("drag",o),/^(xy|x|y|start)$/.test(o.lockAxis)&&(this.options.drag.lockAxis=o.lockAxis),/^(xy|x|y)$/.test(o.startAxis)&&(this.options.drag.startAxis=o.startAxis),this):t.bool(o)?(this.options.drag.enabled=o,this):this.options.drag},beforeMove:o,move:e,defaults:{startAxis:"xy",lockAxis:"xy"},getCursor(){return"move"}};export default r; | ||
//# sourceMappingURL=plugin.prod.js.map |
@@ -1,5 +0,1 @@ | ||
import { InteractEvent } from "../../core/InteractEvent.js"; | ||
import { Interactable } from "../../core/Interactable.js"; | ||
import Interaction from "../../core/Interaction.js"; | ||
import { Scope } from "../../core/scope.js"; | ||
import * as domUtils from "../../utils/domUtils.js"; | ||
@@ -6,0 +2,0 @@ import extend from "../../utils/extend.js"; |
@@ -1,2 +0,2 @@ | ||
import{InteractEvent as e}from"../../core/InteractEvent.prod.js";import{Interactable as t}from"../../core/Interactable.prod.js";import o from"../../core/Interaction.prod.js";import{Scope as r}from"../../core/scope.prod.js";import*as n from"../../utils/domUtils.prod.js";import a from"../../utils/extend.prod.js";import p from"../../utils/getOriginXY.prod.js";import i from"../../utils/is.prod.js";import d from"../../utils/normalizeListeners.prod.js";import*as c from"../../utils/pointerUtils.prod.js";import l from"../drag/plugin.prod.js";import{DropEvent as s}from"./DropEvent.prod.js";function v(e,t){for(const{dropzone:o,element:r}of e.slice())t.dropzone=o,t.target=r,o.fire(t),t.propagationStopped=t.immediatePropagationStopped=!1}function m(e,t){const o=(({interactables:e},t)=>{const o=[];for(const r of e.list){if(!r.options.drop.enabled)continue;const e=r.options.drop.accept;if(i.element(e)&&e!==t||i.string(e)&&!n.matchesSelector(t,e)||i.func(e)&&!e({dropzone:r,draggableElement:t}))continue;const a=i.string(r.target)?r._context.querySelectorAll(r.target):i.array(r.target)?r.target:[r.target];for(const e of a)e!==t&&o.push({dropzone:r,element:e,rect:r.getRect(e)})}return o})(e,t);for(const e of o)e.rect=e.dropzone.getRect(e.element);return o}function u({dropState:e,interactable:t,element:o},r,a){const p=[];for(const{dropzone:n,element:i,rect:d}of e.activeDrops)p.push(n.dropCheck(r,a,t,o,i,d)?i:null);const i=n.indexOfDeepestElement(p);return e.activeDrops[i]||null}function f(e,t,o){const{dropState:r}=e,n={enter:null,leave:null,activate:null,deactivate:null,move:null,drop:null};return"dragstart"===o.type&&(n.activate=new s(r,o,"dropactivate"),n.activate.target=null,n.activate.dropzone=null),"dragend"===o.type&&(n.deactivate=new s(r,o,"dropdeactivate"),n.deactivate.target=null,n.deactivate.dropzone=null),r.rejected||(r.cur.element!==r.prev.element&&(r.prev.dropzone&&(n.leave=new s(r,o,"dragleave"),o.dragLeave=n.leave.target=r.prev.element,o.prevDropzone=n.leave.dropzone=r.prev.dropzone),r.cur.dropzone&&(n.enter=new s(r,o,"dragenter"),o.dragEnter=r.cur.element,o.dropzone=r.cur.dropzone)),"dragend"===o.type&&r.cur.dropzone&&(n.drop=new s(r,o,"drop"),o.dropzone=r.cur.dropzone,o.relatedTarget=r.cur.element),"dragmove"===o.type&&r.cur.dropzone&&(n.move=new s(r,o,"dropmove"),n.move.dragmove=o,o.dropzone=r.cur.dropzone)),n}function g(e,t){const{dropState:o}=e,{activeDrops:r,cur:n,prev:a}=o;t.leave&&a.dropzone.fire(t.leave),t.enter&&n.dropzone.fire(t.enter),t.move&&n.dropzone.fire(t.move),t.drop&&n.dropzone.fire(t.drop),t.deactivate&&v(r,t.deactivate),o.prev.dropzone=n.dropzone,o.prev.element=n.element}function z({interaction:e,iEvent:t,event:o},r){if("dragmove"!==t.type&&"dragend"!==t.type)return;const{dropState:n}=e;r.dynamicDrop&&(n.activeDrops=m(r,e.element));const a=t,p=u(e,a,o);n.rejected=n.rejected&&!!p&&p.dropzone===n.cur.dropzone&&p.element===n.cur.element,n.cur.dropzone=p&&p.dropzone,n.cur.element=p&&p.element,n.events=f(e,0,a)}const h={id:"actions/drop",install(e){const{actions:t,interactStatic:o,Interactable:r,defaults:n}=e;e.usePlugin(l),r.prototype.dropzone=function(e){return((e,t)=>{if(i.object(t)){if(e.options.drop.enabled=!1!==t.enabled,t.listeners){const o=d(t.listeners),r=Object.keys(o).reduce(((e,t)=>(e[/^(enter|leave)/.test(t)?"drag"+t:/^(activate|deactivate|move)/.test(t)?"drop"+t:t]=o[t],e)),{});e.off(e.options.drop.listeners),e.on(r),e.options.drop.listeners=r}return i.func(t.ondrop)&&e.on("drop",t.ondrop),i.func(t.ondropactivate)&&e.on("dropactivate",t.ondropactivate),i.func(t.ondropdeactivate)&&e.on("dropdeactivate",t.ondropdeactivate),i.func(t.ondragenter)&&e.on("dragenter",t.ondragenter),i.func(t.ondragleave)&&e.on("dragleave",t.ondragleave),i.func(t.ondropmove)&&e.on("dropmove",t.ondropmove),/^(pointer|center)$/.test(t.overlap)?e.options.drop.overlap=t.overlap:i.number(t.overlap)&&(e.options.drop.overlap=Math.max(Math.min(1,t.overlap),0)),"accept"in t&&(e.options.drop.accept=t.accept),"checker"in t&&(e.options.drop.checker=t.checker),e}return i.bool(t)?(e.options.drop.enabled=t,e):e.options.drop})(this,e)},r.prototype.dropCheck=function(e,t,o,r,n,a){return((e,t,o,r,n,a,d)=>{let l=!1;if(!(d=d||e.getRect(a)))return!!e.options.drop.checker&&e.options.drop.checker(t,o,l,e,a,r,n);const s=e.options.drop.overlap;if("pointer"===s){const e=p(r,n,"drag"),o=c.getPageXY(t);o.x+=e.x,o.y+=e.y;const a=o.x>d.left&&o.x<d.right,i=o.y>d.top&&o.y<d.bottom;l=a&&i}const v=r.getRect(n);if(v&&"center"===s){const e=v.left+v.width/2,t=v.top+v.height/2;l=e>=d.left&&e<=d.right&&t>=d.top&&t<=d.bottom}return v&&i.number(s)&&(l=Math.max(0,Math.min(d.right,v.right)-Math.max(d.left,v.left))*Math.max(0,Math.min(d.bottom,v.bottom)-Math.max(d.top,v.top))/(v.width*v.height)>=s),e.options.drop.checker&&(l=e.options.drop.checker(t,o,l,e,a,r,n)),l})(this,e,t,o,r,n,a)},o.dynamicDrop=t=>i.bool(t)?(e.dynamicDrop=t,o):e.dynamicDrop,a(t.phaselessTypes,{dragenter:!0,dragleave:!0,dropactivate:!0,dropdeactivate:!0,dropmove:!0,drop:!0}),t.methodDict.drop="dropzone",e.dynamicDrop=!1,n.actions.drop=h.defaults},listeners:{"interactions:before-action-start"({interaction:e}){"drag"===e.prepared.name&&(e.dropState={cur:{dropzone:null,element:null},prev:{dropzone:null,element:null},rejected:null,events:null,activeDrops:[]})},"interactions:after-action-start"({interaction:e,event:t,iEvent:o},r){if("drag"!==e.prepared.name)return;const{dropState:n}=e;n.activeDrops=null,n.events=null,n.activeDrops=m(r,e.element),n.events=f(e,0,o),n.events.activate&&(v(n.activeDrops,n.events.activate),r.fire("actions/drop:start",{interaction:e,dragEvent:o}))},"interactions:action-move":z,"interactions:after-action-move"({interaction:e,iEvent:t},o){"drag"===e.prepared.name&&(g(e,e.dropState.events),o.fire("actions/drop:move",{interaction:e,dragEvent:t}),e.dropState.events={})},"interactions:action-end"(e,t){if("drag"!==e.interaction.prepared.name)return;const{interaction:o,iEvent:r}=e;z(e,t),g(o,o.dropState.events),t.fire("actions/drop:end",{interaction:o,dragEvent:r})},"interactions:stop"({interaction:e}){if("drag"!==e.prepared.name)return;const{dropState:t}=e;t&&(t.activeDrops=null,t.events=null,t.cur.dropzone=null,t.cur.element=null,t.prev.dropzone=null,t.prev.element=null,t.rejected=!1)}},getActiveDrops:m,getDrop:u,getDropEvents:f,fireDropEvents:g,defaults:{enabled:!1,accept:null,overlap:"pointer"}};export default h; | ||
import*as e from"../../utils/domUtils.prod.js";import t from"../../utils/extend.prod.js";import o from"../../utils/getOriginXY.prod.js";import r from"../../utils/is.prod.js";import n from"../../utils/normalizeListeners.prod.js";import*as a from"../../utils/pointerUtils.prod.js";import p from"../drag/plugin.prod.js";import{DropEvent as i}from"./DropEvent.prod.js";function d(e,t){for(const{dropzone:o,element:r}of e.slice())t.dropzone=o,t.target=r,o.fire(t),t.propagationStopped=t.immediatePropagationStopped=!1}function c(t,o){const n=(({interactables:t},o)=>{const n=[];for(const a of t.list){if(!a.options.drop.enabled)continue;const t=a.options.drop.accept;if(r.element(t)&&t!==o||r.string(t)&&!e.matchesSelector(o,t)||r.func(t)&&!t({dropzone:a,draggableElement:o}))continue;const p=r.string(a.target)?a._context.querySelectorAll(a.target):r.array(a.target)?a.target:[a.target];for(const e of p)e!==o&&n.push({dropzone:a,element:e,rect:a.getRect(e)})}return n})(t,o);for(const e of n)e.rect=e.dropzone.getRect(e.element);return n}function l({dropState:t,interactable:o,element:r},n,a){const p=[];for(const{dropzone:e,element:i,rect:d}of t.activeDrops)p.push(e.dropCheck(n,a,o,r,i,d)?i:null);const i=e.indexOfDeepestElement(p);return t.activeDrops[i]||null}function s(e,t,o){const{dropState:r}=e,n={enter:null,leave:null,activate:null,deactivate:null,move:null,drop:null};return"dragstart"===o.type&&(n.activate=new i(r,o,"dropactivate"),n.activate.target=null,n.activate.dropzone=null),"dragend"===o.type&&(n.deactivate=new i(r,o,"dropdeactivate"),n.deactivate.target=null,n.deactivate.dropzone=null),r.rejected||(r.cur.element!==r.prev.element&&(r.prev.dropzone&&(n.leave=new i(r,o,"dragleave"),o.dragLeave=n.leave.target=r.prev.element,o.prevDropzone=n.leave.dropzone=r.prev.dropzone),r.cur.dropzone&&(n.enter=new i(r,o,"dragenter"),o.dragEnter=r.cur.element,o.dropzone=r.cur.dropzone)),"dragend"===o.type&&r.cur.dropzone&&(n.drop=new i(r,o,"drop"),o.dropzone=r.cur.dropzone,o.relatedTarget=r.cur.element),"dragmove"===o.type&&r.cur.dropzone&&(n.move=new i(r,o,"dropmove"),n.move.dragmove=o,o.dropzone=r.cur.dropzone)),n}function v(e,t){const{dropState:o}=e,{activeDrops:r,cur:n,prev:a}=o;t.leave&&a.dropzone.fire(t.leave),t.enter&&n.dropzone.fire(t.enter),t.move&&n.dropzone.fire(t.move),t.drop&&n.dropzone.fire(t.drop),t.deactivate&&d(r,t.deactivate),o.prev.dropzone=n.dropzone,o.prev.element=n.element}function u({interaction:e,iEvent:t,event:o},r){if("dragmove"!==t.type&&"dragend"!==t.type)return;const{dropState:n}=e;r.dynamicDrop&&(n.activeDrops=c(r,e.element));const a=t,p=l(e,a,o);n.rejected=n.rejected&&!!p&&p.dropzone===n.cur.dropzone&&p.element===n.cur.element,n.cur.dropzone=p&&p.dropzone,n.cur.element=p&&p.element,n.events=s(e,0,a)}const m={id:"actions/drop",install(e){const{actions:i,interactStatic:d,Interactable:c,defaults:l}=e;e.usePlugin(p),c.prototype.dropzone=function(e){return((e,t)=>{if(r.object(t)){if(e.options.drop.enabled=!1!==t.enabled,t.listeners){const o=n(t.listeners),r=Object.keys(o).reduce(((e,t)=>(e[/^(enter|leave)/.test(t)?"drag"+t:/^(activate|deactivate|move)/.test(t)?"drop"+t:t]=o[t],e)),{});e.off(e.options.drop.listeners),e.on(r),e.options.drop.listeners=r}return r.func(t.ondrop)&&e.on("drop",t.ondrop),r.func(t.ondropactivate)&&e.on("dropactivate",t.ondropactivate),r.func(t.ondropdeactivate)&&e.on("dropdeactivate",t.ondropdeactivate),r.func(t.ondragenter)&&e.on("dragenter",t.ondragenter),r.func(t.ondragleave)&&e.on("dragleave",t.ondragleave),r.func(t.ondropmove)&&e.on("dropmove",t.ondropmove),/^(pointer|center)$/.test(t.overlap)?e.options.drop.overlap=t.overlap:r.number(t.overlap)&&(e.options.drop.overlap=Math.max(Math.min(1,t.overlap),0)),"accept"in t&&(e.options.drop.accept=t.accept),"checker"in t&&(e.options.drop.checker=t.checker),e}return r.bool(t)?(e.options.drop.enabled=t,e):e.options.drop})(this,e)},c.prototype.dropCheck=function(e,t,n,p,i,d){return((e,t,n,p,i,d,c)=>{let l=!1;if(!(c=c||e.getRect(d)))return!!e.options.drop.checker&&e.options.drop.checker(t,n,l,e,d,p,i);const s=e.options.drop.overlap;if("pointer"===s){const e=o(p,i,"drag"),r=a.getPageXY(t);r.x+=e.x,r.y+=e.y;const n=r.x>c.left&&r.x<c.right,d=r.y>c.top&&r.y<c.bottom;l=n&&d}const v=p.getRect(i);if(v&&"center"===s){const e=v.left+v.width/2,t=v.top+v.height/2;l=e>=c.left&&e<=c.right&&t>=c.top&&t<=c.bottom}return v&&r.number(s)&&(l=Math.max(0,Math.min(c.right,v.right)-Math.max(c.left,v.left))*Math.max(0,Math.min(c.bottom,v.bottom)-Math.max(c.top,v.top))/(v.width*v.height)>=s),e.options.drop.checker&&(l=e.options.drop.checker(t,n,l,e,d,p,i)),l})(this,e,t,n,p,i,d)},d.dynamicDrop=t=>r.bool(t)?(e.dynamicDrop=t,d):e.dynamicDrop,t(i.phaselessTypes,{dragenter:!0,dragleave:!0,dropactivate:!0,dropdeactivate:!0,dropmove:!0,drop:!0}),i.methodDict.drop="dropzone",e.dynamicDrop=!1,l.actions.drop=m.defaults},listeners:{"interactions:before-action-start"({interaction:e}){"drag"===e.prepared.name&&(e.dropState={cur:{dropzone:null,element:null},prev:{dropzone:null,element:null},rejected:null,events:null,activeDrops:[]})},"interactions:after-action-start"({interaction:e,event:t,iEvent:o},r){if("drag"!==e.prepared.name)return;const{dropState:n}=e;n.activeDrops=null,n.events=null,n.activeDrops=c(r,e.element),n.events=s(e,0,o),n.events.activate&&(d(n.activeDrops,n.events.activate),r.fire("actions/drop:start",{interaction:e,dragEvent:o}))},"interactions:action-move":u,"interactions:after-action-move"({interaction:e,iEvent:t},o){"drag"===e.prepared.name&&(v(e,e.dropState.events),o.fire("actions/drop:move",{interaction:e,dragEvent:t}),e.dropState.events={})},"interactions:action-end"(e,t){if("drag"!==e.interaction.prepared.name)return;const{interaction:o,iEvent:r}=e;u(e,t),v(o,o.dropState.events),t.fire("actions/drop:end",{interaction:o,dragEvent:r})},"interactions:stop"({interaction:e}){if("drag"!==e.prepared.name)return;const{dropState:t}=e;t&&(t.activeDrops=null,t.events=null,t.cur.dropzone=null,t.cur.element=null,t.prev.dropzone=null,t.prev.element=null,t.rejected=!1)}},getActiveDrops:c,getDrop:l,getDropEvents:s,fireDropEvents:v,defaults:{enabled:!1,accept:null,overlap:"pointer"}};export default m; | ||
//# sourceMappingURL=plugin.prod.js.map |
@@ -1,2 +0,1 @@ | ||
import Interaction from "../../core/Interaction.js"; | ||
import is from "../../utils/is.js"; | ||
@@ -61,6 +60,3 @@ import * as pointerUtils from "../../utils/pointerUtils.js"; | ||
}) { | ||
if (interaction.prepared.name !== 'gesture') { | ||
return; | ||
} | ||
if (interaction.prepared.name !== 'gesture') return; | ||
const pointers = interaction.pointers.map(p => p.pointer); | ||
@@ -67,0 +63,0 @@ const starting = phase === 'start'; |
@@ -1,2 +0,2 @@ | ||
import e from"../../core/Interaction.prod.js";import t from"../../utils/is.prod.js";import*as s from"../../utils/pointerUtils.prod.js";function n({interaction:e,iEvent:n,phase:a}){if("gesture"!==e.prepared.name)return;const r=e.pointers.map((e=>e.pointer)),i="start"===a,o="end"===a,c=e.interactable.options.deltaSource;if(n.touches=[r[0],r[1]],i)n.distance=s.touchDistance(r,c),n.box=s.touchBBox(r),n.scale=1,n.ds=0,n.angle=s.touchAngle(r,c),n.da=0,e.gesture.startDistance=n.distance,e.gesture.startAngle=n.angle;else if(o){const t=e.prevEvent;n.distance=t.distance,n.box=t.box,n.scale=t.scale,n.ds=0,n.angle=t.angle,n.da=0}else n.distance=s.touchDistance(r,c),n.box=s.touchBBox(r),n.scale=n.distance/e.gesture.startDistance,n.angle=s.touchAngle(r,c),n.ds=n.scale-e.gesture.scale,n.da=n.angle-e.gesture.angle;e.gesture.distance=n.distance,e.gesture.angle=n.angle,t.number(n.scale)&&n.scale!==1/0&&!isNaN(n.scale)&&(e.gesture.scale=n.scale)}const a={id:"actions/gesture",before:["actions/drag","actions/resize"],install(e){const{actions:s,Interactable:n,defaults:r}=e;n.prototype.gesturable=function(e){return t.object(e)?(this.options.gesture.enabled=!1!==e.enabled,this.setPerAction("gesture",e),this.setOnEvents("gesture",e),this):t.bool(e)?(this.options.gesture.enabled=e,this):this.options.gesture},s.map.gesture=a,s.methodDict.gesture="gesturable",r.actions.gesture=a.defaults},listeners:{"interactions:action-start":n,"interactions:action-move":n,"interactions:action-end":n,"interactions:new"({interaction:e}){e.gesture={angle:0,distance:0,scale:1,startAngle:0,startDistance:0}},"auto-start:check"(e){if(e.interaction.pointers.length<2)return;const t=e.interactable.options.gesture;return t&&t.enabled?(e.action={name:"gesture"},!1):void 0}},defaults:{},getCursor(){return""}};export default a; | ||
import e from"../../utils/is.prod.js";import*as t from"../../utils/pointerUtils.prod.js";function s({interaction:s,iEvent:n,phase:a}){if("gesture"!==s.prepared.name)return;const i=s.pointers.map((e=>e.pointer)),r="start"===a,o="end"===a,c=s.interactable.options.deltaSource;if(n.touches=[i[0],i[1]],r)n.distance=t.touchDistance(i,c),n.box=t.touchBBox(i),n.scale=1,n.ds=0,n.angle=t.touchAngle(i,c),n.da=0,s.gesture.startDistance=n.distance,s.gesture.startAngle=n.angle;else if(o){const e=s.prevEvent;n.distance=e.distance,n.box=e.box,n.scale=e.scale,n.ds=0,n.angle=e.angle,n.da=0}else n.distance=t.touchDistance(i,c),n.box=t.touchBBox(i),n.scale=n.distance/s.gesture.startDistance,n.angle=t.touchAngle(i,c),n.ds=n.scale-s.gesture.scale,n.da=n.angle-s.gesture.angle;s.gesture.distance=n.distance,s.gesture.angle=n.angle,e.number(n.scale)&&n.scale!==1/0&&!isNaN(n.scale)&&(s.gesture.scale=n.scale)}const n={id:"actions/gesture",before:["actions/drag","actions/resize"],install(t){const{actions:s,Interactable:a,defaults:i}=t;a.prototype.gesturable=function(t){return e.object(t)?(this.options.gesture.enabled=!1!==t.enabled,this.setPerAction("gesture",t),this.setOnEvents("gesture",t),this):e.bool(t)?(this.options.gesture.enabled=t,this):this.options.gesture},s.map.gesture=n,s.methodDict.gesture="gesturable",i.actions.gesture=n.defaults},listeners:{"interactions:action-start":s,"interactions:action-move":s,"interactions:action-end":s,"interactions:new"({interaction:e}){e.gesture={angle:0,distance:0,scale:1,startAngle:0,startDistance:0}},"auto-start:check"(e){if(e.interaction.pointers.length<2)return;const t=e.interactable.options.gesture;return t&&t.enabled?(e.action={name:"gesture"},!1):void 0}},defaults:{},getCursor(){return""}};export default n; | ||
//# sourceMappingURL=plugin.prod.js.map |
{ | ||
"name": "@interactjs/actions", | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/core": "1.10.2", | ||
"@interactjs/utils": "1.10.2" | ||
"@interactjs/core": "1.10.3", | ||
"@interactjs/utils": "1.10.3" | ||
}, | ||
"optionalDependencies": { | ||
"@interactjs/interact": "1.10.2" | ||
"@interactjs/interact": "1.10.3" | ||
}, | ||
@@ -12,0 +12,0 @@ "publishConfig": { |
@@ -1,3 +0,1 @@ | ||
import { Interactable } from "../../core/Interactable.js"; | ||
import { Interaction } from "../../core/Interaction.js"; | ||
import * as dom from "../../utils/domUtils.js"; | ||
@@ -214,7 +212,8 @@ import extend from "../../utils/extend.js"; | ||
return is.element(value) // the value is an element to use as a resize handle | ||
? value === element // otherwise check if element matches value as selector | ||
: dom.matchesUpTo(element, value, interactableElement); | ||
return is.element(value) ? // the value is an element to use as a resize handle | ||
value === element : // otherwise check if element matches value as selector | ||
dom.matchesUpTo(element, value, interactableElement); | ||
} | ||
/* eslint-disable multiline-ternary */ | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports | ||
@@ -284,6 +283,3 @@ | ||
}) { | ||
if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) { | ||
return; | ||
} | ||
if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) return; | ||
const resizeEvent = iEvent; | ||
@@ -344,6 +340,3 @@ const resizeOptions = interaction.interactable.options.resize; | ||
}) { | ||
if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) { | ||
return; | ||
} | ||
if (interaction.prepared.name !== 'resize' || !interaction.prepared.edges) return; | ||
const resizeEvent = iEvent; | ||
@@ -359,6 +352,3 @@ resizeEvent.edges = interaction.prepared.edges; | ||
}) { | ||
if (interaction.prepared.name !== 'resize' || !interaction.resizeAxes) { | ||
return; | ||
} | ||
if (interaction.prepared.name !== 'resize' || !interaction.resizeAxes) return; | ||
const options = interaction.interactable.options; | ||
@@ -365,0 +355,0 @@ const resizeEvent = iEvent; |
@@ -1,2 +0,2 @@ | ||
import{Interactable as e}from"../../core/Interactable.prod.js";import{Interaction as t}from"../../core/Interaction.prod.js";import*as r from"../../utils/domUtils.prod.js";import i from"../../utils/extend.prod.js";import s from"../../utils/is.prod.js";function o(e,t,i,o,n,a,p){if(!t)return!1;if(!0===t){const t=s.number(a.width)?a.width:a.right-a.left,r=s.number(a.height)?a.height:a.bottom-a.top;if(p=Math.min(p,Math.abs(("left"===e||"right"===e?t:r)/2)),t<0&&("left"===e?e="right":"right"===e&&(e="left")),r<0&&("top"===e?e="bottom":"bottom"===e&&(e="top")),"left"===e)return i.x<(t>=0?a.left:a.right)+p;if("top"===e)return i.y<(r>=0?a.top:a.bottom)+p;if("right"===e)return i.x>(t>=0?a.right:a.left)-p;if("bottom"===e)return i.y>(r>=0?a.bottom:a.top)-p}return!!s.element(o)&&(s.element(t)?t===o:r.matchesUpTo(o,t,n))}function n({iEvent:e,interaction:t}){if("resize"!==t.prepared.name||!t.resizeAxes)return;const r=e;t.interactable.options.resize.square?("y"===t.resizeAxes?r.delta.x=r.delta.y:r.delta.y=r.delta.x,r.axes="xy"):(r.axes=t.resizeAxes,"x"===t.resizeAxes?r.delta.y=0:"y"===t.resizeAxes&&(r.delta.x=0))}const a={id:"actions/resize",before:["actions/drag"],install(e){const{actions:t,browser:r,Interactable:i,defaults:o}=e;a.cursors=(e=>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"})(r),a.defaultMargin=r.supportsTouch||r.supportsPointerEvent?20:10,i.prototype.resizable=function(t){return((e,t,r)=>s.object(t)?(e.options.resize.enabled=!1!==t.enabled,e.setPerAction("resize",t),e.setOnEvents("resize",t),s.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),s.bool(t.preserveAspectRatio)?e.options.resize.preserveAspectRatio=t.preserveAspectRatio:s.bool(t.square)&&(e.options.resize.square=t.square),e):s.bool(t)?(e.options.resize.enabled=t,e):e.options.resize)(this,t,e)},t.map.resize=a,t.methodDict.resize="resizable",o.actions.resize=a.defaults},listeners:{"interactions:new"({interaction:e}){e.resizeAxes="xy"},"interactions:action-start"(e){(({iEvent:e,interaction:t})=>{if("resize"!==t.prepared.name||!t.prepared.edges)return;const r=e,s=t.rect;t._rects={start:i({},s),corrected:i({},s),previous:i({},s),delta:{left:0,right:0,width:0,top:0,bottom:0,height:0}},r.edges=t.prepared.edges,r.rect=t._rects.corrected,r.deltaRect=t._rects.delta})(e),n(e)},"interactions:action-move"(e){(({iEvent:e,interaction:t})=>{if("resize"!==t.prepared.name||!t.prepared.edges)return;const r=e,s=t.interactable.options.resize.invert,o="reposition"===s||"negate"===s,n=t.rect,{start:a,corrected:p,delta:c,previous:l}=t._rects;if(i(l,p),o){if(i(p,n),"reposition"===s){if(p.top>p.bottom){const e=p.top;p.top=p.bottom,p.bottom=e}if(p.left>p.right){const e=p.left;p.left=p.right,p.right=e}}}else p.top=Math.min(n.top,a.bottom),p.bottom=Math.max(n.bottom,a.top),p.left=Math.min(n.left,a.right),p.right=Math.max(n.right,a.left);p.width=p.right-p.left,p.height=p.bottom-p.top;for(const e in p)c[e]=p[e]-l[e];r.edges=t.prepared.edges,r.rect=p,r.deltaRect=c})(e),n(e)},"interactions:action-end"({iEvent:e,interaction:t}){if("resize"!==t.prepared.name||!t.prepared.edges)return;const r=e;r.edges=t.prepared.edges,r.rect=t._rects.corrected,r.deltaRect=t._rects.delta},"auto-start:check"(e){const{interaction:t,interactable:r,element:n,rect:p,buttons:c}=e;if(!p)return;const l=i({},t.coords.cur.page),d=r.options.resize;if(d&&d.enabled&&(!t.pointerIsDown||!/mouse|pointer/.test(t.pointerType)||0!=(c&d.mouseButtons))){if(s.object(d.edges)){const r={left:!1,right:!1,top:!1,bottom:!1};for(const e in r)r[e]=o(e,d.edges[e],l,t._latestPointer.eventTarget,n,p,d.margin||a.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"!==d.axis&&l.x>p.right-a.defaultMargin,r="x"!==d.axis&&l.y>p.bottom-a.defaultMargin;(t||r)&&(e.action={name:"resize",axes:(t?"x":"")+(r?"y":"")})}return!e.action&&void 0}}},defaults:{square:!1,preserveAspectRatio:!1,axis:"xy",margin:NaN,edges:null,invert:"none"},cursors:null,getCursor({edges:e,axis:t,name:r}){const i=a.cursors;let s=null;if(t)s=i[r+t];else if(e){let t="";for(const r of["top","bottom","left","right"])e[r]&&(t+=r);s=i[t]}return s},defaultMargin:null};export default a; | ||
import*as e from"../../utils/domUtils.prod.js";import t from"../../utils/extend.prod.js";import r from"../../utils/is.prod.js";function i(t,i,s,o,n,a,l){if(!i)return!1;if(!0===i){const e=r.number(a.width)?a.width:a.right-a.left,i=r.number(a.height)?a.height:a.bottom-a.top;if(l=Math.min(l,Math.abs(("left"===t||"right"===t?e:i)/2)),e<0&&("left"===t?t="right":"right"===t&&(t="left")),i<0&&("top"===t?t="bottom":"bottom"===t&&(t="top")),"left"===t)return s.x<(e>=0?a.left:a.right)+l;if("top"===t)return s.y<(i>=0?a.top:a.bottom)+l;if("right"===t)return s.x>(e>=0?a.right:a.left)-l;if("bottom"===t)return s.y>(i>=0?a.bottom:a.top)-l}return!!r.element(o)&&(r.element(i)?i===o:e.matchesUpTo(o,i,n))}function s({iEvent:e,interaction:t}){if("resize"!==t.prepared.name||!t.resizeAxes)return;const r=e;t.interactable.options.resize.square?("y"===t.resizeAxes?r.delta.x=r.delta.y:r.delta.y=r.delta.x,r.axes="xy"):(r.axes=t.resizeAxes,"x"===t.resizeAxes?r.delta.y=0:"y"===t.resizeAxes&&(r.delta.x=0))}const o={id:"actions/resize",before:["actions/drag"],install(e){const{actions:t,browser:i,Interactable:s,defaults:n}=e;o.cursors=(e=>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"})(i),o.defaultMargin=i.supportsTouch||i.supportsPointerEvent?20:10,s.prototype.resizable=function(t){return((e,t,i)=>r.object(t)?(e.options.resize.enabled=!1!==t.enabled,e.setPerAction("resize",t),e.setOnEvents("resize",t),r.string(t.axis)&&/^x$|^y$|^xy$/.test(t.axis)?e.options.resize.axis=t.axis:null===t.axis&&(e.options.resize.axis=i.defaults.actions.resize.axis),r.bool(t.preserveAspectRatio)?e.options.resize.preserveAspectRatio=t.preserveAspectRatio:r.bool(t.square)&&(e.options.resize.square=t.square),e):r.bool(t)?(e.options.resize.enabled=t,e):e.options.resize)(this,t,e)},t.map.resize=o,t.methodDict.resize="resizable",n.actions.resize=o.defaults},listeners:{"interactions:new"({interaction:e}){e.resizeAxes="xy"},"interactions:action-start"(e){(({iEvent:e,interaction:r})=>{if("resize"!==r.prepared.name||!r.prepared.edges)return;const i=e,s=r.rect;r._rects={start:t({},s),corrected:t({},s),previous:t({},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})(e),s(e)},"interactions:action-move"(e){(({iEvent:e,interaction:r})=>{if("resize"!==r.prepared.name||!r.prepared.edges)return;const i=e,s=r.interactable.options.resize.invert,o="reposition"===s||"negate"===s,n=r.rect,{start:a,corrected:l,delta:p,previous:c}=r._rects;if(t(c,l),o){if(t(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)p[e]=l[e]-c[e];i.edges=r.prepared.edges,i.rect=l,i.deltaRect=p})(e),s(e)},"interactions:action-end"({iEvent:e,interaction:t}){if("resize"!==t.prepared.name||!t.prepared.edges)return;const r=e;r.edges=t.prepared.edges,r.rect=t._rects.corrected,r.deltaRect=t._rects.delta},"auto-start:check"(e){const{interaction:s,interactable:n,element:a,rect:l,buttons:p}=e;if(!l)return;const c=t({},s.coords.cur.page),d=n.options.resize;if(d&&d.enabled&&(!s.pointerIsDown||!/mouse|pointer/.test(s.pointerType)||0!=(p&d.mouseButtons))){if(r.object(d.edges)){const t={left:!1,right:!1,top:!1,bottom:!1};for(const e in t)t[e]=i(e,d.edges[e],c,s._latestPointer.eventTarget,a,l,d.margin||o.defaultMargin);t.left=t.left&&!t.right,t.top=t.top&&!t.bottom,(t.left||t.right||t.top||t.bottom)&&(e.action={name:"resize",edges:t})}else{const t="y"!==d.axis&&c.x>l.right-o.defaultMargin,r="x"!==d.axis&&c.y>l.bottom-o.defaultMargin;(t||r)&&(e.action={name:"resize",axes:(t?"x":"")+(r?"y":"")})}return!e.action&&void 0}}},defaults:{square:!1,preserveAspectRatio:!1,axis:"xy",margin:NaN,edges:null,invert:"none"},cursors:null,getCursor({edges:e,axis:t,name:r}){const i=o.cursors;let s=null;if(t)s=i[r+t];else if(e){let t="";for(const r of["top","bottom","left","right"])e[r]&&(t+=r);s=i[t]}return s},defaultMargin:null};export default o; | ||
//# sourceMappingURL=plugin.prod.js.map |
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
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
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
234418
1298