Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@interactjs/core

Package Overview
Dependencies
Maintainers
2
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interactjs/core - npm Package Compare versions

Comparing version 1.9.20 to 1.9.21

1

BaseEvent.js

@@ -45,3 +45,2 @@ export class BaseEvent {

});
export default BaseEvent;
//# sourceMappingURL=BaseEvent.js.map

2

BaseEvent.min.js

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

export class BaseEvent{constructor(t){this.type=void 0,this.target=void 0,this.currentTarget=void 0,this.interactable=void 0,this._interaction=void 0,this.timeStamp=void 0,this.immediatePropagationStopped=!1,this.propagationStopped=!1,this._interaction=t}preventDefault(){}stopPropagation(){this.propagationStopped=!0}stopImmediatePropagation(){this.immediatePropagationStopped=this.propagationStopped=!0}}Object.defineProperty(BaseEvent.prototype,"interaction",{get(){return this._interaction._proxy},set(){}});export default BaseEvent;
export class BaseEvent{constructor(t){this.type=void 0,this.target=void 0,this.currentTarget=void 0,this.interactable=void 0,this._interaction=void 0,this.timeStamp=void 0,this.immediatePropagationStopped=!1,this.propagationStopped=!1,this._interaction=t}preventDefault(){}stopPropagation(){this.propagationStopped=!0}stopImmediatePropagation(){this.immediatePropagationStopped=this.propagationStopped=!0}}Object.defineProperty(BaseEvent.prototype,"interaction",{get(){return this._interaction._proxy},set(){}});
//# sourceMappingURL=BaseEvent.min.js.map

@@ -234,6 +234,7 @@ import * as arr from "../utils/arr.js";

