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

@interactjs/core - npm Package Compare versions

Comparing version 1.9.7 to 1.9.8

events.d.ts

7

Interactable.d.ts

@@ -7,2 +7,3 @@ import Eventable from './Eventable';

export declare class Interactable implements Partial<Eventable> {
private readonly _scopeEvents;
protected readonly _defaults: Defaults;

@@ -17,3 +18,3 @@ readonly options: Required<Options>;

/** */
constructor(target: Interact.Target, options: any, defaultContext: Document | Interact.Element);
constructor(target: Interact.Target, options: any, defaultContext: Document | Interact.Element, _scopeEvents: Interact.Scope['events']);
setOnEvents(actionName: Interact.ActionName, phases: NonNullable<any>): this;

@@ -80,3 +81,3 @@ updatePerActionListeners(actionName: Interact.ActionName, prev: Interact.Listeners, cur: Interact.Listeners): void;

*/
context(): Document | HTMLElement | SVGElement;
context(): import("@interactjs/types/types").Context;
inContext(element: Document | Node): boolean;

@@ -131,4 +132,2 @@ testIgnoreAllow(this: Interactable, options: {

* action capabilities and event listeners
*
* @return {interact}
*/

@@ -135,0 +134,0 @@ unset(): void;

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

import { getElementRect, matchesUpTo, nodeContains, trySelector } from "../utils/domUtils.js";
import events from "../utils/events.js";
import extend from "../utils/extend.js";

@@ -25,3 +24,4 @@ import * as is from "../utils/is.js";

/** */
constructor(target, options, defaultContext) {
constructor(target, options, defaultContext, _scopeEvents) {
this._scopeEvents = _scopeEvents;
this.options = void 0;

@@ -278,6 +278,6 @@ this._actions = void 0;

else if (is.string(this.target)) {
events[`${addRemove}Delegate`](this.target, this._context, type, listener, options);
this._scopeEvents[`${addRemove}Delegate`](this.target, this._context, type, listener, options);
} // remove listener from this Interactable's element
else {
events[addRemove](this.target, type, listener, options);
this._scopeEvents[addRemove](this.target, type, listener, options);
}

@@ -355,4 +355,2 @@ }

* action capabilities and event listeners
*
* @return {interact}
*/

@@ -362,20 +360,25 @@

unset() {
events.remove(this.target, 'all');
if (is.string(this.target)) {
// remove delegated events
for (const type in events.delegatedEvents) {
const delegated = events.delegatedEvents[type];
for (const type in this._scopeEvents.delegatedEvents) {
const delegated = this._scopeEvents.delegatedEvents[type];
if (delegated.selectors[0] === this.target && delegated.contexts[0] === this._context) {
delegated.selectors.splice(0, 1);
delegated.contexts.splice(0, 1);
delegated.listeners.splice(0, 1);
for (let i = delegated.length - 1; i >= 0; i--) {
const {
selector,
context,
listeners
} = delegated[i];
if (selector === this.target && context === this._context) {
delegated.splice(i, 1);
}
for (let l = listeners.length - 1; l >= 0; l--) {
this._scopeEvents.removeDelegate(this.target, this._context, type, listeners[l][0], listeners[l][1]);
}
}
events.remove(this._context, type, events.delegateListener);
events.remove(this._context, type, events.delegateUseCapture, true);
}
} else {
events.remove(this.target, 'all');
this._scopeEvents.remove(this.target, 'all');
}

@@ -382,0 +385,0 @@ }

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

import*as t from"../utils/arr.min.js";import e from"../utils/browser.min.js";import s from"../utils/clone.min.js";import{getElementRect as i,matchesUpTo as n,nodeContains as o,trySelector as r}from"../utils/domUtils.min.js";import c from"../utils/events.min.js";import h from"../utils/extend.min.js";import*as a from"../utils/is.min.js";import l from"../utils/normalizeListeners.min.js";import{getWindow as m}from"../utils/window.min.js";import u from"./Eventable.min.js";import{isNonNativeEvent as f}from"./scope.min.js";export class Interactable{get _defaults(){return{base:{},perAction:{},actions:{}}}constructor(t,e,s){this.options=void 0,this._actions=void 0,this.target=void 0,this.events=new u,this._context=void 0,this._win=void 0,this._doc=void 0,this._actions=e.actions,this.target=t,this._context=e.context||s,this._win=m(r(t)?this._context:t),this._doc=this._win.document,this.set(e)}setOnEvents(t,e){return a.func(e.onstart)&&this.on(`${t}start`,e.onstart),a.func(e.onmove)&&this.on(`${t}move`,e.onmove),a.func(e.onend)&&this.on(`${t}end`,e.onend),a.func(e.oninertiastart)&&this.on(`${t}inertiastart`,e.oninertiastart),this}updatePerActionListeners(t,e,s){(a.array(e)||a.object(e))&&this.off(t,e),(a.array(s)||a.object(s))&&this.on(t,s)}setPerAction(e,i){const n=this._defaults;for(const o in i){const r=o,c=this.options[e],l=i[r];"listeners"===r&&this.updatePerActionListeners(e,c.listeners,l),a.array(l)?c[r]=t.from(l):a.plainObject(l)?(c[r]=h(c[r]||{},s(l)),a.object(n.perAction[r])&&"enabled"in n.perAction[r]&&(c[r].enabled=!1!==l.enabled)):a.bool(l)&&a.object(n.perAction[r])?c[r].enabled=l:c[r]=l}}getRect(t){return t=t||(a.element(this.target)?this.target:null),a.string(this.target)&&(t=t||this._context.querySelector(this.target)),i(t)}rectChecker(t){return a.func(t)?(this.getRect=t,this):null===t?(delete this.getRect,this):this.getRect}_backCompatOption(t,e){if(r(e)||a.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||o(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||!!a.element(s)&&(a.string(t)?n(s,t,e):!!a.element(t)&&o(t,s))}testIgnore(t,e,s){return!(!t||!a.element(s))&&(a.string(t)?n(s,t,e):!!a.element(t)&&o(t,s))}fire(t){return this.events.fire(t),this}_onOff(t,s,i,n){a.object(s)&&!a.array(s)&&(n=i,i=null);const o="on"===t?"add":"remove",r=l(s,i);for(let s in r){"wheel"===s&&(s=e.wheelEvent);for(const e of r[s])f(s,this._actions)?this.events[t](s,e):a.string(this.target)?c[`${o}Delegate`](this.target,this._context,s,e,n):c[o](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;a.object(t)||(t={}),this.options=s(e.base);for(const s in this._actions.methodDict){const i=s,n=this._actions.methodDict[i];this.options[i]={},this.setPerAction(i,h(h({},e.perAction),e.actions[i])),this[n](t[i])}for(const e in t)a.func(this[e])&&this[e](t[e]);return this}unset(){if(c.remove(this.target,"all"),a.string(this.target))for(const t in c.delegatedEvents){const e=c.delegatedEvents[t];e.selectors[0]===this.target&&e.contexts[0]===this._context&&(e.selectors.splice(0,1),e.contexts.splice(0,1),e.listeners.splice(0,1)),c.remove(this._context,t,c.delegateListener),c.remove(this._context,t,c.delegateUseCapture,!0)}else c.remove(this.target,"all")}}export default Interactable;
import*as t from"../utils/arr.min.js";import e from"../utils/browser.min.js";import s from"../utils/clone.min.js";import{getElementRect as i,matchesUpTo as n,nodeContains as o,trySelector as r}from"../utils/domUtils.min.js";import c from"../utils/extend.min.js";import*as h from"../utils/is.min.js";import a from"../utils/normalizeListeners.min.js";import{getWindow as l}from"../utils/window.min.js";import m from"./Eventable.min.js";import{isNonNativeEvent as u}from"./scope.min.js";export class Interactable{get _defaults(){return{base:{},perAction:{},actions:{}}}constructor(t,e,s,i){this._scopeEvents=i,this.options=void 0,this._actions=void 0,this.target=void 0,this.events=new m,this._context=void 0,this._win=void 0,this._doc=void 0,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.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,i){const n=this._defaults;for(const o in i){const r=o,a=this.options[e],l=i[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)),i(t)}rectChecker(t){return h.func(t)?(this.getRect=t,this):null===t?(delete this.getRect,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||o(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)&&o(t,s))}testIgnore(t,e,s){return!(!t||!h.element(s))&&(h.string(t)?n(s,t,e):!!h.element(t)&&o(t,s))}fire(t){return this.events.fire(t),this}_onOff(t,s,i,n){h.object(s)&&!h.array(s)&&(n=i,i=null);const o="on"===t?"add":"remove",r=a(s,i);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[`${o}Delegate`](this.target,this._context,s,e,n):this._scopeEvents[o](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 i=s,n=this._actions.methodDict[i];this.options[i]={},this.setPerAction(i,c(c({},e.perAction),e.actions[i])),this[n](t[i])}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:i,context:n,listeners:o}=e[s];i===this.target&&n===this._context&&e.splice(s,1);for(let e=o.length-1;e>=0;e--)this._scopeEvents.removeDelegate(this.target,this._context,t,o[e][0],o[e][1])}}else this._scopeEvents.remove(this.target,"all")}}export default Interactable;
//# sourceMappingURL=Interactable.min.js.map
import { matchesSelector, nodeContains } from "../utils/domUtils.js";
import events from "../utils/events.js";
import * as is from "../utils/is.js";

@@ -36,3 +35,3 @@ import { getWindow } from "../utils/window.js";

if (events.supportsPassive && /^touch(start|move)$/.test(event.type)) {
if (scope.events.supportsPassive && /^touch(start|move)$/.test(event.type)) {
const doc = getWindow(event.target).document;

@@ -39,0 +38,0 @@ const docOptions = scope.getDocOptions(doc);

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

import{matchesSelector as t,nodeContains as e}from"../utils/domUtils.min.js";import n from"../utils/events.min.js";import*as i from"../utils/is.min.js";import{getWindow as r}from"../utils/window.min.js";function o(t){return/^(always|never|auto)$/.test(t)?(this.options.preventDefault=t,this):i.bool(t)?(this.options.preventDefault=t?"always":"never",this):this.options.preventDefault}function s({interaction:t,event:e}){t.interactable&&t.interactable.checkAndPreventDefault(e)}export function install(s){const{Interactable:a}=s;a.prototype.preventDefault=o,a.prototype.checkAndPreventDefault=function(e){return function(e,o,s){const a=e.options.preventDefault;if("never"!==a)if("always"!==a){if(n.supportsPassive&&/^touch(start|move)$/.test(s.type)){const t=r(s.target).document,e=o.getDocOptions(t);if(!e||!e.events||!1!==e.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(s.type)||i.element(s.target)&&t(s.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||s.preventDefault()}else s.preventDefault()}(this,s,e)},s.interactions.docEvents.push({type:"dragstart",listener(t){for(const n of s.interactions.list)if(n.element&&(n.element===t.target||e(n.element,t.target)))return void n.interactable.checkAndPreventDefault(t)}})}export default{id:"core/interactablePreventDefault",install:install,listeners:["down","move","up","cancel"].reduce((t,e)=>(t[`interactions:${e}`]=s,t),{})};
import{matchesSelector as t,nodeContains as e}from"../utils/domUtils.min.js";import*as n from"../utils/is.min.js";import{getWindow as i}from"../utils/window.min.js";function r(t){return/^(always|never|auto)$/.test(t)?(this.options.preventDefault=t,this):n.bool(t)?(this.options.preventDefault=t?"always":"never",this):this.options.preventDefault}function o({interaction:t,event:e}){t.interactable&&t.interactable.checkAndPreventDefault(e)}export function install(o){const{Interactable:s}=o;s.prototype.preventDefault=r,s.prototype.checkAndPreventDefault=function(e){return function(e,r,o){const s=e.options.preventDefault;if("never"!==s)if("always"!==s){if(r.events.supportsPassive&&/^touch(start|move)$/.test(o.type)){const t=i(o.target).document,e=r.getDocOptions(t);if(!e||!e.events||!1!==e.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(o.type)||n.element(o.target)&&t(o.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||o.preventDefault()}else o.preventDefault()}(this,o,e)},o.interactions.docEvents.push({type:"dragstart",listener(t){for(const n of o.interactions.list)if(n.element&&(n.element===t.target||e(n.element,t.target)))return void n.interactable.checkAndPreventDefault(t)}})}export default{id:"core/interactablePreventDefault",install:install,listeners:["down","move","up","cancel"].reduce((t,e)=>(t[`interactions:${e}`]=o,t),{})};
//# sourceMappingURL=interactablePreventDefault.min.js.map

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

});
const interactable = new this.scope.Interactable(target, options, this.scope.document);
const interactable = new this.scope.Interactable(target, options, this.scope.document, this.scope.events);
const mappingInfo = {

@@ -40,0 +40,0 @@ context: interactable._context,

@@ -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*as i from"../utils/is.min.js";export default class n{constructor(t){this.scope=t,this.list=[],this.selectorMap={},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),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*as i from"../utils/is.min.js";export default class n{constructor(t){this.scope=t,this.list=[],this.selectorMap={},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}}}
//# sourceMappingURL=InteractableSet.min.js.map
import browser from "../utils/browser.js";
import domObjects from "../utils/domObjects.js";
import { nodeContains } from "../utils/domUtils.js";
import events from "../utils/events.js";
import * as pointerUtils from "../utils/pointerUtils.js";

@@ -216,4 +215,7 @@ import InteractionBase from "./Interaction.js";

const {
docEvents
} = scope.interactions;
interactions: {
docEvents
},
events
} = scope;
const eventMethod = events[eventMethodName];

@@ -220,0 +222,0 @@

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

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

@@ -21,3 +20,3 @@ import { isNonNativeEvent } from "./scope.js";

this.dynamicDrop = void 0;
this.version = "1.9.7";
this.version = "1.9.8";
this.interact = void 0;

@@ -147,3 +146,3 @@ const {

else {
events.add(this.scope.document, type, listener, {
this.scope.events.add(this.scope.document, type, listener, {
options

@@ -197,3 +196,3 @@ });

} else {
events.remove(this.scope.document, type, listener, options);
this.scope.events.remove(this.scope.document, type, listener, options);
}

@@ -200,0 +199,0 @@

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

import t from"../utils/browser.min.js";import e from"../utils/events.min.js";import*as s from"../utils/index.min.js";import{isNonNativeEvent as o}from"./scope.min.js";export class InteractStatic{constructor(t){this.scope=t,this.getPointerAverage=s.pointer.pointerAverage,this.getTouchBBox=s.pointer.touchBBox,this.getTouchDistance=s.pointer.touchDistance,this.getTouchAngle=s.pointer.touchAngle,this.getElementRect=s.dom.getElementRect,this.getElementClientRect=s.dom.getElementClientRect,this.matchesSelector=s.dom.matchesSelector,this.closest=s.dom.closest,this.globalEvents={},this.dynamicDrop=void 0,this.version="1.9.7",this.interact=void 0;const{prototype:e}=this.constructor,o=(e,s)=>{let o=t.interactables.get(e,s);return o||(o=t.interactables.new(e,s),o.events.global=this.globalEvents),o};for(const t of Object.getOwnPropertyNames(this.constructor.prototype))o[t]=e[t];return s.extend(o,this),o.constructor=this.constructor,this.interact=o,o}use(t,e){return this.scope.usePlugin(t,e),this}isSet(t,e){return!!this.scope.interactables.get(t,e&&e.context)}on(t,i,r){if(s.is.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),s.is.array(t)){for(const e of t)this.on(e,i,r);return this}if(s.is.object(t)){for(const e in t)this.on(e,t[e],i);return this}return o(t,this.scope.actions)?this.globalEvents[t]?this.globalEvents[t].push(i):this.globalEvents[t]=[i]:e.add(this.scope.document,t,i,{options:r}),this}off(t,i,r){if(s.is.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),s.is.array(t)){for(const e of t)this.off(e,i,r);return this}if(s.is.object(t)){for(const e in t)this.off(e,t[e],i);return this}if(o(t,this.scope.actions)){let e;t in this.globalEvents&&-1!==(e=this.globalEvents[t].indexOf(i))&&this.globalEvents[t].splice(e,1)}else e.remove(this.scope.document,t,i,r);return this}debug(){return this.scope}supportsTouch(){return t.supportsTouch}supportsPointerEvent(){return t.supportsPointerEvent}stop(){for(const t of this.scope.interactions.list)t.stop();return this}pointerMoveTolerance(t){return s.is.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance}addDocument(t,e){this.scope.addDocument(t,e)}removeDocument(t){this.scope.removeDocument(t)}}export default InteractStatic;
import t from"../utils/browser.min.js";import*as e from"../utils/index.min.js";import{isNonNativeEvent as s}from"./scope.min.js";export class InteractStatic{constructor(t){this.scope=t,this.getPointerAverage=e.pointer.pointerAverage,this.getTouchBBox=e.pointer.touchBBox,this.getTouchDistance=e.pointer.touchDistance,this.getTouchAngle=e.pointer.touchAngle,this.getElementRect=e.dom.getElementRect,this.getElementClientRect=e.dom.getElementClientRect,this.matchesSelector=e.dom.matchesSelector,this.closest=e.dom.closest,this.globalEvents={},this.dynamicDrop=void 0,this.version="1.9.8",this.interact=void 0;const{prototype:s}=this.constructor,o=(e,s)=>{let o=t.interactables.get(e,s);return o||(o=t.interactables.new(e,s),o.events.global=this.globalEvents),o};for(const t of Object.getOwnPropertyNames(this.constructor.prototype))o[t]=s[t];return e.extend(o,this),o.constructor=this.constructor,this.interact=o,o}use(t,e){return this.scope.usePlugin(t,e),this}isSet(t,e){return!!this.scope.interactables.get(t,e&&e.context)}on(t,o,i){if(e.is.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),e.is.array(t)){for(const e of t)this.on(e,o,i);return this}if(e.is.object(t)){for(const e in t)this.on(e,t[e],o);return this}return s(t,this.scope.actions)?this.globalEvents[t]?this.globalEvents[t].push(o):this.globalEvents[t]=[o]:this.scope.events.add(this.scope.document,t,o,{options:i}),this}off(t,o,i){if(e.is.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),e.is.array(t)){for(const e of t)this.off(e,o,i);return this}if(e.is.object(t)){for(const e in t)this.off(e,t[e],o);return this}if(s(t,this.scope.actions)){let e;t in this.globalEvents&&-1!==(e=this.globalEvents[t].indexOf(o))&&this.globalEvents[t].splice(e,1)}else this.scope.events.remove(this.scope.document,t,o,i);return this}debug(){return this.scope}supportsTouch(){return t.supportsTouch}supportsPointerEvent(){return t.supportsPointerEvent}stop(){for(const t of this.scope.interactions.list)t.stop();return this}pointerMoveTolerance(t){return e.is.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance}addDocument(t,e){this.scope.addDocument(t,e)}removeDocument(t){this.scope.removeDocument(t)}}export default InteractStatic;
//# sourceMappingURL=InteractStatic.min.js.map
{
"name": "@interactjs/core",
"version": "1.9.7",
"version": "1.9.8",
"license": "MIT",
"peerDependencies": {
"@interactjs/dev-tools": "1.9.7",
"@interactjs/utils": "1.9.7"
"@interactjs/dev-tools": "1.9.8",
"@interactjs/utils": "1.9.8"
},
"devDependencies": {
"@interactjs/_dev": "1.9.7",
"@interactjs/actions": "1.9.7",
"@interactjs/auto-start": "1.9.7"
"@interactjs/_dev": "1.9.8",
"@interactjs/actions": "1.9.8",
"@interactjs/auto-start": "1.9.8"
},

@@ -17,3 +17,3 @@ "publishConfig": {

},
"gitHead": "6cd658f8"
"gitHead": "701b6e73"
}

@@ -79,28 +79,2 @@ import * as utils from '@interactjs/utils/index';

};
events: {
add: (element: EventTarget, type: string, listener: (event: Event | import("@interactjs/utils/events").FakeEvent) => any, optionalArg?: any) => void;
remove: (element: EventTarget, type: string, listener?: ((event: Event | import("@interactjs/utils/events").FakeEvent) => any) | "all", optionalArg?: any) => void;
addDelegate: (selector: string, context: Node, type: string, listener: (event: Event | import("@interactjs/utils/events").FakeEvent) => any, optionalArg?: any) => void;
removeDelegate: (selector: string, context: Document | HTMLElement | SVGElement, type: string, listener?: (event: Event | import("@interactjs/utils/events").FakeEvent) => any, optionalArg?: any) => void;
delegateListener: (event: Event, optionalArg?: any) => void;
delegateUseCapture: (event: Event) => any;
delegatedEvents: {
[type: string]: {
selectors: string[];
contexts: Node[];
listeners: [(event: Event | import("@interactjs/utils/events").FakeEvent) => any, boolean, boolean][][];
};
};
documents: Document[];
supportsOptions: boolean;
supportsPassive: boolean;
_elements: EventTarget[];
_targets: {
events: {
[type: string]: ((event: Event | import("@interactjs/utils/events").FakeEvent) => any)[];
};
typeCount: number;
}[];
init(window: Window): void;
};
utils: typeof utils;

@@ -107,0 +81,0 @@ defaults: import("@interactjs/core/defaultOptions").Defaults;

@@ -9,2 +9,3 @@ import domObjects from "../utils/domObjects.js";

import defaults from "./defaultOptions.js";
import events from "./events.js";
import interactions from "./interactions.js";

@@ -14,4 +15,3 @@ const {

browser,
raf,
events
raf
} = utils; // eslint-disable-next-line @typescript-eslint/no-empty-interface

@@ -29,3 +29,2 @@

this.browser = browser;
this.events = events;
this.utils = utils;

@@ -169,7 +168,7 @@ this.defaults = utils.clone(defaults);

});
events.documents.push(doc); // don't add an unload event for the main document
this.events.documents.push(doc); // don't add an unload event for the main document
// so that the page may be cached in browser history
if (doc !== this.document) {
events.add(window, 'unload', this.onWindowUnload);
this.events.add(window, 'unload', this.onWindowUnload);
}

@@ -189,5 +188,5 @@

const options = this.documents[index].options;
events.remove(window, 'unload', this.onWindowUnload);
this.events.remove(window, 'unload', this.onWindowUnload);
this.documents.splice(index, 1);
events.documents.splice(index, 1);
this.events.documents.splice(index, 1);
this.fire('scope:remove-document', {

@@ -240,6 +239,6 @@ doc,

raf.init(window);
events.init(window);
scope.window = window;
scope.document = window.document;
scope.usePlugin(interactions);
scope.document = window.document;
scope.window = window;
scope.usePlugin(events);
return scope;

@@ -246,0 +245,0 @@ }

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

import t from"../utils/domObjects.min.js";import*as i from"../utils/index.min.js";import s from"./Eventable.min.js";import e from"./InteractEvent.min.js";import n from"./InteractStatic.min.js";import o from"./Interactable.min.js";import r from"./InteractableSet.min.js";import a from"./defaultOptions.min.js";import d from"./interactions.min.js";const{win:l,browser:h,raf:c,events:u}=i;export default class p{constructor(){this.id=`__interact_scope_${Math.floor(100*Math.random())}`,this.isInitialized=!1,this.listenerMaps=[],this.browser=h,this.events=u,this.utils=i,this.defaults=i.clone(a),this.Eventable=s,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=new n(this),this.InteractEvent=e,this.Interactable=void 0,this.interactables=new r(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 t=this;this.Interactable=class extends o{get _defaults(){return t.defaults}set(i){return super.set(i),t.fire("interactable:set",{options:i,interactable:this}),this}unset(){super.unset(),t.interactables.list.splice(t.interactables.list.indexOf(this),1),t.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.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),{});for(;i<s;i++){if(e[this.listenerMaps[i].id])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,s){if(-1!==this.getDocIndex(t))return!1;const e=l.getWindow(t);s=s?i.extend({},s):{},this.documents.push({doc:t,options:s}),u.documents.push(t),t!==this.document&&u.add(e,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:e,scope:this,options:s})}removeDocument(t){const i=this.getDocIndex(t),s=l.getWindow(t),e=this.documents[i].options;u.remove(s,"unload",this.onWindowUnload),this.documents.splice(i,1),u.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 isNonNativeEvent(t,i){if(i.phaselessTypes[t])return!0;for(const s in i.map)if(0===t.indexOf(s)&&t.substr(s.length)in i.phases)return!0;return!1}export function initScope(i,s){return i.isInitialized=!0,l.init(s),t.init(s),h.init(s),c.init(s),u.init(s),i.usePlugin(d),i.document=s.document,i.window=s,i}export{p as Scope};
import t from"../utils/domObjects.min.js";import*as i from"../utils/index.min.js";import s from"./Eventable.min.js";import e from"./InteractEvent.min.js";import n from"./InteractStatic.min.js";import o from"./Interactable.min.js";import r from"./InteractableSet.min.js";import a from"./defaultOptions.min.js";import d from"./events.min.js";import h from"./interactions.min.js";const{win:l,browser:c,raf:u}=i;export default class p{constructor(){this.id=`__interact_scope_${Math.floor(100*Math.random())}`,this.isInitialized=!1,this.listenerMaps=[],this.browser=c,this.utils=i,this.defaults=i.clone(a),this.Eventable=s,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=new n(this),this.InteractEvent=e,this.Interactable=void 0,this.interactables=new r(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 t=this;this.Interactable=class extends o{get _defaults(){return t.defaults}set(i){return super.set(i),t.fire("interactable:set",{options:i,interactable:this}),this}unset(){super.unset(),t.interactables.list.splice(t.interactables.list.indexOf(this),1),t.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.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),{});for(;i<s;i++){if(e[this.listenerMaps[i].id])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,s){if(-1!==this.getDocIndex(t))return!1;const e=l.getWindow(t);s=s?i.extend({},s):{},this.documents.push({doc:t,options:s}),this.events.documents.push(t),t!==this.document&&this.events.add(e,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:e,scope:this,options:s})}removeDocument(t){const i=this.getDocIndex(t),s=l.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 isNonNativeEvent(t,i){if(i.phaselessTypes[t])return!0;for(const s in i.map)if(0===t.indexOf(s)&&t.substr(s.length)in i.phases)return!0;return!1}export function initScope(i,s){return i.isInitialized=!0,l.init(s),t.init(s),c.init(s),u.init(s),i.window=s,i.document=s.document,i.usePlugin(h),i.usePlugin(d),i}export{p as Scope};
//# 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

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