You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@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

Comparing version 1.10.14 to 1.10.15

4

Interactable.js

@@ -10,4 +10,4 @@ /* eslint-disable no-dupe-class-members */

import { getWindow } from "../utils/window.js";
import { Eventable } from "./Eventable.js";
import isNonNativeEvent from "./isNonNativeEvent.js";
import { Eventable } from './Eventable';
import isNonNativeEvent from './isNonNativeEvent';

@@ -14,0 +14,0 @@ /** */

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

import*as t from"../utils/arr.prod.js";import e from"../utils/browser.prod.js";import s from"../utils/clone.prod.js";import{getElementRect as o,matchesUpTo as n,nodeContains as i,trySelector as r}from"../utils/domUtils.prod.js";import c from"../utils/extend.prod.js";import h from"../utils/is.prod.js";import a from"../utils/normalizeListeners.prod.js";import{getWindow as l}from"../utils/window.prod.js";import{Eventable as p}from"./Eventable.prod.js";import u from"./isNonNativeEvent.prod.js";export class Interactable{get _defaults(){return{base:{},perAction:{},actions:{}}}options;_actions;target;events=new p;_context;_win;_doc;_scopeEvents;_rectChecker;constructor(t,e,s,o){this._actions=e.actions,this.target=t,this._context=e.context||s,this._win=l(r(t)?this._context:t),this._doc=this._win.document,this._scopeEvents=o,this.set(e)}setOnEvents(t,e){return h.func(e.onstart)&&this.on(t+"start",e.onstart),h.func(e.onmove)&&this.on(t+"move",e.onmove),h.func(e.onend)&&this.on(t+"end",e.onend),h.func(e.oninertiastart)&&this.on(t+"inertiastart",e.oninertiastart),this}updatePerActionListeners(t,e,s){(h.array(e)||h.object(e))&&this.off(t,e),(h.array(s)||h.object(s))&&this.on(t,s)}setPerAction(e,o){const n=this._defaults;for(const i in o){const r=i,a=this.options[e],l=o[r];"listeners"===r&&this.updatePerActionListeners(e,a.listeners,l),h.array(l)?a[r]=t.from(l):h.plainObject(l)?(a[r]=c(a[r]||{},s(l)),h.object(n.perAction[r])&&"enabled"in n.perAction[r]&&(a[r].enabled=!1!==l.enabled)):h.bool(l)&&h.object(n.perAction[r])?a[r].enabled=l:a[r]=l}}getRect(t){return t=t||(h.element(this.target)?this.target:null),h.string(this.target)&&(t=t||this._context.querySelector(this.target)),o(t)}rectChecker(t){return h.func(t)?(this._rectChecker=t,this.getRect=t=>{const e=c({},this._rectChecker(t));return"width"in e||(e.width=e.right-e.left,e.height=e.bottom-e.top),e},this):null===t?(delete this.getRect,delete this._rectChecker,this):this.getRect}_backCompatOption(t,e){if(r(e)||h.object(e)){this.options[t]=e;for(const s in this._actions.map)this.options[s][t]=e;return this}return this.options[t]}origin(t){return this._backCompatOption("origin",t)}deltaSource(t){return"page"===t||"client"===t?(this.options.deltaSource=t,this):this.options.deltaSource}context(){return this._context}inContext(t){return this._context===t.ownerDocument||i(this._context,t)}testIgnoreAllow(t,e,s){return!this.testIgnore(t.ignoreFrom,e,s)&&this.testAllow(t.allowFrom,e,s)}testAllow(t,e,s){return!t||!!h.element(s)&&(h.string(t)?n(s,t,e):!!h.element(t)&&i(t,s))}testIgnore(t,e,s){return!(!t||!h.element(s))&&(h.string(t)?n(s,t,e):!!h.element(t)&&i(t,s))}fire(t){return this.events.fire(t),this}_onOff(t,s,o,n){h.object(s)&&!h.array(s)&&(n=o,o=null);const i="on"===t?"add":"remove",r=a(s,o);for(let s in r){"wheel"===s&&(s=e.wheelEvent);for(const e of r[s])u(s,this._actions)?this.events[t](s,e):h.string(this.target)?this._scopeEvents[i+"Delegate"](this.target,this._context,s,e,n):this._scopeEvents[i](this.target,s,e,n)}return this}on(t,e,s){return this._onOff("on",t,e,s)}off(t,e,s){return this._onOff("off",t,e,s)}set(t){const e=this._defaults;h.object(t)||(t={}),this.options=s(e.base);for(const s in this._actions.methodDict){const o=s,n=this._actions.methodDict[o];this.options[o]={},this.setPerAction(o,c(c({},e.perAction),e.actions[o])),this[n](t[o])}for(const e in t)h.func(this[e])&&this[e](t[e]);return this}unset(){if(h.string(this.target))for(const t in this._scopeEvents.delegatedEvents){const e=this._scopeEvents.delegatedEvents[t];for(let s=e.length-1;s>=0;s--){const{selector:o,context:n,listeners:i}=e[s];o===this.target&&n===this._context&&e.splice(s,1);for(let e=i.length-1;e>=0;e--)this._scopeEvents.removeDelegate(this.target,this._context,t,i[e][0],i[e][1])}}else this._scopeEvents.remove(this.target,"all")}}
import*as t from"../utils/arr.prod.js";import e from"../utils/browser.prod.js";import s from"../utils/clone.prod.js";import{getElementRect as o,matchesUpTo as n,nodeContains as i,trySelector as r}from"../utils/domUtils.prod.js";import c from"../utils/extend.prod.js";import h from"../utils/is.prod.js";import a from"../utils/normalizeListeners.prod.js";import{getWindow as l}from"../utils/window.prod.js";import{Eventable as p}from"./Eventable";import u from"./isNonNativeEvent";export class Interactable{get _defaults(){return{base:{},perAction:{},actions:{}}}options;_actions;target;events=new p;_context;_win;_doc;_scopeEvents;_rectChecker;constructor(t,e,s,o){this._actions=e.actions,this.target=t,this._context=e.context||s,this._win=l(r(t)?this._context:t),this._doc=this._win.document,this._scopeEvents=o,this.set(e)}setOnEvents(t,e){return h.func(e.onstart)&&this.on(t+"start",e.onstart),h.func(e.onmove)&&this.on(t+"move",e.onmove),h.func(e.onend)&&this.on(t+"end",e.onend),h.func(e.oninertiastart)&&this.on(t+"inertiastart",e.oninertiastart),this}updatePerActionListeners(t,e,s){(h.array(e)||h.object(e))&&this.off(t,e),(h.array(s)||h.object(s))&&this.on(t,s)}setPerAction(e,o){const n=this._defaults;for(const i in o){const r=i,a=this.options[e],l=o[r];"listeners"===r&&this.updatePerActionListeners(e,a.listeners,l),h.array(l)?a[r]=t.from(l):h.plainObject(l)?(a[r]=c(a[r]||{},s(l)),h.object(n.perAction[r])&&"enabled"in n.perAction[r]&&(a[r].enabled=!1!==l.enabled)):h.bool(l)&&h.object(n.perAction[r])?a[r].enabled=l:a[r]=l}}getRect(t){return t=t||(h.element(this.target)?this.target:null),h.string(this.target)&&(t=t||this._context.querySelector(this.target)),o(t)}rectChecker(t){return h.func(t)?(this._rectChecker=t,this.getRect=t=>{const e=c({},this._rectChecker(t));return"width"in e||(e.width=e.right-e.left,e.height=e.bottom-e.top),e},this):null===t?(delete this.getRect,delete this._rectChecker,this):this.getRect}_backCompatOption(t,e){if(r(e)||h.object(e)){this.options[t]=e;for(const s in this._actions.map)this.options[s][t]=e;return this}return this.options[t]}origin(t){return this._backCompatOption("origin",t)}deltaSource(t){return"page"===t||"client"===t?(this.options.deltaSource=t,this):this.options.deltaSource}context(){return this._context}inContext(t){return this._context===t.ownerDocument||i(this._context,t)}testIgnoreAllow(t,e,s){return!this.testIgnore(t.ignoreFrom,e,s)&&this.testAllow(t.allowFrom,e,s)}testAllow(t,e,s){return!t||!!h.element(s)&&(h.string(t)?n(s,t,e):!!h.element(t)&&i(t,s))}testIgnore(t,e,s){return!(!t||!h.element(s))&&(h.string(t)?n(s,t,e):!!h.element(t)&&i(t,s))}fire(t){return this.events.fire(t),this}_onOff(t,s,o,n){h.object(s)&&!h.array(s)&&(n=o,o=null);const i="on"===t?"add":"remove",r=a(s,o);for(let s in r){"wheel"===s&&(s=e.wheelEvent);for(const e of r[s])u(s,this._actions)?this.events[t](s,e):h.string(this.target)?this._scopeEvents[i+"Delegate"](this.target,this._context,s,e,n):this._scopeEvents[i](this.target,s,e,n)}return this}on(t,e,s){return this._onOff("on",t,e,s)}off(t,e,s){return this._onOff("off",t,e,s)}set(t){const e=this._defaults;h.object(t)||(t={}),this.options=s(e.base);for(const s in this._actions.methodDict){const o=s,n=this._actions.methodDict[o];this.options[o]={},this.setPerAction(o,c(c({},e.perAction),e.actions[o])),this[n](t[o])}for(const e in t)h.func(this[e])&&this[e](t[e]);return this}unset(){if(h.string(this.target))for(const t in this._scopeEvents.delegatedEvents){const e=this._scopeEvents.delegatedEvents[t];for(let s=e.length-1;s>=0;s--){const{selector:o,context:n,listeners:i}=e[s];o===this.target&&n===this._context&&e.splice(s,1);for(let e=i.length-1;e>=0;e--)this._scopeEvents.removeDelegate(this.target,this._context,t,i[e][0],i[e][1])}}else this._scopeEvents.remove(this.target,"all")}}
//# sourceMappingURL=Interactable.prod.js.map
import extend from "../utils/extend.js";
import getOriginXY from "../utils/getOriginXY.js";
import hypot from "../utils/hypot.js";
import { BaseEvent } from "./BaseEvent.js";
import { defaults } from "./options.js";
import { BaseEvent } from './BaseEvent';
import { defaults } from './options';
export class InteractEvent extends BaseEvent {

@@ -7,0 +7,0 @@ relatedTarget = null;

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

import t from"../utils/extend.prod.js";import e from"../utils/getOriginXY.prod.js";import i from"../utils/hypot.prod.js";import{BaseEvent as s}from"./BaseEvent.prod.js";import{defaults as r}from"./options.prod.js";export class InteractEvent extends s{relatedTarget=null;screenX;screenY;button;buttons;ctrlKey;shiftKey;altKey;metaKey;page;client;delta;rect;x0;y0;t0;dt;duration;clientX0;clientY0;velocity;speed;swipe;axes;preEnd;constructor(s,o,n,p,a,c,l){super(s),a=a||s.element;const h=s.interactable,y=(h&&h.options||r).deltaSource,d=e(h,a,n),g="start"===p,v="end"===p,m=g?this:s.prevEvent,u=g?s.coords.start:v?{page:m.page,client:m.client,timeStamp:s.coords.cur.timeStamp}:s.coords.cur;this.page=t({},u.page),this.client=t({},u.client),this.rect=t({},s.rect),this.timeStamp=u.timeStamp,v||(this.page.x-=d.x,this.page.y-=d.y,this.client.x-=d.x,this.client.y-=d.y),this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.button=o.button,this.buttons=o.buttons,this.target=a,this.currentTarget=a,this.preEnd=c,this.type=l||n+(p||""),this.interactable=h,this.t0=g?s.pointers[s.pointers.length-1].downTime:m.t0,this.x0=s.coords.start.page.x-d.x,this.y0=s.coords.start.page.y-d.y,this.clientX0=s.coords.start.client.x-d.x,this.clientY0=s.coords.start.client.y-d.y,this.delta=g||v?{x:0,y:0}:{x:this[y].x-m[y].x,y:this[y].y-m[y].y},this.dt=s.coords.delta.timeStamp,this.duration=this.timeStamp-this.t0,this.velocity=t({},s.coords.velocity[y]),this.speed=i(this.velocity.x,this.velocity.y),this.swipe=v||"inertiastart"===p?this.getSwipe():null}getSwipe(){const t=this._interaction;if(t.prevEvent.speed<600||this.timeStamp-t.prevEvent.timeStamp>150)return null;let e=180*Math.atan2(t.prevEvent.velocityY,t.prevEvent.velocityX)/Math.PI;e<0&&(e+=360);const i=112.5<=e&&e<247.5,s=202.5<=e&&e<337.5;return{up:s,down:!s&&22.5<=e&&e<157.5,left:i,right:!i&&(292.5<=e||e<67.5),angle:e,speed:t.prevEvent.speed,velocity:{x:t.prevEvent.velocityX,y:t.prevEvent.velocityY}}}preventDefault(){}stopImmediatePropagation(){this.immediatePropagationStopped=this.propagationStopped=!0}stopPropagation(){this.propagationStopped=!0}}Object.defineProperties(InteractEvent.prototype,{pageX:{get(){return this.page.x},set(t){this.page.x=t}},pageY:{get(){return this.page.y},set(t){this.page.y=t}},clientX:{get(){return this.client.x},set(t){this.client.x=t}},clientY:{get(){return this.client.y},set(t){this.client.y=t}},dx:{get(){return this.delta.x},set(t){this.delta.x=t}},dy:{get(){return this.delta.y},set(t){this.delta.y=t}},velocityX:{get(){return this.velocity.x},set(t){this.velocity.x=t}},velocityY:{get(){return this.velocity.y},set(t){this.velocity.y=t}}});
import t from"../utils/extend.prod.js";import e from"../utils/getOriginXY.prod.js";import i from"../utils/hypot.prod.js";import{BaseEvent as s}from"./BaseEvent";import{defaults as r}from"./options";export class InteractEvent extends s{relatedTarget=null;screenX;screenY;button;buttons;ctrlKey;shiftKey;altKey;metaKey;page;client;delta;rect;x0;y0;t0;dt;duration;clientX0;clientY0;velocity;speed;swipe;axes;preEnd;constructor(s,o,n,a,p,c,l){super(s),p=p||s.element;const h=s.interactable,y=(h&&h.options||r).deltaSource,d=e(h,p,n),g="start"===a,v="end"===a,m=g?this:s.prevEvent,u=g?s.coords.start:v?{page:m.page,client:m.client,timeStamp:s.coords.cur.timeStamp}:s.coords.cur;this.page=t({},u.page),this.client=t({},u.client),this.rect=t({},s.rect),this.timeStamp=u.timeStamp,v||(this.page.x-=d.x,this.page.y-=d.y,this.client.x-=d.x,this.client.y-=d.y),this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.button=o.button,this.buttons=o.buttons,this.target=p,this.currentTarget=p,this.preEnd=c,this.type=l||n+(a||""),this.interactable=h,this.t0=g?s.pointers[s.pointers.length-1].downTime:m.t0,this.x0=s.coords.start.page.x-d.x,this.y0=s.coords.start.page.y-d.y,this.clientX0=s.coords.start.client.x-d.x,this.clientY0=s.coords.start.client.y-d.y,this.delta=g||v?{x:0,y:0}:{x:this[y].x-m[y].x,y:this[y].y-m[y].y},this.dt=s.coords.delta.timeStamp,this.duration=this.timeStamp-this.t0,this.velocity=t({},s.coords.velocity[y]),this.speed=i(this.velocity.x,this.velocity.y),this.swipe=v||"inertiastart"===a?this.getSwipe():null}getSwipe(){const t=this._interaction;if(t.prevEvent.speed<600||this.timeStamp-t.prevEvent.timeStamp>150)return null;let e=180*Math.atan2(t.prevEvent.velocityY,t.prevEvent.velocityX)/Math.PI;e<0&&(e+=360);const i=112.5<=e&&e<247.5,s=202.5<=e&&e<337.5;return{up:s,down:!s&&22.5<=e&&e<157.5,left:i,right:!i&&(292.5<=e||e<67.5),angle:e,speed:t.prevEvent.speed,velocity:{x:t.prevEvent.velocityX,y:t.prevEvent.velocityY}}}preventDefault(){}stopImmediatePropagation(){this.immediatePropagationStopped=this.propagationStopped=!0}stopPropagation(){this.propagationStopped=!0}}Object.defineProperties(InteractEvent.prototype,{pageX:{get(){return this.page.x},set(t){this.page.x=t}},pageY:{get(){return this.page.y},set(t){this.page.y=t}},clientX:{get(){return this.client.x},set(t){this.client.x=t}},clientY:{get(){return this.client.y},set(t){this.client.y=t}},dx:{get(){return this.delta.x},set(t){this.delta.x=t}},dy:{get(){return this.delta.y},set(t){this.delta.y=t}},velocityX:{get(){return this.velocity.x},set(t){this.velocity.x=t}},velocityY:{get(){return this.velocity.y},set(t){this.velocity.y=t}}});
//# sourceMappingURL=InteractEvent.prod.js.map

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

import * as rectUtils from "../utils/rect.js";
import { InteractEvent } from "./InteractEvent.js";
import { PointerInfo } from "./PointerInfo.js";
import { InteractEvent } from './InteractEvent';
import { PointerInfo } from './PointerInfo';
export let _ProxyValues;

@@ -11,0 +11,0 @@

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

import*as t from"../utils/arr.prod.js";import e from"../utils/extend.prod.js";import i from"../utils/hypot.prod.js";import{warnOnce as n,copyAction as o}from"../utils/misc.prod.js";import*as r from"../utils/pointerUtils.prod.js";import*as s from"../utils/rect.prod.js";import{InteractEvent as p}from"./InteractEvent.prod.js";import{PointerInfo as h}from"./PointerInfo.prod.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{interactable=null;element=null;rect=null;_rects;edges=null;_scopeFire;prepared={name:null,axis:null,edges:null};pointerType;pointers=[];downEvent=null;downPointer={};_latestPointer={pointer:null,event:null,eventTarget:null};prevEvent=null;pointerIsDown=!1;pointerWasMoved=!1;_interacting=!1;_ending=!1;_stopped=!0;_proxy=null;simulation=null;get pointerMoveTolerance(){return 1}doMove=n((function(t){this.move(t)}),"The interaction.doMove() method has been renamed to interaction.move()");coords={start:r.newCoords(),prev:r.newCoords(),cur:r.newCoords(),delta:r.newCoords(),velocity:r.newCoords()};_id=a++;constructor({pointerType:t,scopeFire:e}){this._scopeFire=e,this.pointerType=t;const i=this;this._proxy={};for(const t in _ProxyValues)Object.defineProperty(this._proxy,t,{get(){return i[t]}});for(const t in _ProxyMethods)Object.defineProperty(this._proxy,t,{value:(...e)=>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 s,p;this.pointerIsDown&&!this.pointerWasMoved&&(s=this.coords.cur.client.x-this.coords.start.client.x,p=this.coords.cur.client.y-this.coords.start.client.y,this.pointerWasMoved=i(s,p)>this.pointerMoveTolerance);const h=this.getPointerIndex(t),a={pointer:t,pointerIndex:h,pointerInfo:this.pointers[h],event:e,type:"move",eventTarget:n,dx:s,dy:p,duplicate:o,interaction:this};o||r.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&&r.copyCoords(this.coords.prev,this.coords.cur))}move(t){t&&t.event||r.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 r=/cancel$/i.test(e.type)?"cancel":"up";this._scopeFire("interactions:"+r,{pointer:t,pointerIndex:o,pointerInfo:this.pointers[o],event:e,eventTarget:i,type:r,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=r.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=r.getPointerId(t);let s=this.getPointerIndex(t),p=this.pointers[s];return n=!1!==n&&(n||/(down|start)$/i.test(e.type)),p?p.pointer=t:(p=new h(o,t,e,null,null),s=this.pointers.length,this.pointers.push(p)),r.setCoords(this.coords.cur,this.pointers.map((t=>t.pointer)),this._now()),r.setCoordDeltas(this.coords.delta,this.coords.prev,this.coords.cur),n&&(this.pointerIsDown=!0,p.downTime=this.coords.cur.timeStamp,p.downTarget=i,r.pointerExtend(this.downPointer,t),this.interacting()||(r.copyCoords(this.coords.start,this.coords.cur),r.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:p,pointerIndex:s,interaction:this}),s}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 p(this,t,this.prepared.name,e,this.element,i,n)}_fireEvent(t){var e;null==(e=this.interactable)||e.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:r}=this;if(r&&"move"===i&&(s.addEdges(this.edges,r,this.coords.delta[this.interactable.options.deltaSource]),r.width=r.right-r.left,r.height=r.bottom-r.top),!1===this._scopeFire("interactions:before-action-"+i,t))return!1;const p=t.iEvent=this._createPreparedEvent(e,i,n,o);return this._scopeFire("interactions:action-"+i,t),"start"===i&&(this.prevEvent=p),this._fireEvent(p),this._scopeFire("interactions:after-action-"+i,t),!0}_now(){return Date.now()}}export default Interaction;export{h as PointerInfo};
import*as t from"../utils/arr.prod.js";import e from"../utils/extend.prod.js";import i from"../utils/hypot.prod.js";import{warnOnce as n,copyAction as o}from"../utils/misc.prod.js";import*as r from"../utils/pointerUtils.prod.js";import*as s from"../utils/rect.prod.js";import{InteractEvent as p}from"./InteractEvent";import{PointerInfo as h}from"./PointerInfo";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{interactable=null;element=null;rect=null;_rects;edges=null;_scopeFire;prepared={name:null,axis:null,edges:null};pointerType;pointers=[];downEvent=null;downPointer={};_latestPointer={pointer:null,event:null,eventTarget:null};prevEvent=null;pointerIsDown=!1;pointerWasMoved=!1;_interacting=!1;_ending=!1;_stopped=!0;_proxy=null;simulation=null;get pointerMoveTolerance(){return 1}doMove=n((function(t){this.move(t)}),"The interaction.doMove() method has been renamed to interaction.move()");coords={start:r.newCoords(),prev:r.newCoords(),cur:r.newCoords(),delta:r.newCoords(),velocity:r.newCoords()};_id=a++;constructor({pointerType:t,scopeFire:e}){this._scopeFire=e,this.pointerType=t;const i=this;this._proxy={};for(const t in _ProxyValues)Object.defineProperty(this._proxy,t,{get(){return i[t]}});for(const t in _ProxyMethods)Object.defineProperty(this._proxy,t,{value:(...e)=>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 s,p;this.pointerIsDown&&!this.pointerWasMoved&&(s=this.coords.cur.client.x-this.coords.start.client.x,p=this.coords.cur.client.y-this.coords.start.client.y,this.pointerWasMoved=i(s,p)>this.pointerMoveTolerance);const h=this.getPointerIndex(t),a={pointer:t,pointerIndex:h,pointerInfo:this.pointers[h],event:e,type:"move",eventTarget:n,dx:s,dy:p,duplicate:o,interaction:this};o||r.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&&r.copyCoords(this.coords.prev,this.coords.cur))}move(t){t&&t.event||r.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 r=/cancel$/i.test(e.type)?"cancel":"up";this._scopeFire("interactions:"+r,{pointer:t,pointerIndex:o,pointerInfo:this.pointers[o],event:e,eventTarget:i,type:r,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=r.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=r.getPointerId(t);let s=this.getPointerIndex(t),p=this.pointers[s];return n=!1!==n&&(n||/(down|start)$/i.test(e.type)),p?p.pointer=t:(p=new h(o,t,e,null,null),s=this.pointers.length,this.pointers.push(p)),r.setCoords(this.coords.cur,this.pointers.map((t=>t.pointer)),this._now()),r.setCoordDeltas(this.coords.delta,this.coords.prev,this.coords.cur),n&&(this.pointerIsDown=!0,p.downTime=this.coords.cur.timeStamp,p.downTarget=i,r.pointerExtend(this.downPointer,t),this.interacting()||(r.copyCoords(this.coords.start,this.coords.cur),r.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:p,pointerIndex:s,interaction:this}),s}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 p(this,t,this.prepared.name,e,this.element,i,n)}_fireEvent(t){var e;null==(e=this.interactable)||e.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:r}=this;if(r&&"move"===i&&(s.addEdges(this.edges,r,this.coords.delta[this.interactable.options.deltaSource]),r.width=r.right-r.left,r.height=r.bottom-r.top),!1===this._scopeFire("interactions:before-action-"+i,t))return!1;const p=t.iEvent=this._createPreparedEvent(e,i,n,o);return this._scopeFire("interactions:action-"+i,t),"start"===i&&(this.prevEvent=p),this._fireEvent(p),this._scopeFire("interactions:after-action-"+i,t),!0}_now(){return Date.now()}}export default Interaction;export{h as PointerInfo};
//# sourceMappingURL=Interaction.prod.js.map

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

import * as pointerUtils from "../utils/pointerUtils.js";
import InteractionBase from "./Interaction.js";
import interactablePreventDefault from "./interactablePreventDefault.js";
import finder from "./interactionFinder.js";
import InteractionBase from './Interaction';
import interactablePreventDefault from './interactablePreventDefault';
import finder from './interactionFinder';
const methodNames = ['pointerDown', 'pointerMove', 'pointerUp', 'updatePointer', 'removePointer', 'windowBlur'];

@@ -10,0 +10,0 @@

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

import e from"../utils/browser.prod.js";import t from"../utils/domObjects.prod.js";import{nodeContains as n}from"../utils/domUtils.prod.js";import*as o from"../utils/pointerUtils.prod.js";import r from"./Interaction.prod.js";import i from"./interactablePreventDefault.prod.js";import s from"./interactionFinder.prod.js";const p=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function c(t,n){return r=>{const i=n.interactions.list,s=o.getPointerType(r),[p,c]=o.getEventTargets(r),l=[];if(/^touch/.test(r.type)){n.prevTouchTime=n.now();for(const e of r.changedTouches){const t=e,i={pointer:t,pointerId:o.getPointerId(t),pointerType:s,eventType:r.type,eventTarget:p,curEventTarget:c,scope:n},u=a(i);l.push([i.pointer,i.eventTarget,i.curEventTarget,u])}}else{let t=!1;if(!e.supportsPointerEvent&&/mouse/.test(r.type)){for(let e=0;e<i.length&&!t;e++)t="mouse"!==i[e].pointerType&&i[e].pointerIsDown;t=t||n.now()-n.prevTouchTime<500||0===r.timeStamp}if(!t){const e={pointer:r,pointerId:o.getPointerId(r),pointerType:s,eventType:r.type,curEventTarget:c,eventTarget:p,scope:n},t=a(e);l.push([e.pointer,e.eventTarget,e.curEventTarget,t])}}for(const[e,n,o,i]of l)i[t](e,r,n,o)}}function a(e){const{pointerType:t,scope:n}=e,o={interaction:s.search(e),searchDetails:e};return n.fire("interactions:find",o),o.interaction||n.interactions.new({pointerType:t})}function l({doc:e,scope:t,options:n},o){const{interactions:{docEvents:r},events:i}=t,s=i[o];t.browser.isIOS&&!n.events&&(n.events={passive:!1});for(const t in i.delegatedEvents)s(e,t,i.delegateListener),s(e,t,i.delegateUseCapture,!0);const p=n&&n.events;for(const{type:t,listener:n}of r)s(e,t,n,p)}const u={id:"core/interactions",install(o){const s={};for(const e of p)s[e]=c(e,o);const a=e.pEventTypes;let l;function u(){for(const e of o.interactions.list)if(e.pointerIsDown&&"touch"===e.pointerType&&!e._interacting)for(const t of e.pointers)o.documents.some((({doc:e})=>n(e,t.downTarget)))||e.removePointer(t.pointer,t.event)}l=t.PointerEvent?[{type:a.down,listener:u},{type:a.down,listener:s.pointerDown},{type:a.move,listener:s.pointerMove},{type:a.up,listener:s.pointerUp},{type:a.cancel,listener:s.pointerUp}]:[{type:"mousedown",listener:s.pointerDown},{type:"mousemove",listener:s.pointerMove},{type:"mouseup",listener:s.pointerUp},{type:"touchstart",listener:u},{type:"touchstart",listener:s.pointerDown},{type:"touchmove",listener:s.pointerMove},{type:"touchend",listener:s.pointerUp},{type:"touchcancel",listener:s.pointerUp}],l.push({type:"blur",listener(e){for(const t of o.interactions.list)t.documentBlur(e)}}),o.prevTouchTime=0,o.Interaction=class extends r{get pointerMoveTolerance(){return o.interactions.pointerMoveTolerance}set pointerMoveTolerance(e){o.interactions.pointerMoveTolerance=e}_now(){return o.now()}},o.interactions={list:[],new(e){e.scopeFire=(e,t)=>o.fire(e,t);const t=new o.Interaction(e);return o.interactions.list.push(t),t},listeners:s,docEvents:l,pointerMoveTolerance:1},o.usePlugin(i)},listeners:{"scope:add-document":e=>l(e,"add"),"scope:remove-document":e=>l(e,"remove"),"interactable:unset"({interactable:e},t){for(let n=t.interactions.list.length-1;n>=0;n--){const o=t.interactions.list[n];o.interactable===e&&(o.stop(),t.fire("interactions:destroy",{interaction:o}),o.destroy(),t.interactions.list.length>2&&t.interactions.list.splice(n,1))}}},onDocSignal:l,doOnInteractions:c,methodNames:p};export default u;
import e from"../utils/browser.prod.js";import t from"../utils/domObjects.prod.js";import{nodeContains as n}from"../utils/domUtils.prod.js";import*as o from"../utils/pointerUtils.prod.js";import r from"./Interaction";import i from"./interactablePreventDefault";import s from"./interactionFinder";const p=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function c(t,n){return r=>{const i=n.interactions.list,s=o.getPointerType(r),[p,c]=o.getEventTargets(r),l=[];if(/^touch/.test(r.type)){n.prevTouchTime=n.now();for(const e of r.changedTouches){const t=e,i={pointer:t,pointerId:o.getPointerId(t),pointerType:s,eventType:r.type,eventTarget:p,curEventTarget:c,scope:n},u=a(i);l.push([i.pointer,i.eventTarget,i.curEventTarget,u])}}else{let t=!1;if(!e.supportsPointerEvent&&/mouse/.test(r.type)){for(let e=0;e<i.length&&!t;e++)t="mouse"!==i[e].pointerType&&i[e].pointerIsDown;t=t||n.now()-n.prevTouchTime<500||0===r.timeStamp}if(!t){const e={pointer:r,pointerId:o.getPointerId(r),pointerType:s,eventType:r.type,curEventTarget:c,eventTarget:p,scope:n},t=a(e);l.push([e.pointer,e.eventTarget,e.curEventTarget,t])}}for(const[e,n,o,i]of l)i[t](e,r,n,o)}}function a(e){const{pointerType:t,scope:n}=e,o={interaction:s.search(e),searchDetails:e};return n.fire("interactions:find",o),o.interaction||n.interactions.new({pointerType:t})}function l({doc:e,scope:t,options:n},o){const{interactions:{docEvents:r},events:i}=t,s=i[o];t.browser.isIOS&&!n.events&&(n.events={passive:!1});for(const t in i.delegatedEvents)s(e,t,i.delegateListener),s(e,t,i.delegateUseCapture,!0);const p=n&&n.events;for(const{type:t,listener:n}of r)s(e,t,n,p)}const u={id:"core/interactions",install(o){const s={};for(const e of p)s[e]=c(e,o);const a=e.pEventTypes;let l;function u(){for(const e of o.interactions.list)if(e.pointerIsDown&&"touch"===e.pointerType&&!e._interacting)for(const t of e.pointers)o.documents.some((({doc:e})=>n(e,t.downTarget)))||e.removePointer(t.pointer,t.event)}l=t.PointerEvent?[{type:a.down,listener:u},{type:a.down,listener:s.pointerDown},{type:a.move,listener:s.pointerMove},{type:a.up,listener:s.pointerUp},{type:a.cancel,listener:s.pointerUp}]:[{type:"mousedown",listener:s.pointerDown},{type:"mousemove",listener:s.pointerMove},{type:"mouseup",listener:s.pointerUp},{type:"touchstart",listener:u},{type:"touchstart",listener:s.pointerDown},{type:"touchmove",listener:s.pointerMove},{type:"touchend",listener:s.pointerUp},{type:"touchcancel",listener:s.pointerUp}],l.push({type:"blur",listener(e){for(const t of o.interactions.list)t.documentBlur(e)}}),o.prevTouchTime=0,o.Interaction=class extends r{get pointerMoveTolerance(){return o.interactions.pointerMoveTolerance}set pointerMoveTolerance(e){o.interactions.pointerMoveTolerance=e}_now(){return o.now()}},o.interactions={list:[],new(e){e.scopeFire=(e,t)=>o.fire(e,t);const t=new o.Interaction(e);return o.interactions.list.push(t),t},listeners:s,docEvents:l,pointerMoveTolerance:1},o.usePlugin(i)},listeners:{"scope:add-document":e=>l(e,"add"),"scope:remove-document":e=>l(e,"remove"),"interactable:unset"({interactable:e},t){for(let n=t.interactions.list.length-1;n>=0;n--){const o=t.interactions.list[n];o.interactable===e&&(o.stop(),t.fire("interactions:destroy",{interaction:o}),o.destroy(),t.interactions.list.length>2&&t.interactions.list.splice(n,1))}}},onDocSignal:l,doOnInteractions:c,methodNames:p};export default u;
//# sourceMappingURL=interactions.prod.js.map

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

import * as pointerUtils from "../utils/pointerUtils.js";
import isNonNativeEvent from "./isNonNativeEvent.js";
import isNonNativeEvent from './isNonNativeEvent';
export function createInteractStatic(scope) {

@@ -57,3 +57,3 @@ /**

interact.version = "1.10.14";
interact.version = "1.10.15";
interact.scope = scope;

@@ -60,0 +60,0 @@ /**

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

import t from"../utils/browser.prod.js";import*as e from"../utils/domUtils.prod.js";import o from"../utils/is.prod.js";import{warnOnce as s}from"../utils/misc.prod.js";import*as n from"../utils/pointerUtils.prod.js";import i from"./isNonNativeEvent.prod.js";export function createInteractStatic(r){const c=(t,e)=>{let o=r.interactables.get(t,e);return o||(o=r.interactables.new(t,e),o.events.global=c.globalEvents),o};return c.getPointerAverage=n.pointerAverage,c.getTouchBBox=n.touchBBox,c.getTouchDistance=n.touchDistance,c.getTouchAngle=n.touchAngle,c.getElementRect=e.getElementRect,c.getElementClientRect=e.getElementClientRect,c.matchesSelector=e.matchesSelector,c.closest=e.closest,c.globalEvents={},c.version="1.10.14",c.scope=r,c.use=function(t,e){return this.scope.usePlugin(t,e),this},c.isSet=function(t,e){return!!this.scope.interactables.get(t,e&&e.context)},c.on=s((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 i(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}),"The interact.on() method is being deprecated"),c.off=s((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(i(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}),"The interact.off() method is being deprecated"),c.debug=function(){return this.scope},c.supportsTouch=()=>t.supportsTouch,c.supportsPointerEvent=()=>t.supportsPointerEvent,c.stop=function(){for(const t of this.scope.interactions.list)t.stop();return this},c.pointerMoveTolerance=function(t){return o.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance},c.addDocument=function(t,e){this.scope.addDocument(t,e)},c.removeDocument=function(t){this.scope.removeDocument(t)},c}
import t from"../utils/browser.prod.js";import*as e from"../utils/domUtils.prod.js";import o from"../utils/is.prod.js";import{warnOnce as s}from"../utils/misc.prod.js";import*as n from"../utils/pointerUtils.prod.js";import i from"./isNonNativeEvent";export function createInteractStatic(r){const c=(t,e)=>{let o=r.interactables.get(t,e);return o||(o=r.interactables.new(t,e),o.events.global=c.globalEvents),o};return c.getPointerAverage=n.pointerAverage,c.getTouchBBox=n.touchBBox,c.getTouchDistance=n.touchDistance,c.getTouchAngle=n.touchAngle,c.getElementRect=e.getElementRect,c.getElementClientRect=e.getElementClientRect,c.matchesSelector=e.matchesSelector,c.closest=e.closest,c.globalEvents={},c.version="1.10.15",c.scope=r,c.use=function(t,e){return this.scope.usePlugin(t,e),this},c.isSet=function(t,e){return!!this.scope.interactables.get(t,e&&e.context)},c.on=s((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 i(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}),"The interact.on() method is being deprecated"),c.off=s((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(i(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}),"The interact.off() method is being deprecated"),c.debug=function(){return this.scope},c.supportsTouch=()=>t.supportsTouch,c.supportsPointerEvent=()=>t.supportsPointerEvent,c.stop=function(){for(const t of this.scope.interactions.list)t.stop();return this},c.pointerMoveTolerance=function(t){return o.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance},c.addDocument=function(t,e){this.scope.addDocument(t,e)},c.removeDocument=function(t){this.scope.removeDocument(t)},c}
//# sourceMappingURL=InteractStatic.prod.js.map
{
"name": "@interactjs/core",
"version": "1.10.14",
"version": "1.10.15",
"main": "index",

@@ -12,3 +12,3 @@ "module": "index",

"peerDependencies": {
"@interactjs/utils": "1.10.14"
"@interactjs/utils": "1.10.15"
},

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

@@ -8,10 +8,10 @@ import browser from "../utils/browser.js";

import * as win from "../utils/window.js";
import { Eventable } from "./Eventable.js";
import { InteractEvent } from "./InteractEvent.js";
import { createInteractStatic } from "./InteractStatic.js";
import { Interactable as InteractableBase } from "./Interactable.js";
import { InteractableSet } from "./InteractableSet.js";
import events from "./events.js";
import interactions from "./interactions.js";
import { defaults } from "./options.js";
import { Eventable } from './Eventable';
import { InteractEvent } from './InteractEvent';
import { createInteractStatic } from './InteractStatic';
import { Interactable as InteractableBase } from './Interactable';
import { InteractableSet } from './InteractableSet';
import events from './events';
import interactions from './interactions';
import { defaults } from './options';
export class Scope {

@@ -18,0 +18,0 @@ id = `__interact_scope_${Math.floor(Math.random() * 100)}`;

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc