@interactjs/modifiers
Advanced tools
Comparing version 1.10.17 to 1.10.18
@@ -27,7 +27,8 @@ /** | ||
rect, | ||
edges: originalEdges, | ||
edges, | ||
pageCoords: coords | ||
} = arg; | ||
let { | ||
ratio | ||
ratio, | ||
enabled | ||
} = state.options; | ||
@@ -48,8 +49,8 @@ const { | ||
const linkedEdges = state.linkedEdges = { | ||
top: originalEdges.top || originalEdges.left && !originalEdges.bottom, | ||
left: originalEdges.left || originalEdges.top && !originalEdges.right, | ||
bottom: originalEdges.bottom || originalEdges.right && !originalEdges.top, | ||
right: originalEdges.right || originalEdges.bottom && !originalEdges.left | ||
top: edges.top || edges.left && !edges.bottom, | ||
left: edges.left || edges.top && !edges.right, | ||
bottom: edges.bottom || edges.right && !edges.top, | ||
right: edges.right || edges.bottom && !edges.left | ||
}; | ||
state.xIsPrimaryAxis = !!(originalEdges.left || originalEdges.right); | ||
state.xIsPrimaryAxis = !!(edges.left || edges.right); | ||
@@ -69,4 +70,7 @@ if (state.equalDelta) { | ||
extend(arg.edges, linkedEdges); | ||
if (!modifiers || !modifiers.length) return; | ||
if (enabled !== false) { | ||
extend(edges, linkedEdges); | ||
} | ||
if (!(modifiers != null && modifiers.length)) return; | ||
const subModification = new Modification(arg.interaction); | ||
@@ -86,4 +90,8 @@ subModification.copyFrom(arg.interaction.modification); | ||
} = arg; | ||
const { | ||
linkedEdges | ||
} = state; | ||
const initialCoords = extend({}, coords); | ||
const aspectMethod = state.equalDelta ? setEqualDelta : setRatio; | ||
extend(arg.edges, linkedEdges); | ||
aspectMethod(state, state.xIsPrimaryAxis, coords, rect); | ||
@@ -96,3 +104,3 @@ | ||
const correctedRect = extend({}, rect); | ||
addEdges(state.linkedEdges, correctedRect, { | ||
addEdges(linkedEdges, correctedRect, { | ||
x: coords.x - initialCoords.x, | ||
@@ -103,3 +111,3 @@ y: coords.y - initialCoords.y | ||
rect: correctedRect, | ||
edges: state.linkedEdges, | ||
edges: linkedEdges, | ||
pageCoords: coords, | ||
@@ -106,0 +114,0 @@ prevCoords: coords, |
@@ -1,2 +0,2 @@ | ||
import t from"../utils/extend.prod.js";import{addEdges as e}from"../utils/rect.prod.js";import o from"./Modification";import{makeModifier as r}from"./base";const i={start(e){const{state:r,rect:i,edges:s,pageCoords:a}=e;let{ratio:n}=r.options;const{equalDelta:d,modifiers:l}=r.options;"preserve"===n&&(n=i.width/i.height),r.startCoords=t({},a),r.startRect=t({},i),r.ratio=n,r.equalDelta=d;const c=r.linkedEdges={top:s.top||s.left&&!s.bottom,left:s.left||s.top&&!s.right,bottom:s.bottom||s.right&&!s.top,right:s.right||s.bottom&&!s.left};if(r.xIsPrimaryAxis=!(!s.left&&!s.right),r.equalDelta){const t=(c.left?1:-1)*(c.top?1:-1);r.edgeSign={x:t,y:t}}else r.edgeSign={x:c.left?-1:1,y:c.top?-1:1};if(t(e.edges,c),!l||!l.length)return;const p=new o(e.interaction);p.copyFrom(e.interaction.modification),p.prepareStates(l),r.subModification=p,p.startAll({...e})},set(o){const{state:r,rect:i,coords:n}=o,d=t({},n),l=r.equalDelta?s:a;if(l(r,r.xIsPrimaryAxis,n,i),!r.subModification)return null;const c=t({},i);e(r.linkedEdges,c,{x:n.x-d.x,y:n.y-d.y});const p=r.subModification.setAll({...o,rect:c,edges:r.linkedEdges,pageCoords:n,prevCoords:n,prevRect:c}),{delta:f}=p;return p.changed&&(l(r,Math.abs(f.x)>Math.abs(f.y),p.coords,p.rect),t(n,p.coords)),p.eventProps},defaults:{ratio:"preserve",equalDelta:!1,modifiers:[],enabled:!1}};function s({startCoords:t,edgeSign:e},o,r){o?r.y=t.y+(r.x-t.x)*e.y:r.x=t.x+(r.y-t.y)*e.x}function a({startRect:t,startCoords:e,ratio:o,edgeSign:r},i,s,a){if(i){const i=a.width/o;s.y=e.y+(i-t.height)*r.y}else{const i=a.height*o;s.x=e.x+(i-t.width)*r.x}}export default r(i,"aspectRatio");export{i as aspectRatio}; | ||
import t from"../utils/extend.prod.js";import{addEdges as e}from"../utils/rect.prod.js";import o from"./Modification";import{makeModifier as r}from"./base";const i={start(e){const{state:r,rect:i,edges:s,pageCoords:a}=e;let{ratio:n,enabled:d}=r.options;const{equalDelta:l,modifiers:c}=r.options;"preserve"===n&&(n=i.width/i.height),r.startCoords=t({},a),r.startRect=t({},i),r.ratio=n,r.equalDelta=l;const p=r.linkedEdges={top:s.top||s.left&&!s.bottom,left:s.left||s.top&&!s.right,bottom:s.bottom||s.right&&!s.top,right:s.right||s.bottom&&!s.left};if(r.xIsPrimaryAxis=!(!s.left&&!s.right),r.equalDelta){const t=(p.left?1:-1)*(p.top?1:-1);r.edgeSign={x:t,y:t}}else r.edgeSign={x:p.left?-1:1,y:p.top?-1:1};if(!1!==d&&t(s,p),null==c||!c.length)return;const f=new o(e.interaction);f.copyFrom(e.interaction.modification),f.prepareStates(c),r.subModification=f,f.startAll({...e})},set(o){const{state:r,rect:i,coords:n}=o,{linkedEdges:d}=r,l=t({},n),c=r.equalDelta?s:a;if(t(o.edges,d),c(r,r.xIsPrimaryAxis,n,i),!r.subModification)return null;const p=t({},i);e(d,p,{x:n.x-l.x,y:n.y-l.y});const f=r.subModification.setAll({...o,rect:p,edges:d,pageCoords:n,prevCoords:n,prevRect:p}),{delta:g}=f;return f.changed&&(c(r,Math.abs(g.x)>Math.abs(g.y),f.coords,f.rect),t(n,f.coords)),f.eventProps},defaults:{ratio:"preserve",equalDelta:!1,modifiers:[],enabled:!1}};function s({startCoords:t,edgeSign:e},o,r){o?r.y=t.y+(r.x-t.x)*e.y:r.x=t.x+(r.y-t.y)*e.x}function a({startRect:t,startCoords:e,ratio:o,edgeSign:r},i,s,a){if(i){const i=a.width/o;s.y=e.y+(i-t.height)*r.y}else{const i=a.height*o;s.x=e.x+(i-t.width)*r.x}}export default r(i,"aspectRatio");export{i as aspectRatio}; | ||
//# sourceMappingURL=aspectRatio.prod.js.map |
31
base.js
@@ -71,9 +71,32 @@ import Modification from './Modification'; | ||
'interactions:before-action-start': arg => { | ||
const { | ||
interaction | ||
} = arg; | ||
const modification = arg.interaction.modification; | ||
modification.start(arg, arg.interaction.coords.start.page); | ||
arg.interaction.edges = modification.edges; | ||
modification.start(arg, interaction.coords.start.page); | ||
interaction.edges = modification.edges; | ||
modification.applyToInteraction(arg); | ||
}, | ||
'interactions:before-action-move': arg => arg.interaction.modification.setAndApply(arg), | ||
'interactions:before-action-end': arg => arg.interaction.modification.beforeEnd(arg), | ||
'interactions:before-action-move': arg => { | ||
const { | ||
interaction | ||
} = arg; | ||
const { | ||
modification | ||
} = interaction; | ||
const ret = modification.setAndApply(arg); | ||
interaction.edges = modification.edges; | ||
return ret; | ||
}, | ||
'interactions:before-action-end': arg => { | ||
const { | ||
interaction | ||
} = arg; | ||
const { | ||
modification | ||
} = interaction; | ||
const ret = modification.beforeEnd(arg); | ||
interaction.edges = modification.startEdges; | ||
return ret; | ||
}, | ||
'interactions:action-start': addEventModifiers, | ||
@@ -80,0 +103,0 @@ 'interactions:action-move': addEventModifiers, |
@@ -1,2 +0,2 @@ | ||
import t from"./Modification";export function makeModifier(t,i){const{defaults:n}=t,e={start:t.start,set:t.set,beforeEnd:t.beforeEnd,stop:t.stop},o=t=>{const o=t||{};o.enabled=!1!==o.enabled;for(const t in n)t in o||(o[t]=n[t]);const a={options:o,methods:e,name:i,enable:()=>(o.enabled=!0,a),disable:()=>(o.enabled=!1,a)};return a};return i&&"string"==typeof i&&(o._defaults=n,o._methods=e),o}export function addEventModifiers({iEvent:t,interaction:i}){const n=i.modification.result;n&&(t.modifiers=n.eventProps)}const i={id:"modifiers/base",before:["actions"],install(t){t.defaults.perAction.modifiers=[]},listeners:{"interactions:new"({interaction:i}){i.modification=new t(i)},"interactions:before-action-start"(t){const i=t.interaction.modification;i.start(t,t.interaction.coords.start.page),t.interaction.edges=i.edges,i.applyToInteraction(t)},"interactions:before-action-move":t=>t.interaction.modification.setAndApply(t),"interactions:before-action-end":t=>t.interaction.modification.beforeEnd(t),"interactions:action-start":addEventModifiers,"interactions:action-move":addEventModifiers,"interactions:action-end":addEventModifiers,"interactions:after-action-start":t=>t.interaction.modification.restoreInteractionCoords(t),"interactions:after-action-move":t=>t.interaction.modification.restoreInteractionCoords(t),"interactions:stop":t=>t.interaction.modification.stop(t)}};export default i; | ||
import t from"./Modification";export function makeModifier(t,e){const{defaults:i}=t,n={start:t.start,set:t.set,beforeEnd:t.beforeEnd,stop:t.stop},o=t=>{const o=t||{};o.enabled=!1!==o.enabled;for(const t in i)t in o||(o[t]=i[t]);const r={options:o,methods:n,name:e,enable:()=>(o.enabled=!0,r),disable:()=>(o.enabled=!1,r)};return r};return e&&"string"==typeof e&&(o._defaults=i,o._methods=n),o}export function addEventModifiers({iEvent:t,interaction:e}){const i=e.modification.result;i&&(t.modifiers=i.eventProps)}const e={id:"modifiers/base",before:["actions"],install(t){t.defaults.perAction.modifiers=[]},listeners:{"interactions:new"({interaction:e}){e.modification=new t(e)},"interactions:before-action-start"(t){const{interaction:e}=t,i=t.interaction.modification;i.start(t,e.coords.start.page),e.edges=i.edges,i.applyToInteraction(t)},"interactions:before-action-move"(t){const{interaction:e}=t,{modification:i}=e,n=i.setAndApply(t);return e.edges=i.edges,n},"interactions:before-action-end"(t){const{interaction:e}=t,{modification:i}=e,n=i.beforeEnd(t);return e.edges=i.startEdges,n},"interactions:action-start":addEventModifiers,"interactions:action-move":addEventModifiers,"interactions:action-end":addEventModifiers,"interactions:after-action-start":t=>t.interaction.modification.restoreInteractionCoords(t),"interactions:after-action-move":t=>t.interaction.modification.restoreInteractionCoords(t),"interactions:stop":t=>t.interaction.modification.stop(t)}};export default e; | ||
//# sourceMappingURL=base.prod.js.map |
@@ -1,1 +0,1 @@ | ||
export {}; | ||
import '@interactjs/modifiers/plugin'; |
@@ -1,6 +0,6 @@ | ||
/* eslint-disable import/order, no-console, eol-last */ | ||
import interact from "../interact/index.js"; // eslint-disable-next-line import/no-extraneous-dependencies | ||
/* eslint-disable no-console, eol-last, import/no-duplicates, import/no-extraneous-dependencies, import/order */ | ||
import "./plugin.js"; | ||
import interact from "../interact/index.js"; | ||
import plugin from "./plugin.js"; | ||
interact.use(plugin); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import r from"../interact/index.prod.js";import o from"./plugin.prod.js";r.use(o); | ||
import"./plugin.prod.js";import r from"../interact/index.prod.js";import o from"./plugin.prod.js";r.use(o); | ||
//# sourceMappingURL=index.prod.js.map |
@@ -27,2 +27,3 @@ import type { EventPhase } from '@interactjs/core/InteractEvent'; | ||
endResult: Point; | ||
startEdges: EdgeOptions; | ||
edges: EdgeOptions; | ||
@@ -29,0 +30,0 @@ readonly interaction: Readonly<Interaction>; |
@@ -15,2 +15,3 @@ import clone from "../utils/clone.js"; | ||
endResult; | ||
startEdges; | ||
edges; | ||
@@ -22,2 +23,8 @@ interaction; | ||
this.result = createResult(); | ||
this.edges = { | ||
left: false, | ||
right: false, | ||
top: false, | ||
bottom: false | ||
}; | ||
} | ||
@@ -33,3 +40,4 @@ | ||
this.prepareStates(modifierList); | ||
this.edges = extend({}, interaction.edges); | ||
this.startEdges = extend({}, interaction.edges); | ||
this.edges = extend({}, this.startEdges); | ||
this.startOffset = getRectOffset(interaction.rect, pageCoords); | ||
@@ -58,4 +66,4 @@ this.startDelta = { | ||
arg.element = interaction.element; | ||
arg.rect = arg.rect || interaction.rect; | ||
arg.edges = this.edges; | ||
arg.rect ||= interaction.rect; | ||
arg.edges ||= this.startEdges; | ||
arg.startOffset = this.startOffset; | ||
@@ -79,6 +87,8 @@ return arg; | ||
skipModifiers, | ||
rect: unmodifiedRect | ||
rect: unmodifiedRect, | ||
edges: unmodifiedEdges | ||
} = arg; | ||
arg.coords = extend({}, arg.pageCoords); | ||
arg.rect = extend({}, unmodifiedRect); | ||
arg.edges = extend({}, unmodifiedEdges); | ||
const states = skipModifiers ? this.states.slice(skipModifiers) : this.states; | ||
@@ -99,3 +109,3 @@ const newResult = createResult(arg.coords, arg.rect); | ||
returnValue = state.methods.set(arg); | ||
rectUtils.addEdges(this.interaction.edges, arg.rect, { | ||
rectUtils.addEdges(arg.edges, arg.rect, { | ||
x: arg.coords.x - lastModifierCoords.x, | ||
@@ -109,2 +119,3 @@ y: arg.coords.y - lastModifierCoords.y | ||
extend(this.edges, arg.edges); | ||
newResult.delta.x = arg.coords.x - arg.pageCoords.x; | ||
@@ -335,2 +346,3 @@ newResult.delta.y = arg.coords.y - arg.pageCoords.y; | ||
this.startDelta = other.startDelta; | ||
this.startEdges = other.startEdges; | ||
this.edges = other.edges; | ||
@@ -337,0 +349,0 @@ this.states = other.states.map(s => clone(s)); |
@@ -1,2 +0,2 @@ | ||
import t from"../utils/clone.prod.js";import e from"../utils/extend.prod.js";import*as s from"../utils/rect.prod.js";export default class o{states=[];startOffset={left:0,right:0,top:0,bottom:0};startDelta;result;endResult;edges;interaction;constructor(t){this.interaction=t,this.result=r()}start({phase:t},s){const{interaction:o}=this,i=(t=>{const e=t.interactable.options[t.prepared.name],s=e.modifiers;return s&&s.length?s:["snap","snapSize","snapEdges","restrict","restrictEdges","restrictSize"].map((t=>{const s=e[t];return s&&s.enabled&&{options:s,methods:s._methods}})).filter((t=>!!t))})(o);this.prepareStates(i),this.edges=e({},o.edges),this.startOffset=getRectOffset(o.rect,s),this.startDelta={x:0,y:0};const n=this.fillArg({phase:t,pageCoords:s,preEnd:!1});return this.result=r(),this.startAll(n),this.result=this.setAll(n)}fillArg(t){const{interaction:e}=this;return t.interaction=e,t.interactable=e.interactable,t.element=e.element,t.rect=t.rect||e.rect,t.edges=this.edges,t.startOffset=this.startOffset,t}startAll(t){for(const e of this.states)e.methods.start&&(t.state=e,e.methods.start(t))}setAll(t){const{phase:o,preEnd:i,skipModifiers:n,rect:a}=t;t.coords=e({},t.pageCoords),t.rect=e({},a);const l=n?this.states.slice(n):this.states,c=r(t.coords,t.rect);for(const r of l){var d;const{options:n}=r,a=e({},t.coords);let l=null;null!=(d=r.methods)&&d.set&&this.shouldDo(n,i,o)&&(t.state=r,l=r.methods.set(t),s.addEdges(this.interaction.edges,t.rect,{x:t.coords.x-a.x,y:t.coords.y-a.y})),c.eventProps.push(l)}c.delta.x=t.coords.x-t.pageCoords.x,c.delta.y=t.coords.y-t.pageCoords.y,c.rectDelta.left=t.rect.left-a.left,c.rectDelta.right=t.rect.right-a.right,c.rectDelta.top=t.rect.top-a.top,c.rectDelta.bottom=t.rect.bottom-a.bottom;const h=this.result.coords,p=this.result.rect;if(h&&p){const t=c.rect.left!==p.left||c.rect.right!==p.right||c.rect.top!==p.top||c.rect.bottom!==p.bottom;c.changed=t||h.x!==c.coords.x||h.y!==c.coords.y}return c}applyToInteraction(t){const{interaction:s}=this,{phase:o}=t,r=s.coords.cur,i=s.coords.start,{result:n,startDelta:a}=this,l=n.delta;"start"===o&&e(this.startDelta,n.delta);for(const[t,e]of[[i,a],[r,l]])t.page.x+=e.x,t.page.y+=e.y,t.client.x+=e.x,t.client.y+=e.y;const{rectDelta:c}=this.result,d=t.rect||s.rect;d.left+=c.left,d.right+=c.right,d.top+=c.top,d.bottom+=c.bottom,d.width=d.right-d.left,d.height=d.bottom-d.top}setAndApply(t){const{interaction:e}=this,{phase:s,preEnd:o,skipModifiers:r}=t,i=this.setAll(this.fillArg({preEnd:o,phase:s,pageCoords:t.modifiedCoords||e.coords.cur.page}));if(this.result=i,!i.changed&&(!r||r<this.states.length)&&e.interacting())return!1;if(t.modifiedCoords){const{page:s}=e.coords.cur,o={x:t.modifiedCoords.x-s.x,y:t.modifiedCoords.y-s.y};i.coords.x+=o.x,i.coords.y+=o.y,i.delta.x+=o.x,i.delta.y+=o.y}this.applyToInteraction(t)}beforeEnd(t){const{interaction:e,event:s}=t,o=this.states;if(!o||!o.length)return;let r=!1;for(const e of o){t.state=e;const{options:s,methods:o}=e,i=o.beforeEnd&&o.beforeEnd(t);if(i)return this.endResult=i,!1;r=r||!r&&this.shouldDo(s,!0,t.phase,!0)}r&&e.move({event:s,preEnd:!0})}stop(t){const{interaction:s}=t;if(!this.states||!this.states.length)return;const o=e({states:this.states,interactable:s.interactable,element:s.element,rect:null},t);this.fillArg(o);for(const t of this.states)o.state=t,t.methods.stop&&t.methods.stop(o);this.states=null,this.endResult=null}prepareStates(t){this.states=[];for(let e=0;e<t.length;e++){const{options:s,methods:o,name:r}=t[e];this.states.push({options:s,methods:o,index:e,name:r})}return this.states}restoreInteractionCoords({interaction:{coords:t,rect:e,modification:s}}){if(!s.result)return;const{startDelta:o}=s,{delta:r,rectDelta:i}=s.result,n=[[t.start,o],[t.cur,r]];for(const[t,e]of n)t.page.x-=e.x,t.page.y-=e.y,t.client.x-=e.x,t.client.y-=e.y;e.left-=i.left,e.right-=i.right,e.top-=i.top,e.bottom-=i.bottom}shouldDo(t,e,s,o){return!(!t||!1===t.enabled||o&&!t.endOnly||t.endOnly&&!e||"start"===s&&!t.setStart)}copyFrom(s){this.startOffset=s.startOffset,this.startDelta=s.startDelta,this.edges=s.edges,this.states=s.states.map((e=>t(e))),this.result=r(e({},s.result.coords),e({},s.result.rect))}destroy(){for(const t in this)this[t]=null}}function r(t,e){return{rect:e,coords:t,delta:{x:0,y:0},rectDelta:{left:0,right:0,top:0,bottom:0},eventProps:[],changed:!0}}export function getRectOffset(t,e){return t?{left:e.x-t.left,top:e.y-t.top,right:t.right-e.x,bottom:t.bottom-e.y}:{left:0,top:0,right:0,bottom:0}} | ||
import t from"../utils/clone.prod.js";import e from"../utils/extend.prod.js";import*as s from"../utils/rect.prod.js";export default class o{states=[];startOffset={left:0,right:0,top:0,bottom:0};startDelta;result;endResult;startEdges;edges;interaction;constructor(t){this.interaction=t,this.result=r(),this.edges={left:!1,right:!1,top:!1,bottom:!1}}start({phase:t},s){const{interaction:o}=this,i=(t=>{const e=t.interactable.options[t.prepared.name],s=e.modifiers;return s&&s.length?s:["snap","snapSize","snapEdges","restrict","restrictEdges","restrictSize"].map((t=>{const s=e[t];return s&&s.enabled&&{options:s,methods:s._methods}})).filter((t=>!!t))})(o);this.prepareStates(i),this.startEdges=e({},o.edges),this.edges=e({},this.startEdges),this.startOffset=getRectOffset(o.rect,s),this.startDelta={x:0,y:0};const a=this.fillArg({phase:t,pageCoords:s,preEnd:!1});return this.result=r(),this.startAll(a),this.result=this.setAll(a)}fillArg(t){const{interaction:e}=this;return t.interaction=e,t.interactable=e.interactable,t.element=e.element,t.rect||=e.rect,t.edges||=this.startEdges,t.startOffset=this.startOffset,t}startAll(t){for(const e of this.states)e.methods.start&&(t.state=e,e.methods.start(t))}setAll(t){const{phase:o,preEnd:i,skipModifiers:a,rect:n,edges:l}=t;t.coords=e({},t.pageCoords),t.rect=e({},n),t.edges=e({},l);const c=a?this.states.slice(a):this.states,d=r(t.coords,t.rect);for(const r of c){var h;const{options:a}=r,n=e({},t.coords);let l=null;null!=(h=r.methods)&&h.set&&this.shouldDo(a,i,o)&&(t.state=r,l=r.methods.set(t),s.addEdges(t.edges,t.rect,{x:t.coords.x-n.x,y:t.coords.y-n.y})),d.eventProps.push(l)}e(this.edges,t.edges),d.delta.x=t.coords.x-t.pageCoords.x,d.delta.y=t.coords.y-t.pageCoords.y,d.rectDelta.left=t.rect.left-n.left,d.rectDelta.right=t.rect.right-n.right,d.rectDelta.top=t.rect.top-n.top,d.rectDelta.bottom=t.rect.bottom-n.bottom;const p=this.result.coords,f=this.result.rect;if(p&&f){const t=d.rect.left!==f.left||d.rect.right!==f.right||d.rect.top!==f.top||d.rect.bottom!==f.bottom;d.changed=t||p.x!==d.coords.x||p.y!==d.coords.y}return d}applyToInteraction(t){const{interaction:s}=this,{phase:o}=t,r=s.coords.cur,i=s.coords.start,{result:a,startDelta:n}=this,l=a.delta;"start"===o&&e(this.startDelta,a.delta);for(const[t,e]of[[i,n],[r,l]])t.page.x+=e.x,t.page.y+=e.y,t.client.x+=e.x,t.client.y+=e.y;const{rectDelta:c}=this.result,d=t.rect||s.rect;d.left+=c.left,d.right+=c.right,d.top+=c.top,d.bottom+=c.bottom,d.width=d.right-d.left,d.height=d.bottom-d.top}setAndApply(t){const{interaction:e}=this,{phase:s,preEnd:o,skipModifiers:r}=t,i=this.setAll(this.fillArg({preEnd:o,phase:s,pageCoords:t.modifiedCoords||e.coords.cur.page}));if(this.result=i,!i.changed&&(!r||r<this.states.length)&&e.interacting())return!1;if(t.modifiedCoords){const{page:s}=e.coords.cur,o={x:t.modifiedCoords.x-s.x,y:t.modifiedCoords.y-s.y};i.coords.x+=o.x,i.coords.y+=o.y,i.delta.x+=o.x,i.delta.y+=o.y}this.applyToInteraction(t)}beforeEnd(t){const{interaction:e,event:s}=t,o=this.states;if(!o||!o.length)return;let r=!1;for(const e of o){t.state=e;const{options:s,methods:o}=e,i=o.beforeEnd&&o.beforeEnd(t);if(i)return this.endResult=i,!1;r=r||!r&&this.shouldDo(s,!0,t.phase,!0)}r&&e.move({event:s,preEnd:!0})}stop(t){const{interaction:s}=t;if(!this.states||!this.states.length)return;const o=e({states:this.states,interactable:s.interactable,element:s.element,rect:null},t);this.fillArg(o);for(const t of this.states)o.state=t,t.methods.stop&&t.methods.stop(o);this.states=null,this.endResult=null}prepareStates(t){this.states=[];for(let e=0;e<t.length;e++){const{options:s,methods:o,name:r}=t[e];this.states.push({options:s,methods:o,index:e,name:r})}return this.states}restoreInteractionCoords({interaction:{coords:t,rect:e,modification:s}}){if(!s.result)return;const{startDelta:o}=s,{delta:r,rectDelta:i}=s.result,a=[[t.start,o],[t.cur,r]];for(const[t,e]of a)t.page.x-=e.x,t.page.y-=e.y,t.client.x-=e.x,t.client.y-=e.y;e.left-=i.left,e.right-=i.right,e.top-=i.top,e.bottom-=i.bottom}shouldDo(t,e,s,o){return!(!t||!1===t.enabled||o&&!t.endOnly||t.endOnly&&!e||"start"===s&&!t.setStart)}copyFrom(s){this.startOffset=s.startOffset,this.startDelta=s.startDelta,this.startEdges=s.startEdges,this.edges=s.edges,this.states=s.states.map((e=>t(e))),this.result=r(e({},s.result.coords),e({},s.result.rect))}destroy(){for(const t in this)this[t]=null}}function r(t,e){return{rect:e,coords:t,delta:{x:0,y:0},rectDelta:{left:0,right:0,top:0,bottom:0},eventProps:[],changed:!0}}export function getRectOffset(t,e){return t?{left:e.x-t.left,top:e.y-t.top,right:t.right-e.x,bottom:t.bottom-e.y}:{left:0,top:0,right:0,bottom:0}} | ||
//# sourceMappingURL=Modification.prod.js.map |
{ | ||
"name": "@interactjs/modifiers", | ||
"version": "1.10.17", | ||
"version": "1.10.18", | ||
"main": "index", | ||
"module": "index", | ||
"type": "module", | ||
"repository": { | ||
@@ -12,10 +13,10 @@ "type": "git", | ||
"dependencies": { | ||
"@interactjs/snappers": "1.10.17" | ||
"@interactjs/snappers": "1.10.18" | ||
}, | ||
"peerDependencies": { | ||
"@interactjs/core": "1.10.17", | ||
"@interactjs/utils": "1.10.17" | ||
"@interactjs/core": "1.10.18", | ||
"@interactjs/utils": "1.10.18" | ||
}, | ||
"optionalDependencies": { | ||
"@interactjs/interact": "1.10.17" | ||
"@interactjs/interact": "1.10.18" | ||
}, | ||
@@ -30,3 +31,3 @@ "publishConfig": { | ||
"license": "MIT", | ||
"gitHead": "5772a7e2" | ||
"gitHead": "90ef3f56" | ||
} |
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
238564
2071
Yes
+ Added@interactjs/core@1.10.18(transitive)
+ Added@interactjs/interact@1.10.18(transitive)
+ Added@interactjs/snappers@1.10.18(transitive)
+ Added@interactjs/utils@1.10.18(transitive)
- Removed@interactjs/core@1.10.17(transitive)
- Removed@interactjs/interact@1.10.17(transitive)
- Removed@interactjs/snappers@1.10.17(transitive)
- Removed@interactjs/types@1.10.17(transitive)
- Removed@interactjs/utils@1.10.17(transitive)
Updated@interactjs/snappers@1.10.18