Socket
Socket
Sign inDemoInstall

@interactjs/modifiers

Package Overview
Dependencies
Maintainers
2
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interactjs/modifiers - npm Package Compare versions

Comparing version 1.9.19 to 1.9.20

12

base.js

@@ -26,3 +26,11 @@ import Modification from "./Modification.js";

methods,
name
name,
enable: () => {
options.enabled = true;
return m;
},
disable: () => {
options.enabled = false;
return m;
}
};

@@ -80,5 +88,5 @@ return m;

},
before: ['actions', 'action/drag', 'actions/resize', 'actions/gesture']
before: ['actions']
};
export default modifiersBase;
//# sourceMappingURL=base.js.map

2

base.min.js

@@ -1,2 +0,2 @@

import t from"./Modification.min.js";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]);return{options:o,methods:e,name:i}};return i&&"string"==typeof i&&(o._defaults=n,o._methods=e),o}export function addEventModifiers({iEvent:t,interaction:{modification:{result:i}}}){i&&(t.modifiers=i.eventProps)}const i={id:"modifiers/base",install(t){t.defaults.perAction.modifiers=[]},listeners:{"interactions:new"({interaction:i}){i.modification=new t(i)},"interactions:before-action-start"(t){const{modification:i}=t.interaction;i.start(t,t.interaction.coords.start.page),t.interaction.edges=i.edges,i.applyToInteraction(t)},"interactions:before-action-move"(t){return t.interaction.modification.setAndApply(t)},"interactions:before-action-end"(t){return t.interaction.modification.beforeEnd(t)},"interactions:action-start":addEventModifiers,"interactions:action-move":addEventModifiers,"interactions:action-end":addEventModifiers,"interactions:after-action-start"(t){return t.interaction.modification.restoreInteractionCoords(t)},"interactions:after-action-move"(t){return t.interaction.modification.restoreInteractionCoords(t)},"interactions:stop"(t){return t.interaction.modification.stop(t)}},before:["actions","action/drag","actions/resize","actions/gesture"]};export default i;
import t from"./Modification.min.js";export function makeModifier(t,n){const{defaults:e}=t,i={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 e)t in o||(o[t]=e[t]);const r={options:o,methods:i,name:n,enable(){return o.enabled=!0,r},disable(){return o.enabled=!1,r}};return r};return n&&"string"==typeof n&&(o._defaults=e,o._methods=i),o}export function addEventModifiers({iEvent:t,interaction:{modification:{result:n}}}){n&&(t.modifiers=n.eventProps)}const n={id:"modifiers/base",install(t){t.defaults.perAction.modifiers=[]},listeners:{"interactions:new"({interaction:n}){n.modification=new t(n)},"interactions:before-action-start"(t){const{modification:n}=t.interaction;n.start(t,t.interaction.coords.start.page),t.interaction.edges=n.edges,n.applyToInteraction(t)},"interactions:before-action-move"(t){return t.interaction.modification.setAndApply(t)},"interactions:before-action-end"(t){return t.interaction.modification.beforeEnd(t)},"interactions:action-start":addEventModifiers,"interactions:action-move":addEventModifiers,"interactions:action-end":addEventModifiers,"interactions:after-action-start"(t){return t.interaction.modification.restoreInteractionCoords(t)},"interactions:after-action-move"(t){return t.interaction.modification.restoreInteractionCoords(t)},"interactions:stop"(t){return t.interaction.modification.stop(t)}},before:["actions"]};export default n;
//# sourceMappingURL=base.min.js.map

@@ -271,7 +271,2 @@ import clone from "../utils/clone.js";

} = modifierList[index];
if (options && options.enabled === false) {
continue;
}
this.states.push({

@@ -373,3 +368,3 @@ options,

if (actionModifiers && actionModifiers.length) {
return actionModifiers.filter(modifier => !modifier.options || modifier.options.enabled !== false);
return actionModifiers;
}

@@ -376,0 +371,0 @@

@@ -1,2 +0,2 @@

import t from"../utils/clone.min.js";import e from"../utils/extend.min.js";import*as s from"../utils/rect.min.js";export default class o{constructor(t){this.states=[],this.startOffset={left:0,right:0,top:0,bottom:0},this.startDelta=null,this.result=null,this.endResult=null,this.edges=void 0,this.interaction=void 0,this.interaction=t,this.result=r()}start({phase:t},s){const{interaction:o}=this,i=function(t){const e=t.interactable.options[t.prepared.name],s=e.modifiers;if(s&&s.length)return s.filter(t=>!t.options||!1!==t.options.enabled);return["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={phase:t,pageCoords:s,preEnd:!1};this.result=r(),this.startAll(n);return this.result=this.setAll(n)}fillArg(t){const{interaction:e}=this;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}startAll(t){this.fillArg(t);for(const e of this.states)e.methods.start&&(t.state=e,e.methods.start(t))}setAll(t){this.fillArg(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){const{options:n}=r,a=e({},t.coords);let l=null;r.methods.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,d=this.result.rect;if(h&&d){const t=c.rect.left!==d.left||c.rect.right!==d.right||c.rect.top!==d.top||c.rect.bottom!==d.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,h=t.rect||s.rect;h.left+=c.left,h.right+=c.right,h.top+=c.top,h.bottom+=c.bottom,h.width=h.right-h.left,h.height=h.bottom-h.top}setAndApply(t){const{interaction:e}=this,{phase:s,preEnd:o,skipModifiers:r}=t,i=this.setAll({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];s&&!1===s.enabled||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.min.js";import e from"../utils/extend.min.js";import*as s from"../utils/rect.min.js";export default class o{constructor(t){this.states=[],this.startOffset={left:0,right:0,top:0,bottom:0},this.startDelta=null,this.result=null,this.endResult=null,this.edges=void 0,this.interaction=void 0,this.interaction=t,this.result=r()}start({phase:t},s){const{interaction:o}=this,i=function(t){const e=t.interactable.options[t.prepared.name],s=e.modifiers;if(s&&s.length)return s;return["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={phase:t,pageCoords:s,preEnd:!1};this.result=r(),this.startAll(n);return this.result=this.setAll(n)}fillArg(t){const{interaction:e}=this;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}startAll(t){this.fillArg(t);for(const e of this.states)e.methods.start&&(t.state=e,e.methods.start(t))}setAll(t){this.fillArg(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){const{options:n}=r,a=e({},t.coords);let l=null;r.methods.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,d=this.result.rect;if(h&&d){const t=c.rect.left!==d.left||c.rect.right!==d.right||c.rect.top!==d.top||c.rect.bottom!==d.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,h=t.rect||s.rect;h.left+=c.left,h.right+=c.right,h.top+=c.top,h.bottom+=c.bottom,h.width=h.right-h.left,h.height=h.bottom-h.top}setAndApply(t){const{interaction:e}=this,{phase:s,preEnd:o,skipModifiers:r}=t,i=this.setAll({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.min.js.map
{
"name": "@interactjs/modifiers",
"version": "1.9.19",
"version": "1.9.20",
"license": "MIT",
"dependencies": {
"@interactjs/snappers": "1.9.19"
"@interactjs/snappers": "1.9.20"
},
"peerDependencies": {
"@interactjs/core": "1.9.19",
"@interactjs/utils": "1.9.19"
"@interactjs/core": "1.9.20",
"@interactjs/utils": "1.9.20"
},
"optionalDependencies": {
"@interactjs/interact": "1.9.19"
"@interactjs/interact": "1.9.20"
},

@@ -15,0 +15,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc