@interactjs/core
Advanced tools
Comparing version 1.10.1 to 1.10.2
@@ -0,1 +1,2 @@ | ||
import { Scope } from "./scope.js"; | ||
import * as arr from "../utils/arr.js"; | ||
@@ -2,0 +3,0 @@ import * as domUtils from "../utils/domUtils.js"; |
@@ -1,2 +0,2 @@ | ||
import*as e from"../utils/arr.prod.js";import*as t from"../utils/domUtils.prod.js";import s from"../utils/extend.prod.js";import n from"../utils/is.prod.js";import r from"../utils/pointerExtend.prod.js";import*as o from"../utils/pointerUtils.prod.js";class i{constructor(e){this.currentTarget=void 0,this.originalEvent=void 0,this.type=void 0,this.originalEvent=e,r(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}function a(e){if(!n.object(e))return{capture:!!e,passive:!1};const t=s({},e);return t.capture=!!e.capture,t.passive=!!e.passive,t}export default{id:"events",install(s){const r=[],p={},l=[],c={add:u,remove:v,addDelegate(t,s,n,r,o){const i=a(o);if(!p[n]){p[n]=[];for(const e of l)u(e,n,d),u(e,n,f,!0)}const c=p[n];let v=e.find(c,e=>e.selector===t&&e.context===s);v||(v={selector:t,context:s,listeners:[]},c.push(v)),v.listeners.push([r,i])},removeDelegate(e,t,s,n,r){const o=a(r),i=p[s];let l,c=!1;if(i)for(l=i.length-1;l>=0;l--){const r=i[l];if(r.selector===e&&r.context===t){const{listeners:e}=r;for(let r=e.length-1;r>=0;r--){const[a,{capture:p,passive:u}]=e[r];if(a===n&&p===o.capture&&u===o.passive){e.splice(r,1),e.length||(i.splice(l,1),v(t,s,d),v(t,s,f,!0)),c=!0;break}}if(c)break}}},delegateListener:d,delegateUseCapture:f,delegatedEvents:p,documents:l,targets:r,supportsOptions:!1,supportsPassive:!1};function u(t,s,n,o){const i=a(o);let p=e.find(r,e=>e.eventTarget===t);p||(p={eventTarget:t,events:{}},r.push(p)),p.events[s]||(p.events[s]=[]),t.addEventListener&&!e.contains(p.events[s],n)&&(t.addEventListener(s,n,c.supportsOptions?i:i.capture),p.events[s].push(n))}function v(t,s,n,o){const i=a(o),p=e.findIndex(r,e=>e.eventTarget===t),l=r[p];if(!l||!l.events)return;if("all"===s){for(s in l.events)l.events.hasOwnProperty(s)&&v(t,s,"all");return}let u=!1;const d=l.events[s];if(d){if("all"===n){for(let e=d.length-1;e>=0;e--)v(t,s,d[e],i);return}for(let e=0;e<d.length;e++)if(d[e]===n){t.removeEventListener(s,n,c.supportsOptions?i:i.capture),d.splice(e,1),0===d.length&&(delete l.events[s],u=!0);break}}u&&!Object.keys(l.events).length&&r.splice(p,1)}function d(e,s){const r=a(s),l=new i(e),c=p[e.type],[u]=o.getEventTargets(e);let v=u;for(;n.element(v);){for(let e=0;e<c.length;e++){const s=c[e],{selector:n,context:o}=s;if(t.matchesSelector(v,n)&&t.nodeContains(o,u)&&t.nodeContains(o,v)){const{listeners:e}=s;l.currentTarget=v;for(const[t,{capture:s,passive:n}]of e)s===r.capture&&n===r.passive&&t(l)}}v=t.parentNode(v)}}function f(e){return d(e,!0)}return s.document.createElement("div").addEventListener("test",null,{get capture(){return c.supportsOptions=!0},get passive(){return c.supportsPassive=!0}}),s.events=c,c}}; | ||
import{Scope as e}from"./scope.prod.js";import*as t from"../utils/arr.prod.js";import*as s from"../utils/domUtils.prod.js";import n from"../utils/extend.prod.js";import r from"../utils/is.prod.js";import o from"../utils/pointerExtend.prod.js";import*as i from"../utils/pointerUtils.prod.js";class a{constructor(e){this.currentTarget=void 0,this.originalEvent=void 0,this.type=void 0,this.originalEvent=e,o(this,e)}preventOriginalDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}stopImmediatePropagation(){this.originalEvent.stopImmediatePropagation()}}function p(e){if(!r.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(e){const n=[],o={},l=[],c={add:u,remove:v,addDelegate(e,s,n,r,i){const a=p(i);if(!o[n]){o[n]=[];for(const e of l)u(e,n,d),u(e,n,f,!0)}const c=o[n];let v=t.find(c,(t=>t.selector===e&&t.context===s));v||(v={selector:e,context:s,listeners:[]},c.push(v)),v.listeners.push([r,a])},removeDelegate(e,t,s,n,r){const i=p(r),a=o[s];let l,c=!1;if(a)for(l=a.length-1;l>=0;l--){const r=a[l];if(r.selector===e&&r.context===t){const{listeners:e}=r;for(let r=e.length-1;r>=0;r--){const[o,{capture:p,passive:u}]=e[r];if(o===n&&p===i.capture&&u===i.passive){e.splice(r,1),e.length||(a.splice(l,1),v(t,s,d),v(t,s,f,!0)),c=!0;break}}if(c)break}}},delegateListener:d,delegateUseCapture:f,delegatedEvents:o,documents:l,targets:n,supportsOptions:!1,supportsPassive:!1};function u(e,s,r,o){const i=p(o);let a=t.find(n,(t=>t.eventTarget===e));a||(a={eventTarget:e,events:{}},n.push(a)),a.events[s]||(a.events[s]=[]),e.addEventListener&&!t.contains(a.events[s],r)&&(e.addEventListener(s,r,c.supportsOptions?i:i.capture),a.events[s].push(r))}function v(e,s,r,o){const i=p(o),a=t.findIndex(n,(t=>t.eventTarget===e)),l=n[a];if(!l||!l.events)return;if("all"===s){for(s in l.events)l.events.hasOwnProperty(s)&&v(e,s,"all");return}let u=!1;const d=l.events[s];if(d){if("all"===r){for(let t=d.length-1;t>=0;t--)v(e,s,d[t],i);return}for(let t=0;t<d.length;t++)if(d[t]===r){e.removeEventListener(s,r,c.supportsOptions?i:i.capture),d.splice(t,1),0===d.length&&(delete l.events[s],u=!0);break}}u&&!Object.keys(l.events).length&&n.splice(a,1)}function d(e,t){const n=p(t),l=new a(e),c=o[e.type],[u]=i.getEventTargets(e);let v=u;for(;r.element(v);){for(let e=0;e<c.length;e++){const t=c[e],{selector:r,context:o}=t;if(s.matchesSelector(v,r)&&s.nodeContains(o,u)&&s.nodeContains(o,v)){const{listeners:e}=t;l.currentTarget=v;for(const[t,{capture:s,passive:r}]of e)s===n.capture&&r===n.passive&&t(l)}}v=s.parentNode(v)}}function f(e){return d(e,!0)}return e.document.createElement("div").addEventListener("test",null,{get capture(){return c.supportsOptions=!0},get passive(){return c.supportsPassive=!0}}),e.events=c,c}}; | ||
//# sourceMappingURL=events.prod.js.map |
@@ -111,3 +111,3 @@ /* eslint-disable no-dupe-class-members */ | ||
* @param {Element} [element] The element to measure. | ||
* @return {Interact.Rect} The object's bounding rectangle. | ||
* @return {Rect} The object's bounding rectangle. | ||
*/ | ||
@@ -114,0 +114,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { Interactable } from "./Interactable.js"; | ||
import { matchesSelector, nodeContains } from "../utils/domUtils.js"; | ||
@@ -2,0 +3,0 @@ import is from "../utils/is.js"; |
@@ -1,2 +0,2 @@ | ||
import{matchesSelector as t,nodeContains as e}from"../utils/domUtils.prod.js";import n from"../utils/is.prod.js";import{getWindow as r}from"../utils/window.prod.js";function o(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 i({interaction:t,event:e}){t.interactable&&t.interactable.checkAndPreventDefault(e)}export function install(i){const{Interactable:s}=i;s.prototype.preventDefault=o,s.prototype.checkAndPreventDefault=function(e){return((e,o,i)=>{const s=e.options.preventDefault;if("never"!==s)if("always"!==s){if(o.events.supportsPassive&&/^touch(start|move)$/.test(i.type)){const t=r(i.target).document,e=o.getDocOptions(t);if(!e||!e.events||!1!==e.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(i.type)||n.element(i.target)&&t(i.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||i.preventDefault()}else i.preventDefault()})(this,i,e)},i.interactions.docEvents.push({type:"dragstart",listener(t){for(const n of i.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]=i,t),{})}; | ||
import{Interactable as t}from"./Interactable.prod.js";import{matchesSelector as e,nodeContains as n}from"../utils/domUtils.prod.js";import r from"../utils/is.prod.js";import{getWindow as o}from"../utils/window.prod.js";function i(t){return/^(always|never|auto)$/.test(t)?(this.options.preventDefault=t,this):r.bool(t)?(this.options.preventDefault=t?"always":"never",this):this.options.preventDefault}function s({interaction:t,event:e}){t.interactable&&t.interactable.checkAndPreventDefault(e)}export function install(t){const{Interactable:s}=t;s.prototype.preventDefault=i,s.prototype.checkAndPreventDefault=function(n){return((t,n,i)=>{const s=t.options.preventDefault;if("never"!==s)if("always"!==s){if(n.events.supportsPassive&&/^touch(start|move)$/.test(i.type)){const t=o(i.target).document,e=n.getDocOptions(t);if(!e||!e.events||!1!==e.events.passive)return}/^(mouse|pointer|touch)*(down|start)/i.test(i.type)||r.element(i.target)&&e(i.target,"input,select,textarea,[contenteditable=true],[contenteditable=true] *")||i.preventDefault()}else i.preventDefault()})(this,t,n)},t.interactions.docEvents.push({type:"dragstart",listener(e){for(const r of t.interactions.list)if(r.element&&(r.element===e.target||n(r.element,e.target)))return void r.interactable.checkAndPreventDefault(e)}})}export default{id:"core/interactablePreventDefault",install:install,listeners:["down","move","up","cancel"].reduce(((t,e)=>(t["interactions:"+e]=s,t)),{})}; | ||
//# sourceMappingURL=interactablePreventDefault.prod.js.map |
@@ -1,2 +0,2 @@ | ||
import*as t from"../utils/arr.prod.js";import*as e from"../utils/domUtils.prod.js";import s from"../utils/extend.prod.js";import i from"../utils/is.prod.js";export class InteractableSet{constructor(e){this.list=[],this.selectorMap={},this.scope=void 0,this.scope=e,e.addListeners({"interactable:unset":({interactable:e})=>{const{target:s,_context:o}=e,c=i.string(s)?this.selectorMap[s]:s[this.scope.id],n=t.findIndex(c,t=>t.context===o);c[n]&&(c[n].context=null,c[n].interactable=null),c.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),c={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(c)):(o.target[this.scope.id]||Object.defineProperty(t,this.scope.id,{value:[],configurable:!0}),t[this.scope.id].push(c)),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,c=i.string(e),n=c?this.selectorMap[e]:e[this.scope.id];if(!n)return null;const r=t.find(n,t=>t.context===o&&(c||t.interactable.inContext(e)));return r&&r.interactable}forEachMatch(t,s){for(const o of this.list){let c;if((i.string(o.target)?i.element(t)&&e.matchesSelector(t,o.target):t===o.target)&&o.inContext(t)&&(c=s(o)),void 0!==c)return c}}} | ||
import*as t from"../utils/arr.prod.js";import*as e from"../utils/domUtils.prod.js";import s from"../utils/extend.prod.js";import i from"../utils/is.prod.js";export class InteractableSet{constructor(e){this.list=[],this.selectorMap={},this.scope=void 0,this.scope=e,e.addListeners({"interactable:unset":({interactable:e})=>{const{target:s,_context:o}=e,c=i.string(s)?this.selectorMap[s]:s[this.scope.id],n=t.findIndex(c,(t=>t.context===o));c[n]&&(c[n].context=null,c[n].interactable=null),c.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),c={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(c)):(o.target[this.scope.id]||Object.defineProperty(t,this.scope.id,{value:[],configurable:!0}),t[this.scope.id].push(c)),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,c=i.string(e),n=c?this.selectorMap[e]:e[this.scope.id];if(!n)return null;const r=t.find(n,(t=>t.context===o&&(c||t.interactable.inContext(e))));return r&&r.interactable}forEachMatch(t,s){for(const o of this.list){let c;if((i.string(o.target)?i.element(t)&&e.matchesSelector(t,o.target):t===o.target)&&o.inContext(t)&&(c=s(o)),void 0!==c)return c}}} | ||
//# sourceMappingURL=InteractableSet.prod.js.map |
@@ -7,3 +7,2 @@ import extend from "../utils/extend.js"; | ||
export class InteractEvent extends BaseEvent { | ||
// drag | ||
// resize | ||
@@ -40,4 +39,2 @@ | ||
this.timeStamp = void 0; | ||
this.dragEnter = void 0; | ||
this.dragLeave = void 0; | ||
this.axes = void 0; | ||
@@ -44,0 +41,0 @@ this.preEnd = void 0; |
@@ -1,2 +0,2 @@ | ||
import t from"../utils/extend.prod.js";import e from"../utils/getOriginXY.prod.js";import i from"../utils/hypot.prod.js";import{BaseEvent as s}from"./BaseEvent.prod.js";import{defaults as o}from"./defaultOptions.prod.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}}}); | ||
import t from"../utils/extend.prod.js";import e from"../utils/getOriginXY.prod.js";import i from"../utils/hypot.prod.js";import{BaseEvent as s}from"./BaseEvent.prod.js";import{defaults as o}from"./defaultOptions.prod.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.axes=void 0,this.preEnd=void 0,a=a||s.element;const c=s.interactable,l=(c&&c.options||o).deltaSource,v=e(c,a,h),y="start"===n,g="end"===n,m=y?this:s.prevEvent,u=y?s.coords.start:g?{page:m.page,client:m.client,timeStamp:s.coords.cur.timeStamp}:s.coords.cur;this.page=t({},u.page),this.client=t({},u.client),this.rect=t({},s.rect),this.timeStamp=u.timeStamp,g||(this.page.x-=v.x,this.page.y-=v.y,this.client.x-=v.x,this.client.y-=v.y),this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.shiftKey=r.shiftKey,this.metaKey=r.metaKey,this.button=r.button,this.buttons=r.buttons,this.target=a,this.currentTarget=a,this.preEnd=p,this.type=d||h+(n||""),this.interactable=c,this.t0=y?s.pointers[s.pointers.length-1].downTime:m.t0,this.x0=s.coords.start.page.x-v.x,this.y0=s.coords.start.page.y-v.y,this.clientX0=s.coords.start.client.x-v.x,this.clientY0=s.coords.start.client.y-v.y,this.delta=y||g?{x:0,y:0}:{x:this[l].x-m[l].x,y:this[l].y-m[l].y},this.dt=s.coords.delta.timeStamp,this.duration=this.timeStamp-this.t0,this.velocity=t({},s.coords.velocity[l]),this.speed=i(this.velocity.x,this.velocity.y),this.swipe=g||"inertiastart"===n?this.getSwipe():null}getSwipe(){const t=this._interaction;if(t.prevEvent.speed<600||this.timeStamp-t.prevEvent.timeStamp>150)return null;let e=180*Math.atan2(t.prevEvent.velocityY,t.prevEvent.velocityX)/Math.PI;e<0&&(e+=360);const i=112.5<=e&&e<247.5,s=202.5<=e&&e<337.5;return{up:s,down:!s&&22.5<=e&&e<157.5,left:i,right:!i&&(292.5<=e||e<67.5),angle:e,speed:t.prevEvent.speed,velocity:{x:t.prevEvent.velocityX,y:t.prevEvent.velocityY}}}preventDefault(){}stopImmediatePropagation(){this.immediatePropagationStopped=this.propagationStopped=!0}stopPropagation(){this.propagationStopped=!0}}Object.defineProperties(InteractEvent.prototype,{pageX:{get(){return this.page.x},set(t){this.page.x=t}},pageY:{get(){return this.page.y},set(t){this.page.y=t}},clientX:{get(){return this.client.x},set(t){this.client.x=t}},clientY:{get(){return this.client.y},set(t){this.client.y=t}},dx:{get(){return this.delta.x},set(t){this.delta.x=t}},dy:{get(){return this.delta.y},set(t){this.delta.y=t}},velocityX:{get(){return this.velocity.x},set(t){this.velocity.x=t}},velocityY:{get(){return this.velocity.y},set(t){this.velocity.y=t}}}); | ||
//# sourceMappingURL=InteractEvent.prod.js.map |
@@ -1,2 +0,2 @@ | ||
import*as t from"../utils/arr.prod.js";import e from"../utils/extend.prod.js";import i from"../utils/hypot.prod.js";import{warnOnce as o,copyAction as n}from"../utils/misc.prod.js";import*as s from"../utils/pointerUtils.prod.js";import*as r from"../utils/rect.prod.js";import{InteractEvent as h}from"./InteractEvent.prod.js";import{PointerInfo as p}from"./PointerInfo.prod.js";export let _ProxyValues;(t=>{t.interactable="",t.element="",t.prepared="",t.pointerIsDown="",t.pointerWasMoved="",t._proxy=""})(_ProxyValues||(_ProxyValues={}));export let _ProxyMethods;(t=>{t.start="",t.move="",t.end="",t.stop="",t.interacting=""})(_ProxyMethods||(_ProxyMethods={}));let a=0;export class Interaction{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=o((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(){return i[t]}});for(const t in _ProxyMethods)Object.defineProperty(this._proxy,t,{value:(...e)=>i[t](...e)});this._scopeFire("interactions:new",{interaction:this})}pointerDown(t,e,i){const o=this.updatePointer(t,e,i,!0),n=this.pointers[o];this._scopeFire("interactions:down",{pointer:t,event:e,eventTarget:i,pointerIndex:o,pointerInfo:n,type:"down",interaction:this})}start(t,i,o){return!(this.interacting()||!this.pointerIsDown||this.pointers.length<("gesture"===t.name?2:1)||!i.options[t.name].enabled)&&(n(this.prepared,t),this.interactable=i,this.element=o,this.rect=i.getRect(o),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,o){this.simulation||this.modification&&this.modification.endResult||this.updatePointer(t,e,o,!1);const n=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:o,dx:r,dy:h,duplicate:n,interaction:this};n||s.setCoordVelocity(this.coords.velocity,this.coords.delta),this._scopeFire("interactions:move",a),n||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,o){let n=this.getPointerIndex(t);-1===n&&(n=this.updatePointer(t,e,i,!1));const s=/cancel$/i.test(e.type)?"cancel":"up";this._scopeFire("interactions:"+s,{pointer:t,pointerIndex:n,pointerInfo:this.pointers[n],event:e,eventTarget:i,type:s,curEventTarget:o,interaction:this}),this.simulation||this.end(e),this.removePointer(t,e)}documentBlur(t){this.end(t),this._scopeFire("interactions:blur",{event:t,type:"blur",interaction:this})}end(t){let e;this._ending=!0,t=t||this._latestPointer.event,this.interacting()&&(e=this._doPhase({event:t,interaction:this,phase:"end"})),this._ending=!1,!0===e&&this.stop()}currentAction(){return this._interacting?this.prepared.name:null}interacting(){return this._interacting}stop(){this._scopeFire("interactions:stop",{interaction:this}),this.interactable=this.element=null,this._interacting=!1,this._stopped=!0,this.prepared.name=this.prevEvent=null}getPointerIndex(e){const i=s.getPointerId(e);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:t.findIndex(this.pointers,t=>t.id===i)}getPointerInfo(t){return this.pointers[this.getPointerIndex(t)]}updatePointer(t,e,i,o){const n=s.getPointerId(t);let r=this.getPointerIndex(t),h=this.pointers[r];return o=!1!==o&&(o||/(down|start)$/i.test(e.type)),h?h.pointer=t:(h=new p(n,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),o&&(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:o,pointerInfo:h,pointerIndex:r,interaction:this}),r}removePointer(t,e){const i=this.getPointerIndex(t);if(-1===i)return;const o=this.pointers[i];this._scopeFire("interactions:remove-pointer",{pointer:t,event:e,eventTarget:null,pointerIndex:i,pointerInfo:o,interaction:this}),this.pointers.splice(i,1),this.pointerIsDown=!1}_updateLatestPointer(t,e,i){this._latestPointer.pointer=t,this._latestPointer.event=e,this._latestPointer.eventTarget=i}destroy(){this._latestPointer.pointer=null,this._latestPointer.event=null,this._latestPointer.eventTarget=null}_createPreparedEvent(t,e,i,o){return new h(this,t,this.prepared.name,e,this.element,i,o)}_fireEvent(t){this.interactable.fire(t),(!this.prevEvent||t.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=t)}_doPhase(t){const{event:e,phase:i,preEnd:o,type:n}=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,o,n);return this._scopeFire("interactions:action-"+i,t),"start"===i&&(this.prevEvent=h),this._fireEvent(h),this._scopeFire("interactions:after-action-"+i,t),!0}_now(){return Date.now()}}export default Interaction;export{p as PointerInfo}; | ||
import*as t from"../utils/arr.prod.js";import e from"../utils/extend.prod.js";import i from"../utils/hypot.prod.js";import{warnOnce as o,copyAction as n}from"../utils/misc.prod.js";import*as s from"../utils/pointerUtils.prod.js";import*as r from"../utils/rect.prod.js";import{InteractEvent as h}from"./InteractEvent.prod.js";import{PointerInfo as p}from"./PointerInfo.prod.js";export let _ProxyValues;(t=>{t.interactable="",t.element="",t.prepared="",t.pointerIsDown="",t.pointerWasMoved="",t._proxy=""})(_ProxyValues||(_ProxyValues={}));export let _ProxyMethods;(t=>{t.start="",t.move="",t.end="",t.stop="",t.interacting=""})(_ProxyMethods||(_ProxyMethods={}));let a=0;export class Interaction{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=o((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(){return i[t]}});for(const t in _ProxyMethods)Object.defineProperty(this._proxy,t,{value:(...e)=>i[t](...e)});this._scopeFire("interactions:new",{interaction:this})}pointerDown(t,e,i){const o=this.updatePointer(t,e,i,!0),n=this.pointers[o];this._scopeFire("interactions:down",{pointer:t,event:e,eventTarget:i,pointerIndex:o,pointerInfo:n,type:"down",interaction:this})}start(t,i,o){return!(this.interacting()||!this.pointerIsDown||this.pointers.length<("gesture"===t.name?2:1)||!i.options[t.name].enabled)&&(n(this.prepared,t),this.interactable=i,this.element=o,this.rect=i.getRect(o),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,o){this.simulation||this.modification&&this.modification.endResult||this.updatePointer(t,e,o,!1);const n=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:o,dx:r,dy:h,duplicate:n,interaction:this};n||s.setCoordVelocity(this.coords.velocity,this.coords.delta),this._scopeFire("interactions:move",a),n||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,o){let n=this.getPointerIndex(t);-1===n&&(n=this.updatePointer(t,e,i,!1));const s=/cancel$/i.test(e.type)?"cancel":"up";this._scopeFire("interactions:"+s,{pointer:t,pointerIndex:n,pointerInfo:this.pointers[n],event:e,eventTarget:i,type:s,curEventTarget:o,interaction:this}),this.simulation||this.end(e),this.removePointer(t,e)}documentBlur(t){this.end(t),this._scopeFire("interactions:blur",{event:t,type:"blur",interaction:this})}end(t){let e;this._ending=!0,t=t||this._latestPointer.event,this.interacting()&&(e=this._doPhase({event:t,interaction:this,phase:"end"})),this._ending=!1,!0===e&&this.stop()}currentAction(){return this._interacting?this.prepared.name:null}interacting(){return this._interacting}stop(){this._scopeFire("interactions:stop",{interaction:this}),this.interactable=this.element=null,this._interacting=!1,this._stopped=!0,this.prepared.name=this.prevEvent=null}getPointerIndex(e){const i=s.getPointerId(e);return"mouse"===this.pointerType||"pen"===this.pointerType?this.pointers.length-1:t.findIndex(this.pointers,(t=>t.id===i))}getPointerInfo(t){return this.pointers[this.getPointerIndex(t)]}updatePointer(t,e,i,o){const n=s.getPointerId(t);let r=this.getPointerIndex(t),h=this.pointers[r];return o=!1!==o&&(o||/(down|start)$/i.test(e.type)),h?h.pointer=t:(h=new p(n,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),o&&(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:o,pointerInfo:h,pointerIndex:r,interaction:this}),r}removePointer(t,e){const i=this.getPointerIndex(t);if(-1===i)return;const o=this.pointers[i];this._scopeFire("interactions:remove-pointer",{pointer:t,event:e,eventTarget:null,pointerIndex:i,pointerInfo:o,interaction:this}),this.pointers.splice(i,1),this.pointerIsDown=!1}_updateLatestPointer(t,e,i){this._latestPointer.pointer=t,this._latestPointer.event=e,this._latestPointer.eventTarget=i}destroy(){this._latestPointer.pointer=null,this._latestPointer.event=null,this._latestPointer.eventTarget=null}_createPreparedEvent(t,e,i,o){return new h(this,t,this.prepared.name,e,this.element,i,o)}_fireEvent(t){this.interactable.fire(t),(!this.prevEvent||t.timeStamp>=this.prevEvent.timeStamp)&&(this.prevEvent=t)}_doPhase(t){const{event:e,phase:i,preEnd:o,type:n}=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,o,n);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.prod.js.map |
@@ -1,2 +0,2 @@ | ||
import*as e from"../utils/domUtils.prod.js";const t={methodOrder:["simulationResume","mouseOrPen","hasPointer","idle"],search(e){for(const n of t.methodOrder){const i=t[n](e);if(i)return i}return null},simulationResume({pointerType:t,eventType:n,eventTarget:i,scope:r}){if(!/down|start/i.test(n))return null;for(const n of r.interactions.list){let r=i;if(n.simulation&&n.simulation.allowResume&&n.pointerType===t)for(;r;){if(r===n.element)return n;r=e.parentNode(r)}}return null},mouseOrPen({pointerId:e,pointerType:t,eventType:i,scope:r}){if("mouse"!==t&&"pen"!==t)return null;let o;for(const i of r.interactions.list)if(i.pointerType===t){if(i.simulation&&!n(i,e))continue;if(i.interacting())return i;o||(o=i)}if(o)return o;for(const e of r.interactions.list)if(!(e.pointerType!==t||/down/i.test(i)&&e.simulation))return e;return null},hasPointer({pointerId:e,scope:t}){for(const i of t.interactions.list)if(n(i,e))return i;return null},idle({pointerType:e,scope:t}){for(const n of t.interactions.list){if(1===n.pointers.length){const e=n.interactable;if(e&&(!e.options.gesture||!e.options.gesture.enabled))continue}else if(n.pointers.length>=2)continue;if(!n.interacting()&&e===n.pointerType)return n}return null}};function n(e,t){return e.pointers.some(({id:e})=>e===t)}export default t; | ||
import*as e from"../utils/domUtils.prod.js";const t={methodOrder:["simulationResume","mouseOrPen","hasPointer","idle"],search(e){for(const n of t.methodOrder){const i=t[n](e);if(i)return i}return null},simulationResume({pointerType:t,eventType:n,eventTarget:i,scope:r}){if(!/down|start/i.test(n))return null;for(const n of r.interactions.list){let r=i;if(n.simulation&&n.simulation.allowResume&&n.pointerType===t)for(;r;){if(r===n.element)return n;r=e.parentNode(r)}}return null},mouseOrPen({pointerId:e,pointerType:t,eventType:i,scope:r}){if("mouse"!==t&&"pen"!==t)return null;let o;for(const i of r.interactions.list)if(i.pointerType===t){if(i.simulation&&!n(i,e))continue;if(i.interacting())return i;o||(o=i)}if(o)return o;for(const e of r.interactions.list)if(!(e.pointerType!==t||/down/i.test(i)&&e.simulation))return e;return null},hasPointer({pointerId:e,scope:t}){for(const i of t.interactions.list)if(n(i,e))return i;return null},idle({pointerType:e,scope:t}){for(const n of t.interactions.list){if(1===n.pointers.length){const e=n.interactable;if(e&&(!e.options.gesture||!e.options.gesture.enabled))continue}else if(n.pointers.length>=2)continue;if(!n.interacting()&&e===n.pointerType)return n}return null}};function n(e,t){return e.pointers.some((({id:e})=>e===t))}export default t; | ||
//# sourceMappingURL=interactionFinder.prod.js.map |
@@ -0,1 +1,2 @@ | ||
import { Scope, SignalArgs } from "./scope.js"; | ||
import browser from "../utils/browser.js"; | ||
@@ -2,0 +3,0 @@ import domObjects from "../utils/domObjects.js"; |
@@ -1,2 +0,2 @@ | ||
import e from"../utils/browser.prod.js";import t from"../utils/domObjects.prod.js";import{nodeContains as n}from"../utils/domUtils.prod.js";import*as o from"../utils/pointerUtils.prod.js";import r from"./Interaction.prod.js";import i from"./interactablePreventDefault.prod.js";import s from"./interactionFinder.prod.js";const p=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function c(t,n){return r=>{const i=n.interactions.list,s=o.getPointerType(r),[p,c]=o.getEventTargets(r),l=[];if(/^touch/.test(r.type)){n.prevTouchTime=n.now();for(const e of r.changedTouches){const t=e,i={pointer:t,pointerId:o.getPointerId(t),pointerType:s,eventType:r.type,eventTarget:p,curEventTarget:c,scope:n},u=a(i);l.push([i.pointer,i.eventTarget,i.curEventTarget,u])}}else{let t=!1;if(!e.supportsPointerEvent&&/mouse/.test(r.type)){for(let e=0;e<i.length&&!t;e++)t="mouse"!==i[e].pointerType&&i[e].pointerIsDown;t=t||n.now()-n.prevTouchTime<500||0===r.timeStamp}if(!t){const e={pointer:r,pointerId:o.getPointerId(r),pointerType:s,eventType:r.type,curEventTarget:c,eventTarget:p,scope:n},t=a(e);l.push([e.pointer,e.eventTarget,e.curEventTarget,t])}}for(const[e,n,o,i]of l)i[t](e,r,n,o)}}function a(e){const{pointerType:t,scope:n}=e,o={interaction:s.search(e),searchDetails:e};return n.fire("interactions:find",o),o.interaction||n.interactions.new({pointerType:t})}function l({doc:e,scope:t,options:n},o){const{interactions:{docEvents:r},events:i}=t,s=i[o];t.browser.isIOS&&!n.events&&(n.events={passive:!1});for(const t in i.delegatedEvents)s(e,t,i.delegateListener),s(e,t,i.delegateUseCapture,!0);const p=n&&n.events;for(const{type:t,listener:n}of r)s(e,t,n,p)}const u={id:"core/interactions",install(o){const s={};for(const e of p)s[e]=c(e,o);const a=e.pEventTypes;let l;function u(){for(const e of o.interactions.list)if(e.pointerIsDown&&"touch"===e.pointerType&&!e._interacting)for(const t of e.pointers)o.documents.some(({doc:e})=>n(e,t.downTarget))||e.removePointer(t.pointer,t.event)}l=t.PointerEvent?[{type:a.down,listener:u},{type:a.down,listener:s.pointerDown},{type:a.move,listener:s.pointerMove},{type:a.up,listener:s.pointerUp},{type:a.cancel,listener:s.pointerUp}]:[{type:"mousedown",listener:s.pointerDown},{type:"mousemove",listener:s.pointerMove},{type:"mouseup",listener:s.pointerUp},{type:"touchstart",listener:u},{type:"touchstart",listener:s.pointerDown},{type:"touchmove",listener:s.pointerMove},{type:"touchend",listener:s.pointerUp},{type:"touchcancel",listener:s.pointerUp}],l.push({type:"blur",listener(e){for(const t of o.interactions.list)t.documentBlur(e)}}),o.prevTouchTime=0,o.Interaction=class extends r{get pointerMoveTolerance(){return o.interactions.pointerMoveTolerance}set pointerMoveTolerance(e){o.interactions.pointerMoveTolerance=e}_now(){return o.now()}},o.interactions={list:[],new(e){e.scopeFire=(e,t)=>o.fire(e,t);const t=new o.Interaction(e);return o.interactions.list.push(t),t},listeners:s,docEvents:l,pointerMoveTolerance:1},o.usePlugin(i)},listeners:{"scope:add-document":e=>l(e,"add"),"scope:remove-document":e=>l(e,"remove"),"interactable:unset"({interactable:e},t){for(let n=t.interactions.list.length-1;n>=0;n--){const o=t.interactions.list[n];o.interactable===e&&(o.stop(),t.fire("interactions:destroy",{interaction:o}),o.destroy(),t.interactions.list.length>2&&t.interactions.list.splice(n,1))}}},onDocSignal:l,doOnInteractions:c,methodNames:p};export default u; | ||
import{Scope as e,SignalArgs as t}from"./scope.prod.js";import o from"../utils/browser.prod.js";import n from"../utils/domObjects.prod.js";import{nodeContains as r}from"../utils/domUtils.prod.js";import*as i from"../utils/pointerUtils.prod.js";import s from"./Interaction.prod.js";import p from"./interactablePreventDefault.prod.js";import c from"./interactionFinder.prod.js";const a=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function l(e,t){return n=>{const r=t.interactions.list,s=i.getPointerType(n),[p,c]=i.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:i.getPointerId(o),pointerType:s,eventType:n.type,eventTarget:p,curEventTarget:c,scope:t},l=u(r);a.push([r.pointer,r.eventTarget,r.curEventTarget,l])}}else{let e=!1;if(!o.supportsPointerEvent&&/mouse/.test(n.type)){for(let t=0;t<r.length&&!e;t++)e="mouse"!==r[t].pointerType&&r[t].pointerIsDown;e=e||t.now()-t.prevTouchTime<500||0===n.timeStamp}if(!e){const e={pointer:n,pointerId:i.getPointerId(n),pointerType:s,eventType:n.type,curEventTarget:c,eventTarget:p,scope:t},o=u(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 u(e){const{pointerType:t,scope:o}=e,n={interaction:c.search(e),searchDetails:e};return o.fire("interactions:find",n),n.interaction||o.interactions.new({pointerType:t})}function d({doc:e,scope:t,options:o},n){const{interactions:{docEvents:r},events:i}=t,s=i[n];t.browser.isIOS&&!o.events&&(o.events={passive:!1});for(const t in i.delegatedEvents)s(e,t,i.delegateListener),s(e,t,i.delegateUseCapture,!0);const p=o&&o.events;for(const{type:t,listener:o}of r)s(e,t,o,p)}const v={id:"core/interactions",install(e){const t={};for(const o of a)t[o]=l(o,e);const i=o.pEventTypes;let c;function u(){for(const t of e.interactions.list)if(t.pointerIsDown&&"touch"===t.pointerType&&!t._interacting)for(const o of t.pointers)e.documents.some((({doc:e})=>r(e,o.downTarget)))||t.removePointer(o.pointer,o.event)}c=n.PointerEvent?[{type:i.down,listener:u},{type:i.down,listener:t.pointerDown},{type:i.move,listener:t.pointerMove},{type:i.up,listener:t.pointerUp},{type:i.cancel,listener:t.pointerUp}]:[{type:"mousedown",listener:t.pointerDown},{type:"mousemove",listener:t.pointerMove},{type:"mouseup",listener:t.pointerUp},{type:"touchstart",listener:u},{type:"touchstart",listener:t.pointerDown},{type:"touchmove",listener:t.pointerMove},{type:"touchend",listener:t.pointerUp},{type:"touchcancel",listener:t.pointerUp}],c.push({type:"blur",listener(t){for(const o of e.interactions.list)o.documentBlur(t)}}),e.prevTouchTime=0,e.Interaction=class extends s{get pointerMoveTolerance(){return e.interactions.pointerMoveTolerance}set pointerMoveTolerance(t){e.interactions.pointerMoveTolerance=t}_now(){return e.now()}},e.interactions={list:[],new(t){t.scopeFire=(t,o)=>e.fire(t,o);const o=new e.Interaction(t);return e.interactions.list.push(o),o},listeners:t,docEvents:c,pointerMoveTolerance:1},e.usePlugin(p)},listeners:{"scope:add-document":e=>d(e,"add"),"scope:remove-document":e=>d(e,"remove"),"interactable:unset"({interactable:e},t){for(let o=t.interactions.list.length-1;o>=0;o--){const n=t.interactions.list[o];n.interactable===e&&(n.stop(),t.fire("interactions:destroy",{interaction:n}),n.destroy(),t.interactions.list.length>2&&t.interactions.list.splice(o,1))}}},onDocSignal:d,doOnInteractions:l,methodNames:a};export default v; | ||
//# sourceMappingURL=interactions.prod.js.map |
@@ -6,2 +6,3 @@ /** @module interact */ | ||
import * as pointerUtils from "../utils/pointerUtils.js"; | ||
import { warnOnce } from "../utils/misc.js"; | ||
import isNonNativeEvent from "./isNonNativeEvent.js"; | ||
@@ -56,3 +57,3 @@ export function createInteractStatic(scope) { | ||
interact.version = "1.10.1"; | ||
interact.version = "1.10.2"; | ||
interact.scope = scope; | ||
@@ -64,5 +65,2 @@ /** | ||
* | ||
* @param {Object} plugin | ||
* @param {function} plugin.install | ||
* @return {Interact.InteractStatic} | ||
*/ | ||
@@ -80,3 +78,4 @@ | ||
* | ||
* @param {Element} element The Element being searched for | ||
* @param {Target} target The Element or string being searched for | ||
* @param {object} options | ||
* @return {boolean} Indicates if the element or CSS selector was previously | ||
@@ -91,2 +90,3 @@ * passed to interact | ||
/** | ||
* @deprecated | ||
* Add a global listener for an InteractEvent or adds a DOM event to `document` | ||
@@ -104,3 +104,3 @@ * | ||
interact.on = function (type, listener, options) { | ||
interact.on = warnOnce(function on(type, listener, options) { | ||
if (is.string(type) && type.search(' ') !== -1) { | ||
@@ -142,4 +142,5 @@ type = type.trim().split(/ +/); | ||
return this; | ||
}; | ||
}, 'The interact.on() method is being deprecated'); | ||
/** | ||
* @deprecated | ||
* Removes a global InteractEvent listener or DOM event from `document` | ||
@@ -157,4 +158,3 @@ * | ||
interact.off = function (type, listener, options) { | ||
interact.off = warnOnce(function off(type, listener, options) { | ||
if (is.string(type) && type.search(' ') !== -1) { | ||
@@ -191,3 +191,3 @@ type = type.trim().split(/ +/); | ||
return this; | ||
}; | ||
}, 'The interact.off() method is being deprecated'); | ||
@@ -194,0 +194,0 @@ interact.debug = function () { |
@@ -1,2 +0,2 @@ | ||
import t from"../utils/browser.prod.js";import*as e from"../utils/domUtils.prod.js";import o from"../utils/is.prod.js";import*as s from"../utils/pointerUtils.prod.js";import n from"./isNonNativeEvent.prod.js";export function createInteractStatic(i){const r=(t,e)=>{let o=i.interactables.get(t,e);return o||(o=i.interactables.new(t,e),o.events.global=r.globalEvents),o};return r.getPointerAverage=s.pointerAverage,r.getTouchBBox=s.touchBBox,r.getTouchDistance=s.touchDistance,r.getTouchAngle=s.touchAngle,r.getElementRect=e.getElementRect,r.getElementClientRect=e.getElementClientRect,r.matchesSelector=e.matchesSelector,r.closest=e.closest,r.globalEvents={},r.version="1.10.1",r.scope=i,r.use=function(t,e){return this.scope.usePlugin(t,e),this},r.isSet=function(t,e){return!!this.scope.interactables.get(t,e&&e.context)},r.on=function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.on(o,e,s);return this}if(o.object(t)){for(const o in t)this.on(o,t[o],e);return this}return n(t,this.scope.actions)?this.globalEvents[t]?this.globalEvents[t].push(e):this.globalEvents[t]=[e]:this.scope.events.add(this.scope.document,t,e,{options:s}),this},r.off=function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.off(o,e,s);return this}if(o.object(t)){for(const o in t)this.off(o,t[o],e);return this}if(n(t,this.scope.actions)){let o;t in this.globalEvents&&-1!==(o=this.globalEvents[t].indexOf(e))&&this.globalEvents[t].splice(o,1)}else this.scope.events.remove(this.scope.document,t,e,s);return this},r.debug=function(){return this.scope},r.supportsTouch=()=>t.supportsTouch,r.supportsPointerEvent=()=>t.supportsPointerEvent,r.stop=function(){for(const t of this.scope.interactions.list)t.stop();return this},r.pointerMoveTolerance=function(t){return o.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance},r.addDocument=function(t,e){this.scope.addDocument(t,e)},r.removeDocument=function(t){this.scope.removeDocument(t)},r} | ||
import t from"../utils/browser.prod.js";import*as e from"../utils/domUtils.prod.js";import o from"../utils/is.prod.js";import*as s from"../utils/pointerUtils.prod.js";import{warnOnce as n}from"../utils/misc.prod.js";import i from"./isNonNativeEvent.prod.js";export function createInteractStatic(r){const c=(t,e)=>{let o=r.interactables.get(t,e);return o||(o=r.interactables.new(t,e),o.events.global=c.globalEvents),o};return c.getPointerAverage=s.pointerAverage,c.getTouchBBox=s.touchBBox,c.getTouchDistance=s.touchDistance,c.getTouchAngle=s.touchAngle,c.getElementRect=e.getElementRect,c.getElementClientRect=e.getElementClientRect,c.matchesSelector=e.matchesSelector,c.closest=e.closest,c.globalEvents={},c.version="1.10.2",c.scope=r,c.use=function(t,e){return this.scope.usePlugin(t,e),this},c.isSet=function(t,e){return!!this.scope.interactables.get(t,e&&e.context)},c.on=n((function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.on(o,e,s);return this}if(o.object(t)){for(const o in t)this.on(o,t[o],e);return this}return i(t,this.scope.actions)?this.globalEvents[t]?this.globalEvents[t].push(e):this.globalEvents[t]=[e]:this.scope.events.add(this.scope.document,t,e,{options:s}),this}),"The interact.on() method is being deprecated"),c.off=n((function(t,e,s){if(o.string(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),o.array(t)){for(const o of t)this.off(o,e,s);return this}if(o.object(t)){for(const o in t)this.off(o,t[o],e);return this}if(i(t,this.scope.actions)){let o;t in this.globalEvents&&-1!==(o=this.globalEvents[t].indexOf(e))&&this.globalEvents[t].splice(o,1)}else this.scope.events.remove(this.scope.document,t,e,s);return this}),"The interact.off() method is being deprecated"),c.debug=function(){return this.scope},c.supportsTouch=()=>t.supportsTouch,c.supportsPointerEvent=()=>t.supportsPointerEvent,c.stop=function(){for(const t of this.scope.interactions.list)t.stop();return this},c.pointerMoveTolerance=function(t){return o.number(t)?(this.scope.interactions.pointerMoveTolerance=t,this):this.scope.interactions.pointerMoveTolerance},c.addDocument=function(t,e){this.scope.addDocument(t,e)},c.removeDocument=function(t){this.scope.removeDocument(t)},c} | ||
//# sourceMappingURL=interactStatic.prod.js.map |
{ | ||
"name": "@interactjs/core", | ||
"version": "1.10.1", | ||
"version": "1.10.2", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/utils": "1.10.1" | ||
"@interactjs/utils": "1.10.2" | ||
}, | ||
@@ -8,0 +8,0 @@ "publishConfig": { |
@@ -1,2 +0,2 @@ | ||
import t from"../utils/browser.prod.js";import i from"../utils/clone.prod.js";import s from"../utils/domObjects.prod.js";import e from"../utils/extend.prod.js";import n from"../utils/raf.prod.js";import*as o from"../utils/window.prod.js";import{Eventable as r}from"./Eventable.prod.js";import{InteractEvent as d}from"./InteractEvent.prod.js";import{Interactable as a}from"./Interactable.prod.js";import{InteractableSet as l}from"./InteractableSet.prod.js";import{defaults as p}from"./defaultOptions.prod.js";import h from"./events.prod.js";import{createInteractStatic as c}from"./interactStatic.prod.js";import u from"./interactions.prod.js";export class Scope{constructor(){this.id="__interact_scope_"+Math.floor(100*Math.random()),this.isInitialized=!1,this.listenerMaps=[],this.browser=t,this.defaults=i(p),this.Eventable=r,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=c(this),this.InteractEvent=d,this.Interactable=void 0,this.interactables=new l(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 a{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[m(i)]=!0,t),{});for(;i<s;i++){const t=this.listenerMaps[i].id;if(e[t]||e[m(t)])break}this.listenerMaps.splice(i,0,{id:t.id,map:t.listeners})}else t.listeners&&this.listenerMaps.push({id:t.id,map:t.listeners});return this}addDocument(t,i){if(-1!==this.getDocIndex(t))return!1;const s=o.getWindow(t);i=i?e({},i):{},this.documents.push({doc:t,options:i}),this.events.documents.push(t),t!==this.document&&this.events.add(s,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:s,scope:this,options:i})}removeDocument(t){const i=this.getDocIndex(t),s=o.getWindow(t),e=this.documents[i].options;this.events.remove(s,"unload",this.onWindowUnload),this.documents.splice(i,1),this.events.documents.splice(i,1),this.fire("scope:remove-document",{doc:t,window:s,scope:this,options:e})}getDocIndex(t){for(let i=0;i<this.documents.length;i++)if(this.documents[i].doc===t)return i;return-1}getDocOptions(t){const i=this.getDocIndex(t);return-1===i?null:this.documents[i].options}now(){return(this.window.Date||Date).now()}}export function initScope(i,e){return i.isInitialized=!0,o.init(e),s.init(e),t.init(e),n.init(e),i.window=e,i.document=e.document,i.usePlugin(u),i.usePlugin(h),i}function m(t){return t&&t.replace(/\/.*$/,"")} | ||
import t from"../utils/browser.prod.js";import i from"../utils/clone.prod.js";import s from"../utils/domObjects.prod.js";import e from"../utils/extend.prod.js";import n from"../utils/raf.prod.js";import*as o from"../utils/window.prod.js";import{Eventable as r}from"./Eventable.prod.js";import{InteractEvent as d}from"./InteractEvent.prod.js";import{Interactable as a}from"./Interactable.prod.js";import{InteractableSet as l}from"./InteractableSet.prod.js";import{defaults as p}from"./defaultOptions.prod.js";import h from"./events.prod.js";import{createInteractStatic as c}from"./interactStatic.prod.js";import u from"./interactions.prod.js";export class Scope{constructor(){this.id="__interact_scope_"+Math.floor(100*Math.random()),this.isInitialized=!1,this.listenerMaps=[],this.browser=t,this.defaults=i(p),this.Eventable=r,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=c(this),this.InteractEvent=d,this.Interactable=void 0,this.interactables=new l(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 a{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[m(i)]=!0,t)),{});for(;i<s;i++){const t=this.listenerMaps[i].id;if(e[t]||e[m(t)])break}this.listenerMaps.splice(i,0,{id:t.id,map:t.listeners})}else t.listeners&&this.listenerMaps.push({id:t.id,map:t.listeners});return this}addDocument(t,i){if(-1!==this.getDocIndex(t))return!1;const s=o.getWindow(t);i=i?e({},i):{},this.documents.push({doc:t,options:i}),this.events.documents.push(t),t!==this.document&&this.events.add(s,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:s,scope:this,options:i})}removeDocument(t){const i=this.getDocIndex(t),s=o.getWindow(t),e=this.documents[i].options;this.events.remove(s,"unload",this.onWindowUnload),this.documents.splice(i,1),this.events.documents.splice(i,1),this.fire("scope:remove-document",{doc:t,window:s,scope:this,options:e})}getDocIndex(t){for(let i=0;i<this.documents.length;i++)if(this.documents[i].doc===t)return i;return-1}getDocOptions(t){const i=this.getDocIndex(t);return-1===i?null:this.documents[i].options}now(){return(this.window.Date||Date).now()}}export function initScope(i,e){return i.isInitialized=!0,o.init(e),s.init(e),t.init(e),n.init(e),i.window=e,i.document=e.document,i.usePlugin(u),i.usePlugin(h),i}function m(t){return t&&t.replace(/\/.*$/,"")} | ||
//# sourceMappingURL=scope.prod.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
412985
2397