@interactjs/core
Advanced tools
Comparing version 1.9.10 to 1.9.11
@@ -10,3 +10,2 @@ export declare class BaseEvent<T extends Interact.ActionName = any> { | ||
propagationStopped: boolean; | ||
readonly interaction: Interact.InteractionProxy<T>; | ||
constructor(interaction: Interact.Interaction); | ||
@@ -23,2 +22,5 @@ preventDefault(): void; | ||
} | ||
export interface BaseEvent<T extends Interact.ActionName = any> { | ||
interaction: Interact.InteractionProxy<T>; | ||
} | ||
export default BaseEvent; |
export class BaseEvent { | ||
get interaction() { | ||
return this._interaction._proxy; | ||
} | ||
constructor(interaction) { | ||
@@ -36,4 +32,16 @@ this.type = void 0; | ||
} | ||
} // defined outside of class definition to avoid assignment of undefined during | ||
// construction | ||
// getters and setters defined here to support typescript 3.6 and below which | ||
// don't support getter and setters in .d.ts files | ||
Object.defineProperty(BaseEvent.prototype, 'interaction', { | ||
get() { | ||
return this._interaction._proxy; | ||
}, | ||
set() {} | ||
}); | ||
export default BaseEvent; | ||
//# sourceMappingURL=BaseEvent.js.map |
@@ -1,2 +0,2 @@ | ||
export class BaseEvent{get interaction(){return this._interaction._proxy}constructor(t){this.type=void 0,this.target=void 0,this.currentTarget=void 0,this.interactable=void 0,this._interaction=void 0,this.timeStamp=void 0,this.immediatePropagationStopped=!1,this.propagationStopped=!1,this._interaction=t}preventDefault(){}stopPropagation(){this.propagationStopped=!0}stopImmediatePropagation(){this.immediatePropagationStopped=this.propagationStopped=!0}}export default BaseEvent; | ||
export class BaseEvent{constructor(t){this.type=void 0,this.target=void 0,this.currentTarget=void 0,this.interactable=void 0,this._interaction=void 0,this.timeStamp=void 0,this.immediatePropagationStopped=!1,this.propagationStopped=!1,this._interaction=t}preventDefault(){}stopPropagation(){this.propagationStopped=!0}stopImmediatePropagation(){this.immediatePropagationStopped=this.propagationStopped=!0}}Object.defineProperty(BaseEvent.prototype,"interaction",{get(){return this._interaction._proxy},set(){}});export default BaseEvent; | ||
//# sourceMappingURL=BaseEvent.min.js.map |
@@ -1,2 +0,1 @@ | ||
// tslint:disable no-empty-interface | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
@@ -3,0 +2,0 @@ // export interface Options extends BaseDefaults, PerActionDefaults {} |
@@ -11,3 +11,3 @@ declare module '@interactjs/core/scope' { | ||
addDelegate: (selector: string, context: Node, type: string, listener: Listener, optionalArg?: any) => void; | ||
removeDelegate: (selector: string, context: import("../types/types").Context, type: string, listener?: Listener, optionalArg?: any) => void; | ||
removeDelegate: (selector: string, context: import("../types").Context, type: string, listener?: Listener, optionalArg?: any) => void; | ||
delegateListener: (event: Event, optionalArg?: any) => void; | ||
@@ -14,0 +14,0 @@ delegateUseCapture: (event: Event) => any; |
import * as arr from "../utils/arr.js"; | ||
import * as domUtils from "../utils/domUtils.js"; | ||
import extend from "../utils/extend.js"; | ||
import * as is from "../utils/is.js"; | ||
import is from "../utils/is.js"; | ||
import pExtend from "../utils/pointerExtend.js"; | ||
@@ -6,0 +6,0 @@ import * as pointerUtils from "../utils/pointerUtils.js"; |
@@ -1,2 +0,2 @@ | ||
import*as e from"../utils/arr.min.js";import*as t from"../utils/domUtils.min.js";import n from"../utils/extend.min.js";import*as s from"../utils/is.min.js";import r from"../utils/pointerExtend.min.js";import*as i from"../utils/pointerUtils.min.js";export class FakeEvent{constructor(e){this.currentTarget=void 0,this.originalEvent=void 0,this.originalEvent=e,r(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}function o(e){if(!s.object(e))return{capture:!!e,passive:!1};const t=n({},e);return t.capture=!!e.capture,t.passive=!!e.passive,t}export default{id:"events",install(n){const r=[],a={},l=[],p={add:c,remove:u,addDelegate(t,n,s,r,i){const p=o(i);if(!a[s]){a[s]=[];for(const e of l)c(e,s,v),c(e,s,f,!0)}const u=a[s];let d=e.find(u,e=>e.selector===t&&e.context===n);d||(d={selector:t,context:n,listeners:[]},u.push(d)),d.listeners.push([r,p])},removeDelegate(e,t,n,s,r){const i=o(r),l=a[n];let p,c=!1;if(l)for(p=l.length-1;p>=0;p--){const r=l[p];if(r.selector===e&&r.context===t){const{listeners:e}=r;for(let r=e.length-1;r>=0;r--){const[o,{capture:a,passive:d}]=e[r];if(o===s&&a===i.capture&&d===i.passive){e.splice(r,1),e.length||(l.splice(p,1),u(t,n,v),u(t,n,f,!0)),c=!0;break}}if(c)break}}},delegateListener:v,delegateUseCapture:f,delegatedEvents:a,documents:l,targets:r,supportsOptions:!1,supportsPassive:!1};function c(t,n,s,i){const a=o(i);let l=e.find(r,e=>e.eventTarget===t);l||(l={eventTarget:t,events:{}},r.push(l)),l.events[n]||(l.events[n]=[]),t.addEventListener&&!e.contains(l.events[n],s)&&(t.addEventListener(n,s,p.supportsOptions?a:a.capture),l.events[n].push(s))}function u(t,n,s,i){const a=o(i),l=e.findIndex(r,e=>e.eventTarget===t),c=r[l];if(!c||!c.events)return;if("all"===n){for(n in c.events)c.events.hasOwnProperty(n)&&u(t,n,"all");return}let v=!1;const f=c.events[n];if(f){if("all"===s){for(let e=f.length-1;e>=0;e--)u(t,n,f[e],a);return}for(let e=0;e<f.length;e++)if(f[e]===s){t.removeEventListener(n,s,p.supportsOptions?a:a.capture),f.splice(e,1),0===f.length&&(delete c.events[n],v=!0);break}}v&&!Object.keys(c.events).length&&r.splice(l,1)}function v(e,n){const r=o(n),l=new FakeEvent(e),p=a[e.type],[c]=i.getEventTargets(e);let u=c;for(;s.element(u);){for(let e=0;e<p.length;e++){const n=p[e],{selector:s,context:i}=n;if(t.matchesSelector(u,s)&&t.nodeContains(i,c)&&t.nodeContains(i,u)){const{listeners:e}=n;l.currentTarget=u;for(const[t,{capture:n,passive:s}]of e)n===r.capture&&s===r.passive&&t(l)}}u=t.parentNode(u)}}function f(e){return v(e,!0)}return n.document.createElement("div").addEventListener("test",null,{get capture(){return p.supportsOptions=!0},get passive(){return p.supportsPassive=!0}}),n.events=p,p}}; | ||
import*as e from"../utils/arr.min.js";import*as t from"../utils/domUtils.min.js";import n from"../utils/extend.min.js";import s from"../utils/is.min.js";import r from"../utils/pointerExtend.min.js";import*as i from"../utils/pointerUtils.min.js";export class FakeEvent{constructor(e){this.currentTarget=void 0,this.originalEvent=void 0,this.originalEvent=e,r(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}function o(e){if(!s.object(e))return{capture:!!e,passive:!1};const t=n({},e);return t.capture=!!e.capture,t.passive=!!e.passive,t}export default{id:"events",install(n){const r=[],a={},l=[],p={add:c,remove:u,addDelegate(t,n,s,r,i){const p=o(i);if(!a[s]){a[s]=[];for(const e of l)c(e,s,v),c(e,s,f,!0)}const u=a[s];let d=e.find(u,e=>e.selector===t&&e.context===n);d||(d={selector:t,context:n,listeners:[]},u.push(d)),d.listeners.push([r,p])},removeDelegate(e,t,n,s,r){const i=o(r),l=a[n];let p,c=!1;if(l)for(p=l.length-1;p>=0;p--){const r=l[p];if(r.selector===e&&r.context===t){const{listeners:e}=r;for(let r=e.length-1;r>=0;r--){const[o,{capture:a,passive:d}]=e[r];if(o===s&&a===i.capture&&d===i.passive){e.splice(r,1),e.length||(l.splice(p,1),u(t,n,v),u(t,n,f,!0)),c=!0;break}}if(c)break}}},delegateListener:v,delegateUseCapture:f,delegatedEvents:a,documents:l,targets:r,supportsOptions:!1,supportsPassive:!1};function c(t,n,s,i){const a=o(i);let l=e.find(r,e=>e.eventTarget===t);l||(l={eventTarget:t,events:{}},r.push(l)),l.events[n]||(l.events[n]=[]),t.addEventListener&&!e.contains(l.events[n],s)&&(t.addEventListener(n,s,p.supportsOptions?a:a.capture),l.events[n].push(s))}function u(t,n,s,i){const a=o(i),l=e.findIndex(r,e=>e.eventTarget===t),c=r[l];if(!c||!c.events)return;if("all"===n){for(n in c.events)c.events.hasOwnProperty(n)&&u(t,n,"all");return}let v=!1;const f=c.events[n];if(f){if("all"===s){for(let e=f.length-1;e>=0;e--)u(t,n,f[e],a);return}for(let e=0;e<f.length;e++)if(f[e]===s){t.removeEventListener(n,s,p.supportsOptions?a:a.capture),f.splice(e,1),0===f.length&&(delete c.events[n],v=!0);break}}v&&!Object.keys(c.events).length&&r.splice(l,1)}function v(e,n){const r=o(n),l=new FakeEvent(e),p=a[e.type],[c]=i.getEventTargets(e);let u=c;for(;s.element(u);){for(let e=0;e<p.length;e++){const n=p[e],{selector:s,context:i}=n;if(t.matchesSelector(u,s)&&t.nodeContains(i,c)&&t.nodeContains(i,u)){const{listeners:e}=n;l.currentTarget=u;for(const[t,{capture:n,passive:s}]of e)n===r.capture&&s===r.passive&&t(l)}}u=t.parentNode(u)}}function f(e){return v(e,!0)}return n.document.createElement("div").addEventListener("test",null,{get capture(){return p.supportsOptions=!0},get passive(){return p.supportsPassive=!0}}),n.events=p,p}}; | ||
//# sourceMappingURL=events.min.js.map |
import Eventable from './Eventable'; | ||
import { Defaults, Options } from './defaultOptions'; | ||
import { Options } from './defaultOptions'; | ||
import { Actions } from './scope'; | ||
@@ -7,3 +7,2 @@ declare type IgnoreValue = string | Interact.Element | boolean; | ||
export declare class Interactable implements Partial<Eventable> { | ||
protected readonly _defaults: Defaults; | ||
readonly options: Required<Options>; | ||
@@ -45,3 +44,3 @@ readonly _actions: Actions; | ||
*/ | ||
rectChecker(checker: (element: Interact.Element) => any): this | ((element: import("../types/types").Element) => { | ||
rectChecker(checker: (element: Interact.Element) => any): this | ((element: import("../types").Element) => { | ||
left: number; | ||
@@ -74,3 +73,3 @@ right: number; | ||
*/ | ||
deltaSource(newValue?: string): this | "page" | "client"; | ||
deltaSource(newValue?: string): "page" | "client" | this; | ||
/** | ||
@@ -82,3 +81,3 @@ * Gets the selector context Node of the Interactable. The default is | ||
*/ | ||
context(): import("../types/types").Context; | ||
context(): import("../types").Context; | ||
inContext(element: Document | Node): boolean; | ||
@@ -85,0 +84,0 @@ testIgnoreAllow(this: Interactable, options: { |
@@ -1,3 +0,1 @@ | ||
import Eventable from "./Eventable.js"; | ||
import { isNonNativeEvent } from "./scope.js"; | ||
import * as arr from "../utils/arr.js"; | ||
@@ -8,8 +6,11 @@ import browser from "../utils/browser.js"; | ||
import extend from "../utils/extend.js"; | ||
import * as is from "../utils/is.js"; | ||
import is from "../utils/is.js"; | ||
import normalizeListeners from "../utils/normalizeListeners.js"; | ||
import { getWindow } from "../utils/window.js"; | ||
import Eventable from "./Eventable.js"; | ||
import { isNonNativeEvent } from "./scope.js"; | ||
/** */ | ||
export class Interactable { | ||
/** @internal */ | ||
get _defaults() { | ||
@@ -33,2 +34,3 @@ return { | ||
this._scopeEvents = void 0; | ||
this._rectChecker = void 0; | ||
this._actions = options.actions; | ||
@@ -135,3 +137,15 @@ this.target = target; | ||
if (is.func(checker)) { | ||
this.getRect = checker; | ||
this._rectChecker = checker; | ||
this.getRect = element => { | ||
const rect = extend({}, this._rectChecker(element)); | ||
if (!('width' in rect)) { | ||
rect.width = rect.right - rect.left; | ||
rect.height = rect.bottom - rect.top; | ||
} | ||
return rect; | ||
}; | ||
return this; | ||
@@ -142,2 +156,3 @@ } | ||
delete this.getRect; | ||
delete this._rectChecker; | ||
return this; | ||
@@ -144,0 +159,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import t from"./Eventable.min.js";import{isNonNativeEvent as e}from"./scope.min.js";import*as s from"../utils/arr.min.js";import i from"../utils/browser.min.js";import n from"../utils/clone.min.js";import{getElementRect as o,matchesUpTo as r,nodeContains as c,trySelector as h}from"../utils/domUtils.min.js";import a from"../utils/extend.min.js";import*as l from"../utils/is.min.js";import m from"../utils/normalizeListeners.min.js";import{getWindow as u}from"../utils/window.min.js";export class Interactable{get _defaults(){return{base:{},perAction:{},actions:{}}}constructor(e,s,i,n){this.options=void 0,this._actions=void 0,this.target=void 0,this.events=new t,this._context=void 0,this._win=void 0,this._doc=void 0,this._scopeEvents=void 0,this._actions=s.actions,this.target=e,this._context=s.context||i,this._win=u(h(e)?this._context:e),this._doc=this._win.document,this._scopeEvents=n,this.set(s)}setOnEvents(t,e){return l.func(e.onstart)&&this.on(t+"start",e.onstart),l.func(e.onmove)&&this.on(t+"move",e.onmove),l.func(e.onend)&&this.on(t+"end",e.onend),l.func(e.oninertiastart)&&this.on(t+"inertiastart",e.oninertiastart),this}updatePerActionListeners(t,e,s){(l.array(e)||l.object(e))&&this.off(t,e),(l.array(s)||l.object(s))&&this.on(t,s)}setPerAction(t,e){const i=this._defaults;for(const o in e){const r=o,c=this.options[t],h=e[r];"listeners"===r&&this.updatePerActionListeners(t,c.listeners,h),l.array(h)?c[r]=s.from(h):l.plainObject(h)?(c[r]=a(c[r]||{},n(h)),l.object(i.perAction[r])&&"enabled"in i.perAction[r]&&(c[r].enabled=!1!==h.enabled)):l.bool(h)&&l.object(i.perAction[r])?c[r].enabled=h:c[r]=h}}getRect(t){return t=t||(l.element(this.target)?this.target:null),l.string(this.target)&&(t=t||this._context.querySelector(this.target)),o(t)}rectChecker(t){return l.func(t)?(this.getRect=t,this):null===t?(delete this.getRect,this):this.getRect}_backCompatOption(t,e){if(h(e)||l.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||c(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||!!l.element(s)&&(l.string(t)?r(s,t,e):!!l.element(t)&&c(t,s))}testIgnore(t,e,s){return!(!t||!l.element(s))&&(l.string(t)?r(s,t,e):!!l.element(t)&&c(t,s))}fire(t){return this.events.fire(t),this}_onOff(t,s,n,o){l.object(s)&&!l.array(s)&&(o=n,n=null);const r="on"===t?"add":"remove",c=m(s,n);for(let s in c){"wheel"===s&&(s=i.wheelEvent);for(const i of c[s])e(s,this._actions)?this.events[t](s,i):l.string(this.target)?this._scopeEvents[r+"Delegate"](this.target,this._context,s,i,o):this._scopeEvents[r](this.target,s,i,o)}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;l.object(t)||(t={}),this.options=n(e.base);for(const s in this._actions.methodDict){const i=s,n=this._actions.methodDict[i];this.options[i]={},this.setPerAction(i,a(a({},e.perAction),e.actions[i])),this[n](t[i])}for(const e in t)l.func(this[e])&&this[e](t[e]);return this}unset(){if(l.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; | ||
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 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.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")}}export default Interactable; | ||
//# sourceMappingURL=Interactable.min.js.map |
import { matchesSelector, nodeContains } from "../utils/domUtils.js"; | ||
import * as is from "../utils/is.js"; | ||
import is from "../utils/is.js"; | ||
import { getWindow } from "../utils/window.js"; | ||
@@ -4,0 +4,0 @@ |
@@ -1,2 +0,2 @@ | ||
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),{})}; | ||
import{matchesSelector as t,nodeContains as e}from"../utils/domUtils.min.js";import 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 |
import * as arr from "../utils/arr.js"; | ||
import * as domUtils from "../utils/domUtils.js"; | ||
import extend from "../utils/extend.js"; | ||
import * as is from "../utils/is.js"; | ||
import is from "../utils/is.js"; | ||
export default class InteractableSet { | ||
@@ -6,0 +6,0 @@ // all set interactables |
@@ -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 o{constructor(t){this.list=[],this.selectorMap={},this.scope=void 0,this.scope=t,t.addListeners({"interactable:unset":({interactable:t})=>{const{target:e,_context:s}=t,o=i.string(e)?this.selectorMap[e]:e[this.scope.id],n=o.findIndex(t=>t.context===s);o[n]&&(o[n].context=null,o[n].interactable=null),o.splice(n,1)}})}new(t,e){e=s(e||{},{actions:this.scope.actions});const o=new this.scope.Interactable(t,e,this.scope.document,this.scope.events),n={context:o._context,interactable:o};return this.scope.addDocument(o._doc),this.list.push(o),i.string(t)?(this.selectorMap[t]||(this.selectorMap[t]=[]),this.selectorMap[t].push(n)):(o.target[this.scope.id]||Object.defineProperty(t,this.scope.id,{value:[],configurable:!0}),t[this.scope.id].push(n)),this.scope.fire("interactable:new",{target:t,options:e,interactable:o,win:this.scope._win}),o}get(e,s){const o=s&&s.context||this.scope.document,n=i.string(e),c=n?this.selectorMap[e]:e[this.scope.id];if(!c)return null;const r=t.find(c,t=>t.context===o&&(n||t.interactable.inContext(e)));return r&&r.interactable}forEachMatch(t,s){for(const o of this.list){let n;if((i.string(o.target)?i.element(t)&&e.matchesSelector(t,o.target):t===o.target)&&o.inContext(t)&&(n=s(o)),void 0!==n)return n}}} | ||
import*as t from"../utils/arr.min.js";import*as e from"../utils/domUtils.min.js";import s from"../utils/extend.min.js";import i from"../utils/is.min.js";export default class o{constructor(t){this.list=[],this.selectorMap={},this.scope=void 0,this.scope=t,t.addListeners({"interactable:unset":({interactable:t})=>{const{target:e,_context:s}=t,o=i.string(e)?this.selectorMap[e]:e[this.scope.id],n=o.findIndex(t=>t.context===s);o[n]&&(o[n].context=null,o[n].interactable=null),o.splice(n,1)}})}new(t,e){e=s(e||{},{actions:this.scope.actions});const o=new this.scope.Interactable(t,e,this.scope.document,this.scope.events),n={context:o._context,interactable:o};return this.scope.addDocument(o._doc),this.list.push(o),i.string(t)?(this.selectorMap[t]||(this.selectorMap[t]=[]),this.selectorMap[t].push(n)):(o.target[this.scope.id]||Object.defineProperty(t,this.scope.id,{value:[],configurable:!0}),t[this.scope.id].push(n)),this.scope.fire("interactable:new",{target:t,options:e,interactable:o,win:this.scope._win}),o}get(e,s){const o=s&&s.context||this.scope.document,n=i.string(e),c=n?this.selectorMap[e]:e[this.scope.id];if(!c)return null;const r=t.find(c,t=>t.context===o&&(n||t.interactable.inContext(e)));return r&&r.interactable}forEachMatch(t,s){for(const o of this.list){let n;if((i.string(o.target)?i.element(t)&&e.matchesSelector(t,o.target):t===o.target)&&o.inContext(t)&&(n=s(o)),void 0!==n)return n}}} | ||
//# sourceMappingURL=InteractableSet.min.js.map |
@@ -9,2 +9,12 @@ import BaseEvent from './BaseEvent'; | ||
} | ||
export interface InteractEvent { | ||
pageX: number; | ||
pageY: number; | ||
clientX: number; | ||
clientY: number; | ||
dx: number; | ||
dy: number; | ||
velocityX: number; | ||
velocityY: number; | ||
} | ||
export declare class InteractEvent<T extends Interact.ActionName = never, P extends EventPhase = EventPhase> extends BaseEvent<T> { | ||
@@ -43,10 +53,2 @@ target: Interact.Element; | ||
constructor(interaction: Interaction, event: Interact.PointerEventType, actionName: T, phase: P, element: Interact.Element, preEnd?: boolean, type?: string); | ||
pageX: number; | ||
pageY: number; | ||
clientX: number; | ||
clientY: number; | ||
dx: number; | ||
dy: number; | ||
velocityX: number; | ||
velocityY: number; | ||
getSwipe(): { | ||
@@ -53,0 +55,0 @@ up: boolean; |
@@ -1,6 +0,6 @@ | ||
import BaseEvent from "./BaseEvent.js"; | ||
import defaults from "./defaultOptions.js"; | ||
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 "./defaultOptions.js"; | ||
export class InteractEvent extends BaseEvent { | ||
@@ -104,66 +104,2 @@ // drag | ||
get pageX() { | ||
return this.page.x; | ||
} | ||
set pageX(value) { | ||
this.page.x = value; | ||
} | ||
get pageY() { | ||
return this.page.y; | ||
} | ||
set pageY(value) { | ||
this.page.y = value; | ||
} | ||
get clientX() { | ||
return this.client.x; | ||
} | ||
set clientX(value) { | ||
this.client.x = value; | ||
} | ||
get clientY() { | ||
return this.client.y; | ||
} | ||
set clientY(value) { | ||
this.client.y = value; | ||
} | ||
get dx() { | ||
return this.delta.x; | ||
} | ||
set dx(value) { | ||
this.delta.x = value; | ||
} | ||
get dy() { | ||
return this.delta.y; | ||
} | ||
set dy(value) { | ||
this.delta.y = value; | ||
} | ||
get velocityX() { | ||
return this.velocity.x; | ||
} | ||
set velocityX(value) { | ||
this.velocity.x = value; | ||
} | ||
get velocityY() { | ||
return this.velocity.y; | ||
} | ||
set velocityY(value) { | ||
this.velocity.y = value; | ||
} | ||
getSwipe() { | ||
@@ -219,4 +155,88 @@ const interaction = this._interaction; | ||
} | ||
} // getters and setters defined here to support typescript 3.6 and below which | ||
// don't support getter and setters in .d.ts files | ||
Object.defineProperties(InteractEvent.prototype, { | ||
pageX: { | ||
get() { | ||
return this.page.x; | ||
}, | ||
set(value) { | ||
this.page.x = value; | ||
} | ||
}, | ||
pageY: { | ||
get() { | ||
return this.page.y; | ||
}, | ||
set(value) { | ||
this.page.y = value; | ||
} | ||
}, | ||
clientX: { | ||
get() { | ||
return this.client.x; | ||
}, | ||
set(value) { | ||
this.client.x = value; | ||
} | ||
}, | ||
clientY: { | ||
get() { | ||
return this.client.y; | ||
}, | ||
set(value) { | ||
this.client.y = value; | ||
} | ||
}, | ||
dx: { | ||
get() { | ||
return this.delta.x; | ||
}, | ||
set(value) { | ||
this.delta.x = value; | ||
} | ||
}, | ||
dy: { | ||
get() { | ||
return this.delta.y; | ||
}, | ||
set(value) { | ||
this.delta.y = value; | ||
} | ||
}, | ||
velocityX: { | ||
get() { | ||
return this.velocity.x; | ||
}, | ||
set(value) { | ||
this.velocity.x = value; | ||
} | ||
}, | ||
velocityY: { | ||
get() { | ||
return this.velocity.y; | ||
}, | ||
set(value) { | ||
this.velocity.y = value; | ||
} | ||
} | ||
}); | ||
export default InteractEvent; | ||
//# sourceMappingURL=InteractEvent.js.map |
@@ -1,2 +0,2 @@ | ||
import t from"./BaseEvent.min.js";import e from"./defaultOptions.min.js";import i from"../utils/extend.min.js";import s from"../utils/getOriginXY.min.js";import o from"../utils/hypot.min.js";export class InteractEvent extends t{constructor(t,r,h,n,a,d,p){super(t),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||t.element;const l=t.interactable,c=(l&&l.options||e).deltaSource,v=s(l,a,h),y="start"===n,g="end"===n,m=y?this:t.prevEvent,u=y?t.coords.start:g?{page:m.page,client:m.client,timeStamp:t.coords.cur.timeStamp}:t.coords.cur;this.page=i({},u.page),this.client=i({},u.client),this.rect=i({},t.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=d,this.type=p||h+(n||""),this.interactable=l,this.t0=y?t.pointers[t.pointers.length-1].downTime:m.t0,this.x0=t.coords.start.page.x-v.x,this.y0=t.coords.start.page.y-v.y,this.clientX0=t.coords.start.client.x-v.x,this.clientY0=t.coords.start.client.y-v.y,this.delta=y||g?{x:0,y:0}:{x:this[c].x-m[c].x,y:this[c].y-m[c].y},this.dt=t.coords.delta.timeStamp,this.duration=this.timeStamp-this.t0,this.velocity=i({},t.coords.velocity[c]),this.speed=o(this.velocity.x,this.velocity.y),this.swipe=g||"inertiastart"===n?this.getSwipe():null}get pageX(){return this.page.x}set pageX(t){this.page.x=t}get pageY(){return this.page.y}set pageY(t){this.page.y=t}get clientX(){return this.client.x}set clientX(t){this.client.x=t}get clientY(){return this.client.y}set clientY(t){this.client.y=t}get dx(){return this.delta.x}set dx(t){this.delta.x=t}get dy(){return this.delta.y}set dy(t){this.delta.y=t}get velocityX(){return this.velocity.x}set velocityX(t){this.velocity.x=t}get velocityY(){return this.velocity.y}set velocityY(t){this.velocity.y=t}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}}export default InteractEvent; | ||
import t from"../utils/extend.min.js";import e from"../utils/getOriginXY.min.js";import i from"../utils/hypot.min.js";import s from"./BaseEvent.min.js";import 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}}});export default InteractEvent; | ||
//# sourceMappingURL=InteractEvent.min.js.map |
@@ -5,3 +5,2 @@ import InteractEvent, { EventPhase } from './InteractEvent'; | ||
import { ActionName } from './scope'; | ||
import * as utils from '@interactjs/utils/index'; | ||
export interface ActionProps<T extends ActionName = Interact.ActionName> { | ||
@@ -73,3 +72,7 @@ name: T; | ||
'interactions:remove-pointer': PointerArgProps; | ||
'interactions:blur': any; | ||
'interactions:blur': { | ||
interaction: Interaction; | ||
event: Event; | ||
type: 'blur'; | ||
}; | ||
'interactions:before-action-start': Omit<DoAnyPhaseArg, 'iEvent'>; | ||
@@ -120,7 +123,6 @@ 'interactions:action-start': DoAnyPhaseArg; | ||
simulation: any; | ||
readonly pointerMoveTolerance: number; | ||
/** | ||
* @alias Interaction.prototype.move | ||
*/ | ||
doMove: (this: typeof utils) => any; | ||
doMove: (this: void) => any; | ||
coords: Interact.CoordsSet; | ||
@@ -165,3 +167,3 @@ readonly _id: number; | ||
*/ | ||
start(action: StartAction, interactable: Interactable, element: Interact.Element): any; | ||
start(action: StartAction, interactable: Interactable, element: Interact.Element): boolean; | ||
pointerMove(pointer: Interact.PointerType, event: Interact.PointerEventType, eventTarget: Interact.EventTarget): void; | ||
@@ -188,3 +190,3 @@ /** | ||
pointerUp(pointer: Interact.PointerType, event: Interact.PointerEventType, eventTarget: Interact.EventTarget, curEventTarget: Interact.EventTarget): void; | ||
documentBlur(event: any): void; | ||
documentBlur(event: Event): void; | ||
/** | ||
@@ -211,3 +213,3 @@ * ```js | ||
stop(): void; | ||
getPointerIndex(pointer: any): number; | ||
getPointerIndex(pointer: Interact.PointerType): number; | ||
getPointerInfo(pointer: any): PointerInfo; | ||
@@ -214,0 +216,0 @@ updatePointer(pointer: Interact.PointerType, event: Interact.PointerEventType, eventTarget: Interact.EventTarget, down?: boolean): number; |
@@ -0,4 +1,9 @@ | ||
import * as arr from "../utils/arr.js"; | ||
import extend from "../utils/extend.js"; | ||
import hypot from "../utils/hypot.js"; | ||
import { warnOnce, copyAction } from "../utils/misc.js"; | ||
import * as pointerUtils from "../utils/pointerUtils.js"; | ||
import * as rectUtils from "../utils/rect.js"; | ||
import InteractEvent from "./InteractEvent.js"; | ||
import PointerInfo from "./PointerInfo.js"; | ||
import * as utils from "../utils/index.js"; | ||
export let _ProxyValues; | ||
@@ -33,2 +38,4 @@ | ||
// previous action event | ||
/** @internal */ | ||
get pointerMoveTolerance() { | ||
@@ -75,3 +82,3 @@ return 1; | ||
this.simulation = null; | ||
this.doMove = utils.warnOnce(function (signalArg) { | ||
this.doMove = warnOnce(function (signalArg) { | ||
this.move(signalArg); | ||
@@ -81,11 +88,11 @@ }, 'The interaction.doMove() method has been renamed to interaction.move()'); | ||
// Starting InteractEvent pointer coordinates | ||
start: utils.pointer.newCoords(), | ||
start: pointerUtils.newCoords(), | ||
// Previous native pointer move event coordinates | ||
prev: utils.pointer.newCoords(), | ||
prev: pointerUtils.newCoords(), | ||
// current native pointer move event coordinates | ||
cur: utils.pointer.newCoords(), | ||
cur: pointerUtils.newCoords(), | ||
// Change in coordinates and time of the pointer | ||
delta: utils.pointer.newCoords(), | ||
delta: pointerUtils.newCoords(), | ||
// pointer velocity | ||
velocity: utils.pointer.newCoords() | ||
velocity: pointerUtils.newCoords() | ||
}; | ||
@@ -170,7 +177,7 @@ this._id = idCounter++; | ||
utils.copyAction(this.prepared, action); | ||
copyAction(this.prepared, action); | ||
this.interactable = interactable; | ||
this.element = element; | ||
this.rect = interactable.getRect(element); | ||
this.edges = this.prepared.edges ? utils.extend({}, this.prepared.edges) : { | ||
this.edges = this.prepared.edges ? extend({}, this.prepared.edges) : { | ||
left: true, | ||
@@ -202,3 +209,3 @@ right: true, | ||
dy = this.coords.cur.client.y - this.coords.start.client.y; | ||
this.pointerWasMoved = utils.hypot(dx, dy) > this.pointerMoveTolerance; | ||
this.pointerWasMoved = hypot(dx, dy) > this.pointerMoveTolerance; | ||
} | ||
@@ -222,3 +229,3 @@ | ||
// set pointer coordinate, time changes and velocity | ||
utils.pointer.setCoordVelocity(this.coords.velocity, this.coords.delta); | ||
pointerUtils.setCoordVelocity(this.coords.velocity, this.coords.delta); | ||
} | ||
@@ -236,3 +243,3 @@ | ||
if (this.pointerWasMoved) { | ||
utils.pointer.copyCoords(this.coords.prev, this.coords.cur); | ||
pointerUtils.copyCoords(this.coords.prev, this.coords.cur); | ||
} | ||
@@ -263,6 +270,6 @@ } | ||
if (!signalArg || !signalArg.event) { | ||
utils.pointer.setZeroCoords(this.coords.delta); | ||
pointerUtils.setZeroCoords(this.coords.delta); | ||
} | ||
signalArg = utils.extend({ | ||
signalArg = extend({ | ||
pointer: this._latestPointer.pointer, | ||
@@ -376,5 +383,5 @@ event: this._latestPointer.event, | ||
getPointerIndex(pointer) { | ||
const pointerId = utils.pointer.getPointerId(pointer); // mouse and pen interactions may have only one pointer | ||
const pointerId = pointerUtils.getPointerId(pointer); // mouse and pen interactions may have only one pointer | ||
return this.pointerType === 'mouse' || this.pointerType === 'pen' ? this.pointers.length - 1 : utils.arr.findIndex(this.pointers, curPointer => curPointer.id === pointerId); | ||
return this.pointerType === 'mouse' || this.pointerType === 'pen' ? this.pointers.length - 1 : arr.findIndex(this.pointers, curPointer => curPointer.id === pointerId); | ||
} | ||
@@ -387,3 +394,3 @@ | ||
updatePointer(pointer, event, eventTarget, down) { | ||
const id = utils.pointer.getPointerId(pointer); | ||
const id = pointerUtils.getPointerId(pointer); | ||
let pointerIndex = this.getPointerIndex(pointer); | ||
@@ -401,4 +408,4 @@ let pointerInfo = this.pointers[pointerIndex]; | ||
utils.pointer.setCoords(this.coords.cur, this.pointers.map(p => p.pointer), this._now()); | ||
utils.pointer.setCoordDeltas(this.coords.delta, this.coords.prev, this.coords.cur); | ||
pointerUtils.setCoords(this.coords.cur, this.pointers.map(p => p.pointer), this._now()); | ||
pointerUtils.setCoordDeltas(this.coords.delta, this.coords.prev, this.coords.cur); | ||
@@ -409,7 +416,7 @@ if (down) { | ||
pointerInfo.downTarget = eventTarget; | ||
utils.pointer.pointerExtend(this.downPointer, pointer); | ||
pointerUtils.pointerExtend(this.downPointer, pointer); | ||
if (!this.interacting()) { | ||
utils.pointer.copyCoords(this.coords.start, this.coords.cur); | ||
utils.pointer.copyCoords(this.coords.prev, this.coords.cur); | ||
pointerUtils.copyCoords(this.coords.start, this.coords.cur); | ||
pointerUtils.copyCoords(this.coords.prev, this.coords.cur); | ||
this.downEvent = event; | ||
@@ -493,3 +500,3 @@ this.pointerWasMoved = false; | ||
// update the rect changes due to pointer move | ||
utils.rect.addEdges(this.edges, rect, this.coords.delta[this.interactable.options.deltaSource]); | ||
rectUtils.addEdges(this.edges, rect, this.coords.delta[this.interactable.options.deltaSource]); | ||
rect.width = rect.right - rect.left; | ||
@@ -496,0 +503,0 @@ rect.height = rect.bottom - rect.top; |
@@ -1,2 +0,2 @@ | ||
import t from"./InteractEvent.min.js";import e from"./PointerInfo.min.js";import*as i from"../utils/index.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 n=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=i.warnOnce((function(t){this.move(t)}),"The interaction.doMove() method has been renamed to interaction.move()"),this.coords={start:i.pointer.newCoords(),prev:i.pointer.newCoords(),cur:i.pointer.newCoords(),delta:i.pointer.newCoords(),velocity:i.pointer.newCoords()},this._id=n++,this._scopeFire=e,this.pointerType=t;const o=this;this._proxy={};for(const t in _ProxyValues)Object.defineProperty(this._proxy,t,{get:()=>o[t]});for(const t in _ProxyMethods)Object.defineProperty(this._proxy,t,{value(...e){return o[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,e,n){return!(this.interacting()||!this.pointerIsDown||this.pointers.length<("gesture"===t.name?2:1)||!e.options[t.name].enabled)&&(i.copyAction(this.prepared,t),this.interactable=e,this.element=n,this.rect=e.getRect(n),this.edges=this.prepared.edges?i.extend({},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,s;this.pointerIsDown&&!this.pointerWasMoved&&(r=this.coords.cur.client.x-this.coords.start.client.x,s=this.coords.cur.client.y-this.coords.start.client.y,this.pointerWasMoved=i.hypot(r,s)>this.pointerMoveTolerance);const h=this.getPointerIndex(t),p={pointer:t,pointerIndex:h,pointerInfo:this.pointers[h],event:e,type:"move",eventTarget:n,dx:r,dy:s,duplicate:o,interaction:this};o||i.pointer.setCoordVelocity(this.coords.velocity,this.coords.delta),this._scopeFire("interactions:move",p),o||this.simulation||(this.interacting()&&(p.type=null,this.move(p)),this.pointerWasMoved&&i.pointer.copyCoords(this.coords.prev,this.coords.cur))}move(t){t&&t.event||i.pointer.setZeroCoords(this.coords.delta),(t=i.extend({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.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(t){const e=i.pointer.getPointerId(t);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:i.arr.findIndex(this.pointers,t=>t.id===e)}getPointerInfo(t){return this.pointers[this.getPointerIndex(t)]}updatePointer(t,n,o,r){const s=i.pointer.getPointerId(t);let h=this.getPointerIndex(t),p=this.pointers[h];return r=!1!==r&&(r||/(down|start)$/i.test(n.type)),p?p.pointer=t:(p=new e(s,t,n,null,null),h=this.pointers.length,this.pointers.push(p)),i.pointer.setCoords(this.coords.cur,this.pointers.map(t=>t.pointer),this._now()),i.pointer.setCoordDeltas(this.coords.delta,this.coords.prev,this.coords.cur),r&&(this.pointerIsDown=!0,p.downTime=this.coords.cur.timeStamp,p.downTarget=o,i.pointer.pointerExtend(this.downPointer,t),this.interacting()||(i.pointer.copyCoords(this.coords.start,this.coords.cur),i.pointer.copyCoords(this.coords.prev,this.coords.cur),this.downEvent=n,this.pointerWasMoved=!1)),this._updateLatestPointer(t,n,o),this._scopeFire("interactions:update-pointer",{pointer:t,event:n,eventTarget:o,down:r,pointerInfo:p,pointerIndex:h,interaction:this}),h}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(e,i,n,o){return new t(this,e,this.prepared.name,i,this.element,n,o)}_fireEvent(t){this.interactable.fire(t),(!this.prevEvent||t.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=t)}_doPhase(t){const{event:e,phase:n,preEnd:o,type:r}=t,{rect:s}=this;if(s&&"move"===n&&(i.rect.addEdges(this.edges,s,this.coords.delta[this.interactable.options.deltaSource]),s.width=s.right-s.left,s.height=s.bottom-s.top),!1===this._scopeFire("interactions:before-action-"+n,t))return!1;const h=t.iEvent=this._createPreparedEvent(e,n,o,r);return this._scopeFire("interactions:action-"+n,t),"start"===n&&(this.prevEvent=h),this._fireEvent(h),this._scopeFire("interactions:after-action-"+n,t),!0}_now(){return Date.now()}}export default Interaction;export{e 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 h from"./InteractEvent.min.js";import 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;if(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),!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 |
@@ -13,7 +13,7 @@ export interface SearchDetails { | ||
search(details: SearchDetails): any; | ||
simulationResume({ pointerType, eventType, eventTarget, scope }: SearchDetails): import("@interactjs/core/Interaction").Interaction<"drag" | "drop" | "gesture" | "resize">; | ||
simulationResume({ pointerType, eventType, eventTarget, scope }: SearchDetails): import("@interactjs/core/Interaction").Interaction<"resize" | "drag" | "drop" | "gesture">; | ||
mouseOrPen({ pointerId, pointerType, eventType, scope }: SearchDetails): any; | ||
hasPointer({ pointerId, scope }: SearchDetails): import("@interactjs/core/Interaction").Interaction<"drag" | "drop" | "gesture" | "resize">; | ||
idle({ pointerType, scope }: SearchDetails): import("@interactjs/core/Interaction").Interaction<"drag" | "drop" | "gesture" | "resize">; | ||
hasPointer({ pointerId, scope }: SearchDetails): import("@interactjs/core/Interaction").Interaction<"resize" | "drag" | "drop" | "gesture">; | ||
idle({ pointerType, scope }: SearchDetails): import("@interactjs/core/Interaction").Interaction<"resize" | "drag" | "drop" | "gesture">; | ||
}; | ||
export default finder; |
@@ -0,1 +1,5 @@ | ||
import browser from "../utils/browser.js"; | ||
import domObjects from "../utils/domObjects.js"; | ||
import { nodeContains } from "../utils/domUtils.js"; | ||
import * as pointerUtils from "../utils/pointerUtils.js"; | ||
import InteractionBase from "./Interaction.js"; | ||
@@ -5,6 +9,2 @@ import interactablePreventDefault from "./interactablePreventDefault.js"; | ||
import Scope from "./scope.js"; | ||
import browser from "../utils/browser.js"; | ||
import domObjects from "../utils/domObjects.js"; | ||
import { nodeContains } from "../utils/domUtils.js"; | ||
import * as pointerUtils from "../utils/pointerUtils.js"; | ||
const methodNames = ['pointerDown', 'pointerMove', 'pointerUp', 'updatePointer', 'removePointer', 'windowBlur']; | ||
@@ -11,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
import e from"./Interaction.min.js";import t from"./interactablePreventDefault.min.js";import n from"./interactionFinder.min.js";import o from"./scope.min.js";import r from"../utils/browser.min.js";import i from"../utils/domObjects.min.js";import{nodeContains as s}from"../utils/domUtils.min.js";import*as p from"../utils/pointerUtils.min.js";const c=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function a(e,t){return n=>{const o=t.interactions.list,i=p.getPointerType(n),[s,c]=p.getEventTargets(n),a=[];if(/^touch/.test(n.type)){t.prevTouchTime=t.now();for(const e of n.changedTouches){const o=e,r={pointer:o,pointerId:p.getPointerId(o),pointerType:i,eventType:n.type,eventTarget:s,curEventTarget:c,scope:t},u=l(r);a.push([r.pointer,r.eventTarget,r.curEventTarget,u])}}else{let e=!1;if(!r.supportsPointerEvent&&/mouse/.test(n.type)){for(let t=0;t<o.length&&!e;t++)e="mouse"!==o[t].pointerType&&o[t].pointerIsDown;e=e||t.now()-t.prevTouchTime<500||0===n.timeStamp}if(!e){const e={pointer:n,pointerId:p.getPointerId(n),pointerType:i,eventType:n.type,curEventTarget:c,eventTarget:s,scope:t},o=l(e);a.push([e.pointer,e.eventTarget,e.curEventTarget,o])}}for(const[t,o,r,i]of a)i[e](t,n,o,r)}}function l(e){const{pointerType:t,scope:o}=e,r={interaction:n.search(e),searchDetails:e};return o.fire("interactions:find",r),r.interaction||o.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(n){const o={};for(const e of c)o[e]=a(e,n);const p=r.pEventTypes;let l;function u(){for(const e of n.interactions.list)if(e.pointerIsDown&&"touch"===e.pointerType&&!e._interacting)for(const t of e.pointers)n.documents.some(({doc:e})=>s(e,t.downTarget))||e.removePointer(t.pointer,t.event)}l=i.PointerEvent?[{type:p.down,listener:u},{type:p.down,listener:o.pointerDown},{type:p.move,listener:o.pointerMove},{type:p.up,listener:o.pointerUp},{type:p.cancel,listener:o.pointerUp}]:[{type:"mousedown",listener:o.pointerDown},{type:"mousemove",listener:o.pointerMove},{type:"mouseup",listener:o.pointerUp},{type:"touchstart",listener:u},{type:"touchstart",listener:o.pointerDown},{type:"touchmove",listener:o.pointerMove},{type:"touchend",listener:o.pointerUp},{type:"touchcancel",listener:o.pointerUp}],l.push({type:"blur",listener(e){for(const t of n.interactions.list)t.documentBlur(e)}}),n.prevTouchTime=0,n.Interaction=class extends e{get pointerMoveTolerance(){return n.interactions.pointerMoveTolerance}set pointerMoveTolerance(e){n.interactions.pointerMoveTolerance=e}_now(){return n.now()}},n.interactions={list:[],new(e){e.scopeFire=(e,t)=>n.fire(e,t);const t=new n.Interaction(e);return n.interactions.list.push(t),t},listeners:o,docEvents:l,pointerMoveTolerance:1},n.usePlugin(t)},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; | ||
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 |
@@ -1,5 +0,5 @@ | ||
/** @module interact */ | ||
import * as domUtils from '@interactjs/utils/domUtils'; | ||
import * as pointerUtils from '@interactjs/utils/pointerUtils'; | ||
import Interactable from './Interactable'; | ||
import { Options } from './defaultOptions'; | ||
import * as utils from '@interactjs/utils/index'; | ||
export interface InteractStatic { | ||
@@ -9,10 +9,10 @@ (target: Interact.Target, options?: Options): Interactable; | ||
export declare class InteractStatic { | ||
getPointerAverage: typeof utils.pointer.pointerAverage; | ||
getTouchBBox: typeof utils.pointer.touchBBox; | ||
getTouchDistance: typeof utils.pointer.touchDistance; | ||
getTouchAngle: typeof utils.pointer.touchAngle; | ||
getElementRect: typeof utils.dom.getElementRect; | ||
getElementClientRect: typeof utils.dom.getElementClientRect; | ||
matchesSelector: typeof utils.dom.matchesSelector; | ||
closest: typeof utils.dom.closest; | ||
getPointerAverage: typeof pointerUtils.pointerAverage; | ||
getTouchBBox: typeof pointerUtils.touchBBox; | ||
getTouchDistance: typeof pointerUtils.touchDistance; | ||
getTouchAngle: typeof pointerUtils.touchAngle; | ||
getElementRect: typeof domUtils.getElementRect; | ||
getElementClientRect: typeof domUtils.getElementClientRect; | ||
matchesSelector: typeof domUtils.matchesSelector; | ||
closest: typeof domUtils.closest; | ||
globalEvents: any; | ||
@@ -19,0 +19,0 @@ dynamicDrop: (newValue?: boolean) => boolean | this; |
/** @module interact */ | ||
import browser from "../utils/browser.js"; | ||
import * as domUtils from "../utils/domUtils.js"; | ||
import extend from "../utils/extend.js"; | ||
import is from "../utils/is.js"; | ||
import * as pointerUtils from "../utils/pointerUtils.js"; | ||
import { isNonNativeEvent } from "./scope.js"; | ||
import browser from "../utils/browser.js"; | ||
import * as utils from "../utils/index.js"; | ||
export class InteractStatic { | ||
@@ -9,13 +12,13 @@ // expose the functions used to calculate multi-touch properties | ||
constructor(scope) { | ||
this.getPointerAverage = utils.pointer.pointerAverage; | ||
this.getTouchBBox = utils.pointer.touchBBox; | ||
this.getTouchDistance = utils.pointer.touchDistance; | ||
this.getTouchAngle = utils.pointer.touchAngle; | ||
this.getElementRect = utils.dom.getElementRect; | ||
this.getElementClientRect = utils.dom.getElementClientRect; | ||
this.matchesSelector = utils.dom.matchesSelector; | ||
this.closest = utils.dom.closest; | ||
this.getPointerAverage = pointerUtils.pointerAverage; | ||
this.getTouchBBox = pointerUtils.touchBBox; | ||
this.getTouchDistance = pointerUtils.touchDistance; | ||
this.getTouchAngle = pointerUtils.touchAngle; | ||
this.getElementRect = domUtils.getElementRect; | ||
this.getElementClientRect = domUtils.getElementClientRect; | ||
this.matchesSelector = domUtils.matchesSelector; | ||
this.closest = domUtils.closest; | ||
this.globalEvents = {}; | ||
this.dynamicDrop = void 0; | ||
this.version = "1.9.10"; | ||
this.version = "1.9.11"; | ||
this.interact = void 0; | ||
@@ -68,3 +71,3 @@ this.scope = void 0; | ||
utils.extend(interact, this); | ||
extend(interact, this); | ||
interact.constructor = this.constructor; | ||
@@ -118,7 +121,7 @@ this.interact = interact; | ||
on(type, listener, options) { | ||
if (utils.is.string(type) && type.search(' ') !== -1) { | ||
if (is.string(type) && type.search(' ') !== -1) { | ||
type = type.trim().split(/ +/); | ||
} | ||
if (utils.is.array(type)) { | ||
if (is.array(type)) { | ||
for (const eventType of type) { | ||
@@ -131,3 +134,3 @@ this.on(eventType, listener, options); | ||
if (utils.is.object(type)) { | ||
if (is.object(type)) { | ||
for (const prop in type) { | ||
@@ -172,7 +175,7 @@ this.on(prop, type[prop], listener); | ||
off(type, listener, options) { | ||
if (utils.is.string(type) && type.search(' ') !== -1) { | ||
if (is.string(type) && type.search(' ') !== -1) { | ||
type = type.trim().split(/ +/); | ||
} | ||
if (utils.is.array(type)) { | ||
if (is.array(type)) { | ||
for (const eventType of type) { | ||
@@ -185,3 +188,3 @@ this.off(eventType, listener, options); | ||
if (utils.is.object(type)) { | ||
if (is.object(type)) { | ||
for (const prop in type) { | ||
@@ -258,3 +261,3 @@ this.off(prop, type[prop], listener); | ||
pointerMoveTolerance(newValue) { | ||
if (utils.is.number(newValue)) { | ||
if (is.number(newValue)) { | ||
this.scope.interactions.pointerMoveTolerance = newValue; | ||
@@ -261,0 +264,0 @@ return this; |
@@ -1,2 +0,2 @@ | ||
import{isNonNativeEvent as t}from"./scope.min.js";import e from"../utils/browser.min.js";import*as s from"../utils/index.min.js";export class InteractStatic{constructor(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.10",this.interact=void 0,this.scope=void 0,this.scope=t;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(e,o,i){if(s.is.string(e)&&-1!==e.search(" ")&&(e=e.trim().split(/ +/)),s.is.array(e)){for(const t of e)this.on(t,o,i);return this}if(s.is.object(e)){for(const t in e)this.on(t,e[t],o);return this}return t(e,this.scope.actions)?this.globalEvents[e]?this.globalEvents[e].push(o):this.globalEvents[e]=[o]:this.scope.events.add(this.scope.document,e,o,{options:i}),this}off(e,o,i){if(s.is.string(e)&&-1!==e.search(" ")&&(e=e.trim().split(/ +/)),s.is.array(e)){for(const t of e)this.off(t,o,i);return this}if(s.is.object(e)){for(const t in e)this.off(t,e[t],o);return this}if(t(e,this.scope.actions)){let t;e in this.globalEvents&&-1!==(t=this.globalEvents[e].indexOf(o))&&this.globalEvents[e].splice(t,1)}else this.scope.events.remove(this.scope.document,e,o,i);return this}debug(){return this.scope}supportsTouch(){return e.supportsTouch}supportsPointerEvent(){return e.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/domUtils.min.js";import s from"../utils/extend.min.js";import o from"../utils/is.min.js";import*as i from"../utils/pointerUtils.min.js";import{isNonNativeEvent as r}from"./scope.min.js";export class InteractStatic{constructor(t){this.getPointerAverage=i.pointerAverage,this.getTouchBBox=i.touchBBox,this.getTouchDistance=i.touchDistance,this.getTouchAngle=i.touchAngle,this.getElementRect=e.getElementRect,this.getElementClientRect=e.getElementClientRect,this.matchesSelector=e.matchesSelector,this.closest=e.closest,this.globalEvents={},this.dynamicDrop=void 0,this.version="1.9.11",this.interact=void 0,this.scope=void 0,this.scope=t;const{prototype:o}=this.constructor,r=(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))r[t]=o[t];return s(r,this),r.constructor=this.constructor,this.interact=r,r}use(t,e){return this.scope.usePlugin(t,e),this}isSet(t,e){return!!this.scope.interactables.get(t,e&&e.context)}on(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 s in t)this.on(s,t[s],e);return this}return r(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}off(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 s in t)this.off(s,t[s],e);return this}if(r(t,this.scope.actions)){let s;t in this.globalEvents&&-1!==(s=this.globalEvents[t].indexOf(e))&&this.globalEvents[t].splice(s,1)}else this.scope.events.remove(this.scope.document,t,e,s);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 o.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.10", | ||
"version": "1.9.11", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/utils": "1.9.10" | ||
"@interactjs/utils": "1.9.11" | ||
}, | ||
"devDependencies": { | ||
"@interactjs/actions": "1.9.10", | ||
"@interactjs/auto-start": "1.9.10" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "0a55a5d5" | ||
"gitHead": "6b07bf54" | ||
} |
@@ -1,2 +0,1 @@ | ||
/* eslint-disable @typescript-eslint/no-parameter-properties */ | ||
export class PointerInfo { | ||
@@ -3,0 +2,0 @@ constructor(id, pointer, event, downTime, downTarget) { |
import Eventable from './Eventable'; | ||
import InteractEvent, { PhaseMap } from './InteractEvent'; | ||
import InteractStatic from './InteractStatic'; | ||
import InteractableBase from './Interactable'; | ||
import InteractableSet from './InteractableSet'; | ||
import * as utils from '@interactjs/utils/index'; | ||
export interface SignalArgs { | ||
@@ -79,7 +77,6 @@ 'scope:add-document': DocSignalArg; | ||
}; | ||
utils: typeof utils; | ||
defaults: import("@interactjs/core/defaultOptions").Defaults; | ||
Eventable: typeof Eventable; | ||
actions: Actions; | ||
interactStatic: InteractStatic; | ||
interactStatic: any; | ||
InteractEvent: typeof InteractEvent; | ||
@@ -105,3 +102,3 @@ Interactable: typeof InteractableBase; | ||
onWindowUnload: (event: BeforeUnloadEvent) => void; | ||
init(window: Window): import("@interactjs/core/scope").default; | ||
init(window: Window): Scope; | ||
pluginIsInstalled(plugin: Plugin): boolean | Plugin; | ||
@@ -118,3 +115,3 @@ usePlugin(plugin: Plugin, options?: { | ||
export declare function isNonNativeEvent(type: string, actions: Actions): boolean; | ||
export declare function initScope(scope: Scope, window: Window): import("@interactjs/core/scope").default; | ||
export declare function initScope(scope: Scope, window: Window): Scope; | ||
export { Scope }; |
20
scope.js
@@ -0,1 +1,8 @@ | ||
/* eslint-disable import/no-named-as-default-member */ | ||
import browser from "../utils/browser.js"; | ||
import clone from "../utils/clone.js"; | ||
import domObjects from "../utils/domObjects.js"; | ||
import extend from "../utils/extend.js"; | ||
import raf from "../utils/raf.js"; | ||
import win from "../utils/window.js"; | ||
import Eventable from "./Eventable.js"; | ||
@@ -9,10 +16,2 @@ import InteractEvent from "./InteractEvent.js"; | ||
import interactions from "./interactions.js"; | ||
import domObjects from "../utils/domObjects.js"; | ||
import * as utils from "../utils/index.js"; | ||
const { | ||
win, | ||
browser, | ||
raf | ||
} = utils; // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export default class Scope { | ||
@@ -28,4 +27,3 @@ // main window | ||
this.browser = browser; | ||
this.utils = utils; | ||
this.defaults = utils.clone(defaults); | ||
this.defaults = clone(defaults); | ||
this.Eventable = Eventable; | ||
@@ -166,3 +164,3 @@ this.actions = { | ||
const window = win.getWindow(doc); | ||
options = options ? utils.extend({}, options) : {}; | ||
options = options ? extend({}, options) : {}; | ||
this.documents.push({ | ||
@@ -169,0 +167,0 @@ doc, |
@@ -1,2 +0,2 @@ | ||
import t from"./Eventable.min.js";import i from"./InteractEvent.min.js";import s from"./InteractStatic.min.js";import e from"./Interactable.min.js";import n from"./InteractableSet.min.js";import o from"./defaultOptions.min.js";import r from"./events.min.js";import a from"./interactions.min.js";import h from"../utils/domObjects.min.js";import*as d from"../utils/index.min.js";const{win:l,browser:c,raf:u}=d;export default class p{constructor(){this.id="__interact_scope_"+Math.floor(100*Math.random()),this.isInitialized=!1,this.listenerMaps=[],this.browser=c,this.utils=d,this.defaults=d.clone(o),this.Eventable=t,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=new s(this),this.InteractEvent=i,this.Interactable=void 0,this.interactables=new n(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 r=this;this.Interactable=class extends e{get _defaults(){return r.defaults}set(t){return super.set(t),r.fire("interactable:set",{options:t,interactable:this}),this}unset(){super.unset(),r.interactables.list.splice(r.interactables.list.indexOf(this),1),r.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=l.getWindow(t);i=i?d.extend({},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=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(t,i){return t.isInitialized=!0,l.init(i),h.init(i),c.init(i),u.init(i),t.window=i,t.document=i.document,t.usePlugin(a),t.usePlugin(r),t}export{p as Scope}; | ||
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 r from"./Eventable.min.js";import a from"./InteractEvent.min.js";import l from"./InteractStatic.min.js";import d from"./Interactable.min.js";import h from"./InteractableSet.min.js";import m from"./defaultOptions.min.js";import u from"./events.min.js";import c from"./interactions.min.js";export default class p{constructor(){this.id="__interact_scope_"+Math.floor(100*Math.random()),this.isInitialized=!1,this.listenerMaps=[],this.browser=t,this.defaults=i(m),this.Eventable=r,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=new l(this),this.InteractEvent=a,this.Interactable=void 0,this.interactables=new h(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 d{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 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,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(c),i.usePlugin(u),i}export{p as Scope}; | ||
//# sourceMappingURL=scope.min.js.map |
@@ -1,2 +0,3 @@ | ||
import * as utils from '@interactjs/utils/index'; | ||
import * as pointerUtils from '@interactjs/utils/pointerUtils'; | ||
import Scope from '../scope'; | ||
export declare function unique(): number; | ||
@@ -61,4 +62,4 @@ export declare function uniqueProps(obj: any): void; | ||
}; | ||
export declare function newPointer(n?: number): import("../../types/types").PointerType; | ||
export declare function mockScope(options?: any): import("@interactjs/core/scope").default; | ||
export declare function newPointer(n?: number): import("../../types").PointerType; | ||
export declare function mockScope(options?: any): Scope; | ||
export declare function getProps<T extends { | ||
@@ -72,9 +73,9 @@ [key: string]: any; | ||
}): { | ||
scope: import("@interactjs/core/scope").default; | ||
interaction: import("@interactjs/core/Interaction").Interaction<"drag" | "drop" | "gesture" | "resize">; | ||
scope: Scope; | ||
interaction: import("@interactjs/core/Interaction").Interaction<"resize" | "drag" | "drop" | "gesture">; | ||
target: T; | ||
interactable: import("@interactjs/core/Interactable").Interactable; | ||
coords: utils.pointer.MockCoords; | ||
coords: pointerUtils.MockCoords; | ||
event: ({ | ||
coords: utils.pointer.MockCoords; | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -94,3 +95,3 @@ readonly client: any; | ||
} & MouseEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -109,4 +110,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & MouseEvent & TouchEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & MouseEvent & PointerEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -125,4 +126,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & MouseEvent & PointerEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & MouseEvent & import("../../types").PointerEvent<any>) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -141,4 +142,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & MouseEvent & import("@interactjs/pointer-events/PointerEvent").default<any>) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & MouseEvent & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow">) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -157,4 +158,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & MouseEvent & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow">) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & MouseEvent & TouchEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -173,4 +174,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & PointerEvent & MouseEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & Touch & MouseEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -189,4 +190,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & PointerEvent & TouchEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & Touch & PointerEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -205,4 +206,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & PointerEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & Touch & import("../../types").PointerEvent<any>) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -221,4 +222,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & PointerEvent & import("@interactjs/pointer-events/PointerEvent").default<any>) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & Touch & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow">) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -237,4 +238,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & PointerEvent & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow">) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & Touch & TouchEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -253,4 +254,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/pointer-events/PointerEvent").default<any> & MouseEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & PointerEvent & MouseEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -269,4 +270,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/pointer-events/PointerEvent").default<any> & TouchEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & PointerEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -285,4 +286,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/pointer-events/PointerEvent").default<any> & PointerEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & PointerEvent & import("../../types").PointerEvent<any>) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -301,4 +302,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/pointer-events/PointerEvent").default<any>) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & PointerEvent & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow">) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -317,4 +318,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/pointer-events/PointerEvent").default<any> & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow">) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & PointerEvent & TouchEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -333,4 +334,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow"> & MouseEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").PointerEvent<any> & MouseEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -349,4 +350,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow"> & TouchEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").PointerEvent<any> & PointerEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -365,4 +366,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow"> & PointerEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").PointerEvent<any>) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -381,4 +382,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow"> & import("@interactjs/pointer-events/PointerEvent").default<any>) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").PointerEvent<any> & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow">) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -397,4 +398,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow">) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").PointerEvent<any> & TouchEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -413,4 +414,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & Touch & MouseEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow"> & MouseEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -429,4 +430,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & Touch & TouchEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow"> & PointerEvent) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -445,4 +446,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & Touch & PointerEvent) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow"> & import("../../types").PointerEvent<any>) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -461,4 +462,4 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & Touch & import("@interactjs/pointer-events/PointerEvent").default<any>) | ({ | ||
coords: utils.pointer.MockCoords; | ||
} & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow">) | ({ | ||
coords: pointerUtils.MockCoords; | ||
readonly page: any; | ||
@@ -477,5 +478,5 @@ readonly client: any; | ||
preventDefault(): void; | ||
} & Touch & import("@interactjs/core/InteractEvent").InteractEvent<never, "start" | "move" | "end" | "resume" | "inertiastart" | "reflow">); | ||
interact: import("@interactjs/core/InteractStatic").InteractStatic; | ||
start: (action: import("@interactjs/core/Interaction").ActionProps<any>) => any; | ||
} & import("../../types").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow"> & TouchEvent); | ||
interact: any; | ||
start: (action: import("../../types").ActionProps<any>) => boolean; | ||
stop: () => void; | ||
@@ -482,0 +483,0 @@ down: () => void; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
452126
0
3750