@interactjs/core
Advanced tools
Comparing version 1.9.18 to 1.9.19
@@ -10,4 +10,4 @@ /* eslint-disable no-dupe-class-members */ | ||
import { getWindow } from "../utils/window.js"; | ||
import { Eventable } from './Eventable'; | ||
import isNonNativeEvent from './isNonNativeEvent'; | ||
import { Eventable } from "./Eventable.js"; | ||
import isNonNativeEvent from "./isNonNativeEvent.js"; | ||
@@ -14,0 +14,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 h from"../utils/extend.min.js";import c from"../utils/is.min.js";import a from"../utils/normalizeListeners.min.js";import{getWindow as l}from"../utils/window.min.js";import{Eventable as m}from"./Eventable";import u from"./isNonNativeEvent";export class Interactable{get _defaults(){return{base:{},perAction:{},actions:{}}}constructor(t,e,s,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._scopeEvents=void 0,this._rectChecker=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._scopeEvents=i,this.set(e)}setOnEvents(t,e){return c.func(e.onstart)&&this.on(t+"start",e.onstart),c.func(e.onmove)&&this.on(t+"move",e.onmove),c.func(e.onend)&&this.on(t+"end",e.onend),c.func(e.oninertiastart)&&this.on(t+"inertiastart",e.oninertiastart),this}updatePerActionListeners(t,e,s){(c.array(e)||c.object(e))&&this.off(t,e),(c.array(s)||c.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),c.array(l)?a[r]=t.from(l):c.plainObject(l)?(a[r]=h(a[r]||{},s(l)),c.object(n.perAction[r])&&"enabled"in n.perAction[r]&&(a[r].enabled=!1!==l.enabled)):c.bool(l)&&c.object(n.perAction[r])?a[r].enabled=l:a[r]=l}}getRect(t){return t=t||(c.element(this.target)?this.target:null),c.string(this.target)&&(t=t||this._context.querySelector(this.target)),i(t)}rectChecker(t){return c.func(t)?(this._rectChecker=t,this.getRect=t=>{const e=h({},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)||c.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||!!c.element(s)&&(c.string(t)?n(s,t,e):!!c.element(t)&&o(t,s))}testIgnore(t,e,s){return!(!t||!c.element(s))&&(c.string(t)?n(s,t,e):!!c.element(t)&&o(t,s))}fire(t){return this.events.fire(t),this}_onOff(t,s,i,n){c.object(s)&&!c.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):c.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;c.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)c.func(this[e])&&this[e](t[e]);return this}unset(){if(c.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")}} | ||
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 h from"../utils/extend.min.js";import c from"../utils/is.min.js";import a from"../utils/normalizeListeners.min.js";import{getWindow as l}from"../utils/window.min.js";import{Eventable as m}from"./Eventable.min.js";import u from"./isNonNativeEvent.min.js";export class Interactable{get _defaults(){return{base:{},perAction:{},actions:{}}}constructor(t,e,s,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._scopeEvents=void 0,this._rectChecker=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._scopeEvents=i,this.set(e)}setOnEvents(t,e){return c.func(e.onstart)&&this.on(t+"start",e.onstart),c.func(e.onmove)&&this.on(t+"move",e.onmove),c.func(e.onend)&&this.on(t+"end",e.onend),c.func(e.oninertiastart)&&this.on(t+"inertiastart",e.oninertiastart),this}updatePerActionListeners(t,e,s){(c.array(e)||c.object(e))&&this.off(t,e),(c.array(s)||c.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),c.array(l)?a[r]=t.from(l):c.plainObject(l)?(a[r]=h(a[r]||{},s(l)),c.object(n.perAction[r])&&"enabled"in n.perAction[r]&&(a[r].enabled=!1!==l.enabled)):c.bool(l)&&c.object(n.perAction[r])?a[r].enabled=l:a[r]=l}}getRect(t){return t=t||(c.element(this.target)?this.target:null),c.string(this.target)&&(t=t||this._context.querySelector(this.target)),i(t)}rectChecker(t){return c.func(t)?(this._rectChecker=t,this.getRect=t=>{const e=h({},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)||c.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||!!c.element(s)&&(c.string(t)?n(s,t,e):!!c.element(t)&&o(t,s))}testIgnore(t,e,s){return!(!t||!c.element(s))&&(c.string(t)?n(s,t,e):!!c.element(t)&&o(t,s))}fire(t){return this.events.fire(t),this}_onOff(t,s,i,n){c.object(s)&&!c.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):c.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;c.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)c.func(this[e])&&this[e](t[e]);return this}unset(){if(c.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")}} | ||
//# sourceMappingURL=Interactable.min.js.map |
import extend from "../utils/extend.js"; | ||
import getOriginXY from "../utils/getOriginXY.js"; | ||
import hypot from "../utils/hypot.js"; | ||
import { BaseEvent } from './BaseEvent'; | ||
import { defaults } from './defaultOptions'; | ||
import { BaseEvent } from "./BaseEvent.js"; | ||
import { defaults } from "./defaultOptions.js"; | ||
export class InteractEvent extends BaseEvent { | ||
@@ -7,0 +7,0 @@ // drag |
@@ -1,2 +0,2 @@ | ||
import t from"../utils/extend.min.js";import e from"../utils/getOriginXY.min.js";import i from"../utils/hypot.min.js";import{BaseEvent as s}from"./BaseEvent";import{defaults as o}from"./defaultOptions";export class InteractEvent extends s{constructor(s,r,h,n,a,p,d){super(s),this.target=void 0,this.currentTarget=void 0,this.relatedTarget=null,this.screenX=void 0,this.screenY=void 0,this.button=void 0,this.buttons=void 0,this.ctrlKey=void 0,this.shiftKey=void 0,this.altKey=void 0,this.metaKey=void 0,this.page=void 0,this.client=void 0,this.delta=void 0,this.rect=void 0,this.x0=void 0,this.y0=void 0,this.t0=void 0,this.dt=void 0,this.duration=void 0,this.clientX0=void 0,this.clientY0=void 0,this.velocity=void 0,this.speed=void 0,this.swipe=void 0,this.timeStamp=void 0,this.dragEnter=void 0,this.dragLeave=void 0,this.axes=void 0,this.preEnd=void 0,a=a||s.element;const c=s.interactable,l=(c&&c.options||o).deltaSource,v=e(c,a,h),y="start"===n,g="end"===n,m=y?this:s.prevEvent,u=y?s.coords.start:g?{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,g||(this.page.x-=v.x,this.page.y-=v.y,this.client.x-=v.x,this.client.y-=v.y),this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.shiftKey=r.shiftKey,this.metaKey=r.metaKey,this.button=r.button,this.buttons=r.buttons,this.target=a,this.currentTarget=a,this.preEnd=p,this.type=d||h+(n||""),this.interactable=c,this.t0=y?s.pointers[s.pointers.length-1].downTime:m.t0,this.x0=s.coords.start.page.x-v.x,this.y0=s.coords.start.page.y-v.y,this.clientX0=s.coords.start.client.x-v.x,this.clientY0=s.coords.start.client.y-v.y,this.delta=y||g?{x:0,y:0}:{x:this[l].x-m[l].x,y:this[l].y-m[l].y},this.dt=s.coords.delta.timeStamp,this.duration=this.timeStamp-this.t0,this.velocity=t({},s.coords.velocity[l]),this.speed=i(this.velocity.x,this.velocity.y),this.swipe=g||"inertiastart"===n?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.min.js";import e from"../utils/getOriginXY.min.js";import i from"../utils/hypot.min.js";import{BaseEvent as s}from"./BaseEvent.min.js";import{defaults as o}from"./defaultOptions.min.js";export class InteractEvent extends s{constructor(s,r,h,n,a,p,d){super(s),this.target=void 0,this.currentTarget=void 0,this.relatedTarget=null,this.screenX=void 0,this.screenY=void 0,this.button=void 0,this.buttons=void 0,this.ctrlKey=void 0,this.shiftKey=void 0,this.altKey=void 0,this.metaKey=void 0,this.page=void 0,this.client=void 0,this.delta=void 0,this.rect=void 0,this.x0=void 0,this.y0=void 0,this.t0=void 0,this.dt=void 0,this.duration=void 0,this.clientX0=void 0,this.clientY0=void 0,this.velocity=void 0,this.speed=void 0,this.swipe=void 0,this.timeStamp=void 0,this.dragEnter=void 0,this.dragLeave=void 0,this.axes=void 0,this.preEnd=void 0,a=a||s.element;const c=s.interactable,l=(c&&c.options||o).deltaSource,v=e(c,a,h),y="start"===n,g="end"===n,m=y?this:s.prevEvent,u=y?s.coords.start:g?{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,g||(this.page.x-=v.x,this.page.y-=v.y,this.client.x-=v.x,this.client.y-=v.y),this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.shiftKey=r.shiftKey,this.metaKey=r.metaKey,this.button=r.button,this.buttons=r.buttons,this.target=a,this.currentTarget=a,this.preEnd=p,this.type=d||h+(n||""),this.interactable=c,this.t0=y?s.pointers[s.pointers.length-1].downTime:m.t0,this.x0=s.coords.start.page.x-v.x,this.y0=s.coords.start.page.y-v.y,this.clientX0=s.coords.start.client.x-v.x,this.clientY0=s.coords.start.client.y-v.y,this.delta=y||g?{x:0,y:0}:{x:this[l].x-m[l].x,y:this[l].y-m[l].y},this.dt=s.coords.delta.timeStamp,this.duration=this.timeStamp-this.t0,this.velocity=t({},s.coords.velocity[l]),this.speed=i(this.velocity.x,this.velocity.y),this.swipe=g||"inertiastart"===n?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.min.js.map |
@@ -7,4 +7,4 @@ import * as arr from "../utils/arr.js"; | ||
import * as rectUtils from "../utils/rect.js"; | ||
import { InteractEvent } from './InteractEvent'; | ||
import { PointerInfo } from './PointerInfo'; | ||
import { InteractEvent } from "./InteractEvent.js"; | ||
import { PointerInfo } from "./PointerInfo.js"; | ||
export let _ProxyValues; | ||
@@ -11,0 +11,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";import{PointerInfo as p}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{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.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}; | ||
//# sourceMappingURL=Interaction.min.js.map |
@@ -5,5 +5,5 @@ import browser from "../utils/browser.js"; | ||
import * as pointerUtils from "../utils/pointerUtils.js"; | ||
import InteractionBase from './Interaction'; | ||
import interactablePreventDefault from './interactablePreventDefault'; | ||
import finder from './interactionFinder'; | ||
import InteractionBase from "./Interaction.js"; | ||
import interactablePreventDefault from "./interactablePreventDefault.js"; | ||
import finder from "./interactionFinder.js"; | ||
const methodNames = ['pointerDown', 'pointerMove', 'pointerUp', 'updatePointer', 'removePointer', 'windowBlur']; | ||
@@ -10,0 +10,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*as o from"../utils/pointerUtils.min.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){return l(e,"add")},"scope:remove-document"(e){return 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.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";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){return l(e,"add")},"scope:remove-document"(e){return 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.min.js.map |
@@ -6,3 +6,3 @@ /** @module interact */ | ||
import * as pointerUtils from "../utils/pointerUtils.js"; | ||
import isNonNativeEvent from './isNonNativeEvent'; | ||
import isNonNativeEvent from "./isNonNativeEvent.js"; | ||
export function createInteractStatic(scope) { | ||
@@ -56,3 +56,3 @@ /** | ||
interact.version = "1.9.18"; | ||
interact.version = "1.9.19"; | ||
interact.scope = scope; | ||
@@ -59,0 +59,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";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.18",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.19",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.18", | ||
"version": "1.9.19", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/utils": "1.9.18" | ||
"@interactjs/utils": "1.9.19" | ||
}, | ||
@@ -8,0 +8,0 @@ "publishConfig": { |
16
scope.js
@@ -7,10 +7,10 @@ import browser from "../utils/browser.js"; | ||
import win from "../utils/window.js"; | ||
import { Eventable } from './Eventable'; | ||
import { InteractEvent } from './InteractEvent'; | ||
import { Interactable as InteractableBase } from './Interactable'; | ||
import { InteractableSet } from './InteractableSet'; | ||
import { defaults } from './defaultOptions'; | ||
import events from './events'; | ||
import { createInteractStatic } from './interactStatic'; | ||
import interactions from './interactions'; | ||
import { Eventable } from "./Eventable.js"; | ||
import { InteractEvent } from "./InteractEvent.js"; | ||
import { Interactable as InteractableBase } from "./Interactable.js"; | ||
import { InteractableSet } from "./InteractableSet.js"; | ||
import { defaults } from "./defaultOptions.js"; | ||
import events from "./events.js"; | ||
import { createInteractStatic } from "./interactStatic.js"; | ||
import interactions from "./interactions.js"; | ||
export class Scope { | ||
@@ -17,0 +17,0 @@ // main window |
@@ -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";import{InteractEvent as a}from"./InteractEvent";import{Interactable as l}from"./Interactable";import{InteractableSet as d}from"./InteractableSet";import{defaults as h}from"./defaultOptions";import c from"./events";import{createInteractStatic as u}from"./interactStatic";import m from"./interactions";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=u(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),{});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,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(m),i.usePlugin(c),i} | ||
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 m from"./events.min.js";import{createInteractStatic as c}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=c(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),{});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,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(m),i} | ||
//# 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
409534