@interactjs/modifiers
Advanced tools
Comparing version 1.10.11 to 1.10.12
/* eslint-disable import/order, no-console, eol-last */ | ||
import interact from "../interact/index.js"; | ||
import interact from "../interact/index.js"; // eslint-disable-next-line import/no-extraneous-dependencies | ||
import plugin from "./plugin.js"; | ||
interact.use(plugin); | ||
//# sourceMappingURL=index.js.map |
@@ -5,15 +5,16 @@ import clone from "../utils/clone.js"; | ||
export default class Modification { | ||
states = []; | ||
startOffset = { | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
bottom: 0 | ||
}; | ||
startDelta; | ||
result; | ||
endResult; | ||
edges; | ||
interaction; | ||
constructor(interaction) { | ||
this.states = []; | ||
this.startOffset = { | ||
left: 0, | ||
right: 0, | ||
top: 0, | ||
bottom: 0 | ||
}; | ||
this.startDelta = void 0; | ||
this.result = void 0; | ||
this.endResult = void 0; | ||
this.edges = void 0; | ||
this.interaction = void 0; | ||
this.interaction = interaction; | ||
@@ -20,0 +21,0 @@ this.result = createResult(); |
@@ -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{constructor(t){this.states=[],this.startOffset={left:0,right:0,top:0,bottom:0},this.startDelta=void 0,this.result=void 0,this.endResult=void 0,this.edges=void 0,this.interaction=void 0,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;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}} | ||
//# sourceMappingURL=Modification.prod.js.map |
{ | ||
"name": "@interactjs/modifiers", | ||
"version": "1.10.11", | ||
"version": "1.10.12", | ||
"main": "index", | ||
"module": "index", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/taye/interact.js.git", | ||
"directory": "packages/@interactjs/modifiers" | ||
}, | ||
"dependencies": { | ||
"@interactjs/snappers": "1.10.11" | ||
"@interactjs/snappers": "1.10.12" | ||
}, | ||
"peerDependencies": { | ||
"@interactjs/core": "1.10.11", | ||
"@interactjs/utils": "1.10.11" | ||
"@interactjs/core": "1.10.12", | ||
"@interactjs/utils": "1.10.12" | ||
}, | ||
"optionalDependencies": { | ||
"@interactjs/interact": "1.10.11" | ||
"@interactjs/interact": "1.10.12" | ||
}, | ||
@@ -16,0 +21,0 @@ "publishConfig": { |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
211024
+ Added@interactjs/core@1.10.12(transitive)
+ Added@interactjs/interact@1.10.12(transitive)
+ Added@interactjs/snappers@1.10.12(transitive)
+ Added@interactjs/types@1.10.12(transitive)
+ Added@interactjs/utils@1.10.12(transitive)
- Removed@interactjs/core@1.10.11(transitive)
- Removed@interactjs/interact@1.10.11(transitive)
- Removed@interactjs/snappers@1.10.11(transitive)
- Removed@interactjs/types@1.10.11(transitive)
- Removed@interactjs/utils@1.10.11(transitive)
Updated@interactjs/snappers@1.10.12