export class FakeEvent {
class FakeEvent {
constructor(originalEvent) {
this.currentTarget = void 0;
this.originalEvent = void 0;
this.type = void 0;
this.originalEvent = originalEvent; // duplicate the event so that currentTarget can be changed

@@ -240,0 +241,0 @@

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

import*as e from"../utils/arr.min.js";import*as t from"../utils/domUtils.min.js";import n from"../utils/extend.min.js";import s from"../utils/is.min.js";import r from"../utils/pointerExtend.min.js";import*as i from"../utils/pointerUtils.min.js";export class FakeEvent{constructor(e){this.currentTarget=void 0,this.originalEvent=void 0,this.originalEvent=e,r(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}function o(e){if(!s.object(e))return{capture:!!e,passive:!1};const t=n({},e);return t.capture=!!e.capture,t.passive=!!e.passive,t}export default{id:"events",install(n){const r=[],a={},l=[],p={add:c,remove:u,addDelegate(t,n,s,r,i){const p=o(i);if(!a[s]){a[s]=[];for(const e of l)c(e,s,v),c(e,s,f,!0)}const u=a[s];let d=e.find(u,e=>e.selector===t&&e.context===n);d||(d={selector:t,context:n,listeners:[]},u.push(d)),d.listeners.push([r,p])},removeDelegate(e,t,n,s,r){const i=o(r),l=a[n];let p,c=!1;if(l)for(p=l.length-1;p>=0;p--){const r=l[p];if(r.selector===e&&r.context===t){const{listeners:e}=r;for(let r=e.length-1;r>=0;r--){const[o,{capture:a,passive:d}]=e[r];if(o===s&&a===i.capture&&d===i.passive){e.splice(r,1),e.length||(l.splice(p,1),u(t,n,v),u(t,n,f,!0)),c=!0;break}}if(c)break}}},delegateListener:v,delegateUseCapture:f,delegatedEvents:a,documents:l,targets:r,supportsOptions:!1,supportsPassive:!1};function c(t,n,s,i){const a=o(i);let l=e.find(r,e=>e.eventTarget===t);l||(l={eventTarget:t,events:{}},r.push(l)),l.events[n]||(l.events[n]=[]),t.addEventListener&&!e.contains(l.events[n],s)&&(t.addEventListener(n,s,p.supportsOptions?a:a.capture),l.events[n].push(s))}function u(t,n,s,i){const a=o(i),l=e.findIndex(r,e=>e.eventTarget===t),c=r[l];if(!c||!c.events)return;if("all"===n){for(n in c.events)c.events.hasOwnProperty(n)&&u(t,n,"all");return}let v=!1;const f=c.events[n];if(f){if("all"===s){for(let e=f.length-1;e>=0;e--)u(t,n,f[e],a);return}for(let e=0;e<f.length;e++)if(f[e]===s){t.removeEventListener(n,s,p.supportsOptions?a:a.capture),f.splice(e,1),0===f.length&&(delete c.events[n],v=!0);break}}v&&!Object.keys(c.events).length&&r.splice(l,1)}function v(e,n){const r=o(n),l=new FakeEvent(e),p=a[e.type],[c]=i.getEventTargets(e);let u=c;for(;s.element(u);){for(let e=0;e<p.length;e++){const n=p[e],{selector:s,context:i}=n;if(t.matchesSelector(u,s)&&t.nodeContains(i,c)&&t.nodeContains(i,u)){const{listeners:e}=n;l.currentTarget=u;for(const[t,{capture:n,passive:s}]of e)n===r.capture&&s===r.passive&&t(l)}}u=t.parentNode(u)}}function f(e){return v(e,!0)}return n.document.createElement("div").addEventListener("test",null,{get capture(){return p.supportsOptions=!0},get passive(){return p.supportsPassive=!0}}),n.events=p,p}};
import*as e from"../utils/arr.min.js";import*as t from"../utils/domUtils.min.js";import s from"../utils/extend.min.js";import n from"../utils/is.min.js";import r from"../utils/pointerExtend.min.js";import*as i from"../utils/pointerUtils.min.js";class o{constructor(e){this.currentTarget=void 0,this.originalEvent=void 0,this.type=void 0,this.originalEvent=e,r(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}function a(e){if(!n.object(e))return{capture:!!e,passive:!1};const t=s({},e);return t.capture=!!e.capture,t.passive=!!e.passive,t}export default{id:"events",install(s){const r=[],l={},p=[],c={add:u,remove:v,addDelegate(t,s,n,r,i){const o=a(i);if(!l[n]){l[n]=[];for(const e of p)u(e,n,f),u(e,n,d,!0)}const c=l[n];let v=e.find(c,e=>e.selector===t&&e.context===s);v||(v={selector:t,context:s,listeners:[]},c.push(v)),v.listeners.push([r,o])},removeDelegate(e,t,s,n,r){const i=a(r),o=l[s];let p,c=!1;if(o)for(p=o.length-1;p>=0;p--){const r=o[p];if(r.selector===e&&r.context===t){const{listeners:e}=r;for(let r=e.length-1;r>=0;r--){const[a,{capture:l,passive:u}]=e[r];if(a===n&&l===i.capture&&u===i.passive){e.splice(r,1),e.length||(o.splice(p,1),v(t,s,f),v(t,s,d,!0)),c=!0;break}}if(c)break}}},delegateListener:f,delegateUseCapture:d,delegatedEvents:l,documents:p,targets:r,supportsOptions:!1,supportsPassive:!1};function u(t,s,n,i){const o=a(i);let l=e.find(r,e=>e.eventTarget===t);l||(l={eventTarget:t,events:{}},r.push(l)),l.events[s]||(l.events[s]=[]),t.addEventListener&&!e.contains(l.events[s],n)&&(t.addEventListener(s,n,c.supportsOptions?o:o.capture),l.events[s].push(n))}function v(t,s,n,i){const o=a(i),l=e.findIndex(r,e=>e.eventTarget===t),p=r[l];if(!p||!p.events)return;if("all"===s){for(s in p.events)p.events.hasOwnProperty(s)&&v(t,s,"all");return}let u=!1;const f=p.events[s];if(f){if("all"===n){for(let e=f.length-1;e>=0;e--)v(t,s,f[e],o);return}for(let e=0;e<f.length;e++)if(f[e]===n){t.removeEventListener(s,n,c.supportsOptions?o:o.capture),f.splice(e,1),0===f.length&&(delete p.events[s],u=!0);break}}u&&!Object.keys(p.events).length&&r.splice(l,1)}function f(e,s){const r=a(s),p=new o(e),c=l[e.type],[u]=i.getEventTargets(e);let v=u;for(;n.element(v);){for(let e=0;e<c.length;e++){const s=c[e],{selector:n,context:i}=s;if(t.matchesSelector(v,n)&&t.nodeContains(i,u)&&t.nodeContains(i,v)){const{listeners:e}=s;p.currentTarget=v;for(const[t,{capture:s,passive:n}]of e)s===r.capture&&n===r.passive&&t(p)}}v=t.parentNode(v)}}function d(e){return f(e,!0)}return s.document.createElement("div").addEventListener("test",null,{get capture(){return c.supportsOptions=!0},get passive(){return c.supportsPassive=!0}}),s.events=c,c}};
//# sourceMappingURL=events.min.js.map

@@ -21,3 +21,3 @@ import * as arr from "../utils/arr.js";

const targetMappings = is.string(target) ? this.selectorMap[target] : target[this.scope.id];
const targetIndex = targetMappings.findIndex(m => m.context === context);
const targetIndex = arr.findIndex(targetMappings, m => m.context === context);

@@ -24,0 +24,0 @@ if (targetMappings[targetIndex]) {

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

import*as t from"../utils/arr.min.js";import*as e from"../utils/domUtils.min.js";import s from"../utils/extend.min.js";import i from"../utils/is.min.js";export class InteractableSet{constructor(t){this.list=[],this.selectorMap={},this.scope=void 0,this.scope=t,t.addListeners({"interactable:unset":({interactable:t})=>{const{target:e,_context:s}=t,n=i.string(e)?this.selectorMap[e]:e[this.scope.id],o=n.findIndex(t=>t.context===s);n[o]&&(n[o].context=null,n[o].interactable=null),n.splice(o,1)}})}new(t,e){e=s(e||{},{actions:this.scope.actions});const n=new this.scope.Interactable(t,e,this.scope.document,this.scope.events),o={context:n._context,interactable:n};return this.scope.addDocument(n._doc),this.list.push(n),i.string(t)?(this.selectorMap[t]||(this.selectorMap[t]=[]),this.selectorMap[t].push(o)):(n.target[this.scope.id]||Object.defineProperty(t,this.scope.id,{value:[],configurable:!0}),t[this.scope.id].push(o)),this.scope.fire("interactable:new",{target:t,options:e,interactable:n,win:this.scope._win}),n}get(e,s){const n=s&&s.context||this.scope.document,o=i.string(e),c=o?this.selectorMap[e]:e[this.scope.id];if(!c)return null;const r=t.find(c,t=>t.context===n&&(o||t.interactable.inContext(e)));return r&&r.interactable}forEachMatch(t,s){for(const n of this.list){let o;if((i.string(n.target)?i.element(t)&&e.matchesSelector(t,n.target):t===n.target)&&n.inContext(t)&&(o=s(n)),void 0!==o)return o}}}
import*as t from"../utils/arr.min.js";import*as e from"../utils/domUtils.min.js";import s from"../utils/extend.min.js";import i from"../utils/is.min.js";export class InteractableSet{constructor(e){this.list=[],this.selectorMap={},this.scope=void 0,this.scope=e,e.addListeners({"interactable:unset":({interactable:e})=>{const{target:s,_context:n}=e,o=i.string(s)?this.selectorMap[s]:s[this.scope.id],c=t.findIndex(o,t=>t.context===n);o[c]&&(o[c].context=null,o[c].interactable=null),o.splice(c,1)}})}new(t,e){e=s(e||{},{actions:this.scope.actions});const n=new this.scope.Interactable(t,e,this.scope.document,this.scope.events),o={context:n._context,interactable:n};return this.scope.addDocument(n._doc),this.list.push(n),i.string(t)?(this.selectorMap[t]||(this.selectorMap[t]=[]),this.selectorMap[t].push(o)):(n.target[this.scope.id]||Object.defineProperty(t,this.scope.id,{value:[],configurable:!0}),t[this.scope.id].push(o)),this.scope.fire("interactable:new",{target:t,options:e,interactable:n,win:this.scope._win}),n}get(e,s){const n=s&&s.context||this.scope.document,o=i.string(e),c=o?this.selectorMap[e]:e[this.scope.id];if(!c)return null;const r=t.find(c,t=>t.context===n&&(o||t.interactable.inContext(e)));return r&&r.interactable}forEachMatch(t,s){for(const n of this.list){let o;if((i.string(n.target)?i.element(t)&&e.matchesSelector(t,n.target):t===n.target)&&n.inContext(t)&&(o=s(n)),void 0!==o)return o}}}
//# sourceMappingURL=InteractableSet.min.js.map

@@ -165,3 +165,3 @@ import * as arr from "../utils/arr.js";

* @param {Element} element The DOM Element to target
* @return {object} interact
* @return {Boolean} Whether the interaction was successfully started
*/

@@ -303,3 +303,2 @@

this.pointerIsDown = false;
this.removePointer(pointer, event);

@@ -451,2 +450,3 @@ }

this.pointers.splice(pointerIndex, 1);
this.pointerIsDown = false;
}

@@ -453,0 +453,0 @@

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

import*as t from"../utils/arr.min.js";import e from"../utils/extend.min.js";import i from"../utils/hypot.min.js";import{warnOnce as n,copyAction as o}from"../utils/misc.min.js";import*as s from"../utils/pointerUtils.min.js";import*as r from"../utils/rect.min.js";import{InteractEvent as h}from"./InteractEvent.min.js";import{PointerInfo as p}from"./PointerInfo.min.js";export let _ProxyValues;(t=>{t.interactable="",t.element="",t.prepared="",t.pointerIsDown="",t.pointerWasMoved="",t._proxy=""})(_ProxyValues||(_ProxyValues={}));export let _ProxyMethods;(t=>{t.start="",t.move="",t.end="",t.stop="",t.interacting=""})(_ProxyMethods||(_ProxyMethods={}));let a=0;export class Interaction{get pointerMoveTolerance(){return 1}constructor({pointerType:t,scopeFire:e}){this.interactable=null,this.element=null,this.rect=void 0,this._rects=void 0,this.edges=void 0,this._scopeFire=void 0,this.prepared={name:null,axis:null,edges:null},this.pointerType=void 0,this.pointers=[],this.downEvent=null,this.downPointer={},this._latestPointer={pointer:null,event:null,eventTarget:null},this.prevEvent=null,this.pointerIsDown=!1,this.pointerWasMoved=!1,this._interacting=!1,this._ending=!1,this._stopped=!0,this._proxy=null,this.simulation=null,this.doMove=n((function(t){this.move(t)}),"The interaction.doMove() method has been renamed to interaction.move()"),this.coords={start:s.newCoords(),prev:s.newCoords(),cur:s.newCoords(),delta:s.newCoords(),velocity:s.newCoords()},this._id=a++,this._scopeFire=e,this.pointerType=t;const i=this;this._proxy={};for(const t in _ProxyValues)Object.defineProperty(this._proxy,t,{get:()=>i[t]});for(const t in _ProxyMethods)Object.defineProperty(this._proxy,t,{value(...e){return i[t](...e)}});this._scopeFire("interactions:new",{interaction:this})}pointerDown(t,e,i){const n=this.updatePointer(t,e,i,!0),o=this.pointers[n];this._scopeFire("interactions:down",{pointer:t,event:e,eventTarget:i,pointerIndex:n,pointerInfo:o,type:"down",interaction:this})}start(t,i,n){return!(this.interacting()||!this.pointerIsDown||this.pointers.length<("gesture"===t.name?2:1)||!i.options[t.name].enabled)&&(o(this.prepared,t),this.interactable=i,this.element=n,this.rect=i.getRect(n),this.edges=this.prepared.edges?e({},this.prepared.edges):{left:!0,right:!0,top:!0,bottom:!0},this._stopped=!1,this._interacting=this._doPhase({interaction:this,event:this.downEvent,phase:"start"})&&!this._stopped,this._interacting)}pointerMove(t,e,n){this.simulation||this.modification&&this.modification.endResult||this.updatePointer(t,e,n,!1);const o=this.coords.cur.page.x===this.coords.prev.page.x&&this.coords.cur.page.y===this.coords.prev.page.y&&this.coords.cur.client.x===this.coords.prev.client.x&&this.coords.cur.client.y===this.coords.prev.client.y;let r,h;this.pointerIsDown&&!this.pointerWasMoved&&(r=this.coords.cur.client.x-this.coords.start.client.x,h=this.coords.cur.client.y-this.coords.start.client.y,this.pointerWasMoved=i(r,h)>this.pointerMoveTolerance);const p=this.getPointerIndex(t),a={pointer:t,pointerIndex:p,pointerInfo:this.pointers[p],event:e,type:"move",eventTarget:n,dx:r,dy:h,duplicate:o,interaction:this};o||s.setCoordVelocity(this.coords.velocity,this.coords.delta),this._scopeFire("interactions:move",a),o||this.simulation||(this.interacting()&&(a.type=null,this.move(a)),this.pointerWasMoved&&s.copyCoords(this.coords.prev,this.coords.cur))}move(t){t&&t.event||s.setZeroCoords(this.coords.delta),(t=e({pointer:this._latestPointer.pointer,event:this._latestPointer.event,eventTarget:this._latestPointer.eventTarget,interaction:this},t||{})).phase="move",this._doPhase(t)}pointerUp(t,e,i,n){let o=this.getPointerIndex(t);-1===o&&(o=this.updatePointer(t,e,i,!1));const s=/cancel$/i.test(e.type)?"cancel":"up";this._scopeFire("interactions:"+s,{pointer:t,pointerIndex:o,pointerInfo:this.pointers[o],event:e,eventTarget:i,type:s,curEventTarget:n,interaction:this}),this.simulation||this.end(e),this.pointerIsDown=!1,this.removePointer(t,e)}documentBlur(t){this.end(t),this._scopeFire("interactions:blur",{event:t,type:"blur",interaction:this})}end(t){let e;this._ending=!0,t=t||this._latestPointer.event,this.interacting()&&(e=this._doPhase({event:t,interaction:this,phase:"end"})),this._ending=!1,!0===e&&this.stop()}currentAction(){return this._interacting?this.prepared.name:null}interacting(){return this._interacting}stop(){this._scopeFire("interactions:stop",{interaction:this}),this.interactable=this.element=null,this._interacting=!1,this._stopped=!0,this.prepared.name=this.prevEvent=null}getPointerIndex(e){const i=s.getPointerId(e);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:t.findIndex(this.pointers,t=>t.id===i)}getPointerInfo(t){return this.pointers[this.getPointerIndex(t)]}updatePointer(t,e,i,n){const o=s.getPointerId(t);let r=this.getPointerIndex(t),h=this.pointers[r];return n=!1!==n&&(n||/(down|start)$/i.test(e.type)),h?h.pointer=t:(h=new p(o,t,e,null,null),r=this.pointers.length,this.pointers.push(h)),s.setCoords(this.coords.cur,this.pointers.map(t=>t.pointer),this._now()),s.setCoordDeltas(this.coords.delta,this.coords.prev,this.coords.cur),n&&(this.pointerIsDown=!0,h.downTime=this.coords.cur.timeStamp,h.downTarget=i,s.pointerExtend(this.downPointer,t),this.interacting()||(s.copyCoords(this.coords.start,this.coords.cur),s.copyCoords(this.coords.prev,this.coords.cur),this.downEvent=e,this.pointerWasMoved=!1)),this._updateLatestPointer(t,e,i),this._scopeFire("interactions:update-pointer",{pointer:t,event:e,eventTarget:i,down:n,pointerInfo:h,pointerIndex:r,interaction:this}),r}removePointer(t,e){const i=this.getPointerIndex(t);if(-1===i)return;const n=this.pointers[i];this._scopeFire("interactions:remove-pointer",{pointer:t,event:e,eventTarget:null,pointerIndex:i,pointerInfo:n,interaction:this}),this.pointers.splice(i,1)}_updateLatestPointer(t,e,i){this._latestPointer.pointer=t,this._latestPointer.event=e,this._latestPointer.eventTarget=i}destroy(){this._latestPointer.pointer=null,this._latestPointer.event=null,this._latestPointer.eventTarget=null}_createPreparedEvent(t,e,i,n){return new h(this,t,this.prepared.name,e,this.element,i,n)}_fireEvent(t){this.interactable.fire(t),(!this.prevEvent||t.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=t)}_doPhase(t){const{event:e,phase:i,preEnd:n,type:o}=t,{rect:s}=this;s&&"move"===i&&(r.addEdges(this.edges,s,this.coords.delta[this.interactable.options.deltaSource]),s.width=s.right-s.left,s.height=s.bottom-s.top);if(!1===this._scopeFire("interactions:before-action-"+i,t))return!1;const h=t.iEvent=this._createPreparedEvent(e,i,n,o);return this._scopeFire("interactions:action-"+i,t),"start"===i&&(this.prevEvent=h),this._fireEvent(h),this._scopeFire("interactions:after-action-"+i,t),!0}_now(){return Date.now()}}export default Interaction;export{p as PointerInfo};
import*as t from"../utils/arr.min.js";import e from"../utils/extend.min.js";import i from"../utils/hypot.min.js";import{warnOnce as n,copyAction as o}from"../utils/misc.min.js";import*as s from"../utils/pointerUtils.min.js";import*as r from"../utils/rect.min.js";import{InteractEvent as h}from"./InteractEvent.min.js";import{PointerInfo as p}from"./PointerInfo.min.js";export let _ProxyValues;(t=>{t.interactable="",t.element="",t.prepared="",t.pointerIsDown="",t.pointerWasMoved="",t._proxy=""})(_ProxyValues||(_ProxyValues={}));export let _ProxyMethods;(t=>{t.start="",t.move="",t.end="",t.stop="",t.interacting=""})(_ProxyMethods||(_ProxyMethods={}));let a=0;export class Interaction{get pointerMoveTolerance(){return 1}constructor({pointerType:t,scopeFire:e}){this.interactable=null,this.element=null,this.rect=void 0,this._rects=void 0,this.edges=void 0,this._scopeFire=void 0,this.prepared={name:null,axis:null,edges:null},this.pointerType=void 0,this.pointers=[],this.downEvent=null,this.downPointer={},this._latestPointer={pointer:null,event:null,eventTarget:null},this.prevEvent=null,this.pointerIsDown=!1,this.pointerWasMoved=!1,this._interacting=!1,this._ending=!1,this._stopped=!0,this._proxy=null,this.simulation=null,this.doMove=n((function(t){this.move(t)}),"The interaction.doMove() method has been renamed to interaction.move()"),this.coords={start:s.newCoords(),prev:s.newCoords(),cur:s.newCoords(),delta:s.newCoords(),velocity:s.newCoords()},this._id=a++,this._scopeFire=e,this.pointerType=t;const i=this;this._proxy={};for(const t in _ProxyValues)Object.defineProperty(this._proxy,t,{get:()=>i[t]});for(const t in _ProxyMethods)Object.defineProperty(this._proxy,t,{value(...e){return i[t](...e)}});this._scopeFire("interactions:new",{interaction:this})}pointerDown(t,e,i){const n=this.updatePointer(t,e,i,!0),o=this.pointers[n];this._scopeFire("interactions:down",{pointer:t,event:e,eventTarget:i,pointerIndex:n,pointerInfo:o,type:"down",interaction:this})}start(t,i,n){return!(this.interacting()||!this.pointerIsDown||this.pointers.length<("gesture"===t.name?2:1)||!i.options[t.name].enabled)&&(o(this.prepared,t),this.interactable=i,this.element=n,this.rect=i.getRect(n),this.edges=this.prepared.edges?e({},this.prepared.edges):{left:!0,right:!0,top:!0,bottom:!0},this._stopped=!1,this._interacting=this._doPhase({interaction:this,event:this.downEvent,phase:"start"})&&!this._stopped,this._interacting)}pointerMove(t,e,n){this.simulation||this.modification&&this.modification.endResult||this.updatePointer(t,e,n,!1);const o=this.coords.cur.page.x===this.coords.prev.page.x&&this.coords.cur.page.y===this.coords.prev.page.y&&this.coords.cur.client.x===this.coords.prev.client.x&&this.coords.cur.client.y===this.coords.prev.client.y;let r,h;this.pointerIsDown&&!this.pointerWasMoved&&(r=this.coords.cur.client.x-this.coords.start.client.x,h=this.coords.cur.client.y-this.coords.start.client.y,this.pointerWasMoved=i(r,h)>this.pointerMoveTolerance);const p=this.getPointerIndex(t),a={pointer:t,pointerIndex:p,pointerInfo:this.pointers[p],event:e,type:"move",eventTarget:n,dx:r,dy:h,duplicate:o,interaction:this};o||s.setCoordVelocity(this.coords.velocity,this.coords.delta),this._scopeFire("interactions:move",a),o||this.simulation||(this.interacting()&&(a.type=null,this.move(a)),this.pointerWasMoved&&s.copyCoords(this.coords.prev,this.coords.cur))}move(t){t&&t.event||s.setZeroCoords(this.coords.delta),(t=e({pointer:this._latestPointer.pointer,event:this._latestPointer.event,eventTarget:this._latestPointer.eventTarget,interaction:this},t||{})).phase="move",this._doPhase(t)}pointerUp(t,e,i,n){let o=this.getPointerIndex(t);-1===o&&(o=this.updatePointer(t,e,i,!1));const s=/cancel$/i.test(e.type)?"cancel":"up";this._scopeFire("interactions:"+s,{pointer:t,pointerIndex:o,pointerInfo:this.pointers[o],event:e,eventTarget:i,type:s,curEventTarget:n,interaction:this}),this.simulation||this.end(e),this.removePointer(t,e)}documentBlur(t){this.end(t),this._scopeFire("interactions:blur",{event:t,type:"blur",interaction:this})}end(t){let e;this._ending=!0,t=t||this._latestPointer.event,this.interacting()&&(e=this._doPhase({event:t,interaction:this,phase:"end"})),this._ending=!1,!0===e&&this.stop()}currentAction(){return this._interacting?this.prepared.name:null}interacting(){return this._interacting}stop(){this._scopeFire("interactions:stop",{interaction:this}),this.interactable=this.element=null,this._interacting=!1,this._stopped=!0,this.prepared.name=this.prevEvent=null}getPointerIndex(e){const i=s.getPointerId(e);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:t.findIndex(this.pointers,t=>t.id===i)}getPointerInfo(t){return this.pointers[this.getPointerIndex(t)]}updatePointer(t,e,i,n){const o=s.getPointerId(t);let r=this.getPointerIndex(t),h=this.pointers[r];return n=!1!==n&&(n||/(down|start)$/i.test(e.type)),h?h.pointer=t:(h=new p(o,t,e,null,null),r=this.pointers.length,this.pointers.push(h)),s.setCoords(this.coords.cur,this.pointers.map(t=>t.pointer),this._now()),s.setCoordDeltas(this.coords.delta,this.coords.prev,this.coords.cur),n&&(this.pointerIsDown=!0,h.downTime=this.coords.cur.timeStamp,h.downTarget=i,s.pointerExtend(this.downPointer,t),this.interacting()||(s.copyCoords(this.coords.start,this.coords.cur),s.copyCoords(this.coords.prev,this.coords.cur),this.downEvent=e,this.pointerWasMoved=!1)),this._updateLatestPointer(t,e,i),this._scopeFire("interactions:update-pointer",{pointer:t,event:e,eventTarget:i,down:n,pointerInfo:h,pointerIndex:r,interaction:this}),r}removePointer(t,e){const i=this.getPointerIndex(t);if(-1===i)return;const n=this.pointers[i];this._scopeFire("interactions:remove-pointer",{pointer:t,event:e,eventTarget:null,pointerIndex:i,pointerInfo:n,interaction:this}),this.pointers.splice(i,1),this.pointerIsDown=!1}_updateLatestPointer(t,e,i){this._latestPointer.pointer=t,this._latestPointer.event=e,this._latestPointer.eventTarget=i}destroy(){this._latestPointer.pointer=null,this._latestPointer.event=null,this._latestPointer.eventTarget=null}_createPreparedEvent(t,e,i,n){return new h(this,t,this.prepared.name,e,this.element,i,n)}_fireEvent(t){this.interactable.fire(t),(!this.prevEvent||t.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=t)}_doPhase(t){const{event:e,phase:i,preEnd:n,type:o}=t,{rect:s}=this;s&&"move"===i&&(r.addEdges(this.edges,s,this.coords.delta[this.interactable.options.deltaSource]),s.width=s.right-s.left,s.height=s.bottom-s.top);if(!1===this._scopeFire("interactions:before-action-"+i,t))return!1;const h=t.iEvent=this._createPreparedEvent(e,i,n,o);return this._scopeFire("interactions:action-"+i,t),"start"===i&&(this.prevEvent=h),this._fireEvent(h),this._scopeFire("interactions:after-action-"+i,t),!0}_now(){return Date.now()}}export default Interaction;export{p as PointerInfo};
//# sourceMappingURL=Interaction.min.js.map

@@ -138,3 +138,3 @@ import browser from "../utils/browser.js";

if (/^touch/.test(event.type)) {
scope.prevTouchTime = scope.now();
scope.prevTouchTime = scope.now(); // @ts-expect-error

@@ -141,0 +141,0 @@ for (const changedTouch of event.changedTouches) {

@@ -55,3 +55,3 @@ /** @module interact */

interact.version = "1.9.20";
interact.version = "1.9.21";
interact.scope = scope;

@@ -58,0 +58,0 @@ /**

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

import t from"../utils/browser.min.js";import*as e from"../utils/domUtils.min.js";import o from"../utils/is.min.js";import*as s from"../utils/pointerUtils.min.js";import n from"./isNonNativeEvent.min.js";export function createInteractStatic(i){const r=(t,e)=>{let o=i.interactables.get(t,e);return o||(o=i.interactables.new(t,e),o.events.global=r.globalEvents),o};return r.getPointerAverage=s.pointerAverage,r.getTouchBBox=s.touchBBox,r.getTouchDistance=s.touchDistance,r.getTouchAngle=s.touchAngle,r.getElementRect=e.getElementRect,r.getElementClientRect=e.getElementClientRect,r.matchesSelector=e.matchesSelector,r.closest=e.closest,r.globalEvents={},r.version="1.9.20",r.scope=i,r.use=function(t,e){return this.scope.usePlugin(t,e),this},r.isSet=function(t,e){return!!this.scope.interactables.get(t,e&&e.context)},r.on=function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.on(o,e,s);return this}if(o.object(t)){for(const o in t)this.on(o,t[o],e);return this}return n(t,this.scope.actions)?this.globalEvents[t]?this.globalEvents[t].push(e):this.globalEvents[t]=[e]:this.scope.events.add(this.scope.document,t,e,{options:s}),this},r.off=function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.off(o,e,s);return this}if(o.object(t)){for(const o in t)this.off(o,t[o],e);return this}if(n(t,this.scope.actions)){let o;t in this.globalEvents&&-1!==(o=this.globalEvents[t].indexOf(e))&&this.globalEvents[t].splice(o,1)}else this.scope.events.remove(this.scope.document,t,e,s);return this},r.debug=function(){return this.scope},r.supportsTouch=()=>t.supportsTouch,r.supportsPointerEvent=()=>t.supportsPointerEvent,r.stop=function(){for(const t of this.scope.interactions.list)t.stop();return this},r.pointerMoveTolerance=function(t){return o.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance},r.addDocument=function(t,e){this.scope.addDocument(t,e)},r.removeDocument=function(t){this.scope.removeDocument(t)},r}
import t from"../utils/browser.min.js";import*as e from"../utils/domUtils.min.js";import o from"../utils/is.min.js";import*as s from"../utils/pointerUtils.min.js";import n from"./isNonNativeEvent.min.js";export function createInteractStatic(i){const r=(t,e)=>{let o=i.interactables.get(t,e);return o||(o=i.interactables.new(t,e),o.events.global=r.globalEvents),o};return r.getPointerAverage=s.pointerAverage,r.getTouchBBox=s.touchBBox,r.getTouchDistance=s.touchDistance,r.getTouchAngle=s.touchAngle,r.getElementRect=e.getElementRect,r.getElementClientRect=e.getElementClientRect,r.matchesSelector=e.matchesSelector,r.closest=e.closest,r.globalEvents={},r.version="1.9.21",r.scope=i,r.use=function(t,e){return this.scope.usePlugin(t,e),this},r.isSet=function(t,e){return!!this.scope.interactables.get(t,e&&e.context)},r.on=function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.on(o,e,s);return this}if(o.object(t)){for(const o in t)this.on(o,t[o],e);return this}return n(t,this.scope.actions)?this.globalEvents[t]?this.globalEvents[t].push(e):this.globalEvents[t]=[e]:this.scope.events.add(this.scope.document,t,e,{options:s}),this},r.off=function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.off(o,e,s);return this}if(o.object(t)){for(const o in t)this.off(o,t[o],e);return this}if(n(t,this.scope.actions)){let o;t in this.globalEvents&&-1!==(o=this.globalEvents[t].indexOf(e))&&this.globalEvents[t].splice(o,1)}else this.scope.events.remove(this.scope.document,t,e,s);return this},r.debug=function(){return this.scope},r.supportsTouch=()=>t.supportsTouch,r.supportsPointerEvent=()=>t.supportsPointerEvent,r.stop=function(){for(const t of this.scope.interactions.list)t.stop();return this},r.pointerMoveTolerance=function(t){return o.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance},r.addDocument=function(t,e){this.scope.addDocument(t,e)},r.removeDocument=function(t){this.scope.removeDocument(t)},r}
//# sourceMappingURL=interactStatic.min.js.map
{
"name": "@interactjs/core",
"version": "1.9.20",
"version": "1.9.21",
"license": "MIT",
"peerDependencies": {
"@interactjs/utils": "1.9.20"
"@interactjs/utils": "1.9.21"
},

@@ -8,0 +8,0 @@ "publishConfig": {

@@ -6,3 +6,3 @@ import browser from "../utils/browser.js";

import raf from "../utils/raf.js";
import win from "../utils/window.js";
import * as win from "../utils/window.js";
import { Eventable } from "./Eventable.js";

@@ -9,0 +9,0 @@ import { InteractEvent } from "./InteractEvent.js";

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

import t from"../utils/browser.min.js";import i from"../utils/clone.min.js";import s from"../utils/domObjects.min.js";import e from"../utils/extend.min.js";import n from"../utils/raf.min.js";import o from"../utils/window.min.js";import{Eventable as r}from"./Eventable.min.js";import{InteractEvent as a}from"./InteractEvent.min.js";import{Interactable as l}from"./Interactable.min.js";import{InteractableSet as d}from"./InteractableSet.min.js";import{defaults as h}from"./defaultOptions.min.js";import c from"./events.min.js";import{createInteractStatic as m}from"./interactStatic.min.js";import u from"./interactions.min.js";export class Scope{constructor(){this.id="__interact_scope_"+Math.floor(100*Math.random()),this.isInitialized=!1,this.listenerMaps=[],this.browser=t,this.defaults=i(h),this.Eventable=r,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=m(this),this.InteractEvent=a,this.Interactable=void 0,this.interactables=new d(this),this._win=void 0,this.document=void 0,this.window=void 0,this.documents=[],this._plugins={list:[],map:{}},this.onWindowUnload=t=>this.removeDocument(t.target);const s=this;this.Interactable=class extends l{get _defaults(){return s.defaults}set(t){return super.set(t),s.fire("interactable:set",{options:t,interactable:this}),this}unset(){super.unset(),s.interactables.list.splice(s.interactables.list.indexOf(this),1),s.fire("interactable:unset",{interactable:this})}}}addListeners(t,i){this.listenerMaps.push({id:i,map:t})}fire(t,i){for(const{map:{[t]:s}}of this.listenerMaps)if(s&&!1===s(i,this,t))return!1}init(t){return this.isInitialized?this:initScope(this,t)}pluginIsInstalled(t){return this._plugins.map[t.id]||-1!==this._plugins.list.indexOf(t)}usePlugin(t,i){if(!this.isInitialized)return this;if(this.pluginIsInstalled(t))return this;if(t.id&&(this._plugins.map[t.id]=t),this._plugins.list.push(t),t.install&&t.install(this,i),t.listeners&&t.before){let i=0;const s=this.listenerMaps.length,e=t.before.reduce((t,i)=>(t[i]=!0,t[p(i)]=!0,t),{});for(;i<s;i++){const t=this.listenerMaps[i].id;if(e[t]||e[p(t)])break}this.listenerMaps.splice(i,0,{id:t.id,map:t.listeners})}else t.listeners&&this.listenerMaps.push({id:t.id,map:t.listeners});return this}addDocument(t,i){if(-1!==this.getDocIndex(t))return!1;const s=o.getWindow(t);i=i?e({},i):{},this.documents.push({doc:t,options:i}),this.events.documents.push(t),t!==this.document&&this.events.add(s,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:s,scope:this,options:i})}removeDocument(t){const i=this.getDocIndex(t),s=o.getWindow(t),e=this.documents[i].options;this.events.remove(s,"unload",this.onWindowUnload),this.documents.splice(i,1),this.events.documents.splice(i,1),this.fire("scope:remove-document",{doc:t,window:s,scope:this,options:e})}getDocIndex(t){for(let i=0;i<this.documents.length;i++)if(this.documents[i].doc===t)return i;return-1}getDocOptions(t){const i=this.getDocIndex(t);return-1===i?null:this.documents[i].options}now(){return(this.window.Date||Date).now()}}export function initScope(i,e){return i.isInitialized=!0,o.init(e),s.init(e),t.init(e),n.init(e),i.window=e,i.document=e.document,i.usePlugin(u),i.usePlugin(c),i}function p(t){return t&&t.replace(/\/.*$/,"")}
import t from"../utils/browser.min.js";import i from"../utils/clone.min.js";import s from"../utils/domObjects.min.js";import e from"../utils/extend.min.js";import n from"../utils/raf.min.js";import*as o from"../utils/window.min.js";import{Eventable as r}from"./Eventable.min.js";import{InteractEvent as a}from"./InteractEvent.min.js";import{Interactable as l}from"./Interactable.min.js";import{InteractableSet as d}from"./InteractableSet.min.js";import{defaults as h}from"./defaultOptions.min.js";import c from"./events.min.js";import{createInteractStatic as m}from"./interactStatic.min.js";import u from"./interactions.min.js";export class Scope{constructor(){this.id="__interact_scope_"+Math.floor(100*Math.random()),this.isInitialized=!1,this.listenerMaps=[],this.browser=t,this.defaults=i(h),this.Eventable=r,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=m(this),this.InteractEvent=a,this.Interactable=void 0,this.interactables=new d(this),this._win=void 0,this.document=void 0,this.window=void 0,this.documents=[],this._plugins={list:[],map:{}},this.onWindowUnload=t=>this.removeDocument(t.target);const s=this;this.Interactable=class extends l{get _defaults(){return s.defaults}set(t){return super.set(t),s.fire("interactable:set",{options:t,interactable:this}),this}unset(){super.unset(),s.interactables.list.splice(s.interactables.list.indexOf(this),1),s.fire("interactable:unset",{interactable:this})}}}addListeners(t,i){this.listenerMaps.push({id:i,map:t})}fire(t,i){for(const{map:{[t]:s}}of this.listenerMaps)if(s&&!1===s(i,this,t))return!1}init(t){return this.isInitialized?this:initScope(this,t)}pluginIsInstalled(t){return this._plugins.map[t.id]||-1!==this._plugins.list.indexOf(t)}usePlugin(t,i){if(!this.isInitialized)return this;if(this.pluginIsInstalled(t))return this;if(t.id&&(this._plugins.map[t.id]=t),this._plugins.list.push(t),t.install&&t.install(this,i),t.listeners&&t.before){let i=0;const s=this.listenerMaps.length,e=t.before.reduce((t,i)=>(t[i]=!0,t[p(i)]=!0,t),{});for(;i<s;i++){const t=this.listenerMaps[i].id;if(e[t]||e[p(t)])break}this.listenerMaps.splice(i,0,{id:t.id,map:t.listeners})}else t.listeners&&this.listenerMaps.push({id:t.id,map:t.listeners});return this}addDocument(t,i){if(-1!==this.getDocIndex(t))return!1;const s=o.getWindow(t);i=i?e({},i):{},this.documents.push({doc:t,options:i}),this.events.documents.push(t),t!==this.document&&this.events.add(s,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:s,scope:this,options:i})}removeDocument(t){const i=this.getDocIndex(t),s=o.getWindow(t),e=this.documents[i].options;this.events.remove(s,"unload",this.onWindowUnload),this.documents.splice(i,1),this.events.documents.splice(i,1),this.fire("scope:remove-document",{doc:t,window:s,scope:this,options:e})}getDocIndex(t){for(let i=0;i<this.documents.length;i++)if(this.documents[i].doc===t)return i;return-1}getDocOptions(t){const i=this.getDocIndex(t);return-1===i?null:this.documents[i].options}now(){return(this.window.Date||Date).now()}}export function initScope(i,e){return i.isInitialized=!0,o.init(e),s.init(e),t.init(e),n.init(e),i.window=e,i.document=e.document,i.usePlugin(u),i.usePlugin(c),i}function p(t){return t&&t.replace(/\/.*$/,"")}
//# sourceMappingURL=scope.min.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

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