@interactjs/pointer-events
Advanced tools
Comparing version 1.10.2 to 1.10.3
14
base.js
@@ -1,3 +0,1 @@ | ||
import { Interaction } from "../core/Interaction.js"; | ||
import { Scope, SignalArgs } from "../core/scope.js"; | ||
import * as domUtils from "../utils/domUtils.js"; | ||
@@ -80,2 +78,3 @@ import extend from "../utils/extend.js"; | ||
for (const prop in target.props || {}) { | ||
; | ||
pointerEvent[prop] = target.props[prop]; | ||
@@ -151,3 +150,7 @@ } | ||
if (type === 'hold') { | ||
signalArg.targets = signalArg.targets.filter(target => target.eventable.options.holdDuration === interaction.pointers[pointerIndex].hold.duration); | ||
signalArg.targets = signalArg.targets.filter(target => { | ||
var _interaction$pointers; | ||
return target.eventable.options.holdDuration === ((_interaction$pointers = interaction.pointers[pointerIndex]) == null ? void 0 : _interaction$pointers.hold.duration); | ||
}); | ||
} | ||
@@ -241,6 +244,3 @@ | ||
if (!signalArg.targets.length) { | ||
return; | ||
} | ||
if (!signalArg.targets.length) return; | ||
let minDuration = Infinity; | ||
@@ -247,0 +247,0 @@ |
@@ -1,2 +0,2 @@ | ||
import{Interaction as t}from"../core/Interaction.prod.js";import{Scope as e,SignalArgs as n}from"../core/scope.prod.js";import*as o from"../utils/domUtils.prod.js";import r from"../utils/extend.prod.js";import i from"../utils/getOriginXY.prod.js";import{PointerEvent as a}from"./PointerEvent.prod.js";const p={id:"pointer-events/base",before:["inertia","modifiers","auto-start","actions"],install(t){t.pointerEvents=p,t.defaults.actions.pointerEvents=p.defaults,r(t.actions.phaselessTypes,p.types)},listeners:{"interactions:new"({interaction:t}){t.prevTap=null,t.tapTime=0},"interactions:update-pointer"({down:t,pointerInfo:e}){!t&&e.hold||(e.hold={duration:1/0,timeout:null})},"interactions:move"(t,e){const{interaction:n,pointer:o,event:r,eventTarget:i,duplicate:a}=t;a||n.pointerIsDown&&!n.pointerWasMoved||(n.pointerIsDown&&c(t),s({interaction:n,pointer:o,event:r,eventTarget:i,type:"move"},e))},"interactions:down"(t,e){(({interaction:t,pointer:e,event:n,eventTarget:r,pointerIndex:i},a)=>{const p=t.pointers[i].hold,l=o.getPath(r),c={interaction:t,pointer:e,event:n,eventTarget:r,type:"hold",targets:[],path:l,node:null};for(const t of l)c.node=t,a.fire("pointerEvents:collect-targets",c);if(!c.targets.length)return;let d=1/0;for(const t of c.targets){const e=t.eventable.options.holdDuration;e<d&&(d=e)}p.duration=d,p.timeout=setTimeout((()=>{s({interaction:t,eventTarget:r,pointer:e,event:n,type:"hold"},a)}),d)})(t,e),s(t,e)},"interactions:up"(t,e){c(t),s(t,e),(({interaction:t,pointer:e,event:n,eventTarget:o},r)=>{t.pointerWasMoved||s({interaction:t,eventTarget:o,pointer:e,event:n,type:"tap"},r)})(t,e)},"interactions:cancel"(t,e){c(t),s(t,e)}},PointerEvent:a,fire:s,collectEventTargets:l,defaults:{holdDuration:600,ignoreFrom:null,allowFrom:null,origin:{x:0,y:0}},types:{down:!0,move:!0,up:!0,cancel:!0,tap:!0,doubletap:!0,hold:!0}};function s(t,e){const{interaction:n,pointer:o,event:r,eventTarget:p,type:c,targets:d=l(t,e)}=t,v=new a(c,o,r,p,n,e.now());e.fire("pointerEvents:new",{pointerEvent:v});const u={interaction:n,pointer:o,event:r,eventTarget:p,targets:d,type:c,pointerEvent:v};for(let t=0;t<d.length;t++){const e=d[t];for(const t in e.props||{})v[t]=e.props[t];const n=i(e.eventable,e.node);if(v._subtractOrigin(n),v.eventable=e.eventable,v.currentTarget=e.node,e.eventable.fire(v),v._addOrigin(n),v.immediatePropagationStopped||v.propagationStopped&&t+1<d.length&&d[t+1].node!==v.currentTarget)break}if(e.fire("pointerEvents:fired",u),"tap"===c){const t=v.double?s({interaction:n,pointer:o,event:r,eventTarget:p,type:"doubletap"},e):v;n.prevTap=t,n.tapTime=t.timeStamp}return v}function l({interaction:t,pointer:e,event:n,eventTarget:r,type:i},a){const p=t.getPointerIndex(e),s=t.pointers[p];if("tap"===i&&(t.pointerWasMoved||!s||s.downTarget!==r))return[];const l=o.getPath(r),c={interaction:t,pointer:e,event:n,eventTarget:r,type:i,path:l,targets:[],node:null};for(const t of l)c.node=t,a.fire("pointerEvents:collect-targets",c);return"hold"===i&&(c.targets=c.targets.filter((e=>e.eventable.options.holdDuration===t.pointers[p].hold.duration))),c.targets}function c({interaction:t,pointerIndex:e}){const n=t.pointers[e].hold;n&&n.timeout&&(clearTimeout(n.timeout),n.timeout=null)}export default p; | ||
import*as t from"../utils/domUtils.prod.js";import e from"../utils/extend.prod.js";import n from"../utils/getOriginXY.prod.js";import{PointerEvent as o}from"./PointerEvent.prod.js";const r={id:"pointer-events/base",before:["inertia","modifiers","auto-start","actions"],install(t){t.pointerEvents=r,t.defaults.actions.pointerEvents=r.defaults,e(t.actions.phaselessTypes,r.types)},listeners:{"interactions:new"({interaction:t}){t.prevTap=null,t.tapTime=0},"interactions:update-pointer"({down:t,pointerInfo:e}){!t&&e.hold||(e.hold={duration:1/0,timeout:null})},"interactions:move"(t,e){const{interaction:n,pointer:o,event:r,eventTarget:a,duplicate:s}=t;s||n.pointerIsDown&&!n.pointerWasMoved||(n.pointerIsDown&&p(t),i({interaction:n,pointer:o,event:r,eventTarget:a,type:"move"},e))},"interactions:down"(e,n){(({interaction:e,pointer:n,event:o,eventTarget:r,pointerIndex:a},p)=>{const s=e.pointers[a].hold,l=t.getPath(r),c={interaction:e,pointer:n,event:o,eventTarget:r,type:"hold",targets:[],path:l,node:null};for(const t of l)c.node=t,p.fire("pointerEvents:collect-targets",c);if(!c.targets.length)return;let d=1/0;for(const t of c.targets){const e=t.eventable.options.holdDuration;e<d&&(d=e)}s.duration=d,s.timeout=setTimeout((()=>{i({interaction:e,eventTarget:r,pointer:n,event:o,type:"hold"},p)}),d)})(e,n),i(e,n)},"interactions:up"(t,e){p(t),i(t,e),(({interaction:t,pointer:e,event:n,eventTarget:o},r)=>{t.pointerWasMoved||i({interaction:t,eventTarget:o,pointer:e,event:n,type:"tap"},r)})(t,e)},"interactions:cancel"(t,e){p(t),i(t,e)}},PointerEvent:o,fire:i,collectEventTargets:a,defaults:{holdDuration:600,ignoreFrom:null,allowFrom:null,origin:{x:0,y:0}},types:{down:!0,move:!0,up:!0,cancel:!0,tap:!0,doubletap:!0,hold:!0}};function i(t,e){const{interaction:r,pointer:p,event:s,eventTarget:l,type:c,targets:d=a(t,e)}=t,v=new o(c,p,s,l,r,e.now());e.fire("pointerEvents:new",{pointerEvent:v});const u={interaction:r,pointer:p,event:s,eventTarget:l,targets:d,type:c,pointerEvent:v};for(let t=0;t<d.length;t++){const e=d[t];for(const t in e.props||{})v[t]=e.props[t];const o=n(e.eventable,e.node);if(v._subtractOrigin(o),v.eventable=e.eventable,v.currentTarget=e.node,e.eventable.fire(v),v._addOrigin(o),v.immediatePropagationStopped||v.propagationStopped&&t+1<d.length&&d[t+1].node!==v.currentTarget)break}if(e.fire("pointerEvents:fired",u),"tap"===c){const t=v.double?i({interaction:r,pointer:p,event:s,eventTarget:l,type:"doubletap"},e):v;r.prevTap=t,r.tapTime=t.timeStamp}return v}function a({interaction:e,pointer:n,event:o,eventTarget:r,type:i},a){const p=e.getPointerIndex(n),s=e.pointers[p];if("tap"===i&&(e.pointerWasMoved||!s||s.downTarget!==r))return[];const l=t.getPath(r),c={interaction:e,pointer:n,event:o,eventTarget:r,type:i,path:l,targets:[],node:null};for(const t of l)c.node=t,a.fire("pointerEvents:collect-targets",c);return"hold"===i&&(c.targets=c.targets.filter((t=>{var n;return t.eventable.options.holdDuration===(null==(n=e.pointers[p])?void 0:n.hold.duration)}))),c.targets}function p({interaction:t,pointerIndex:e}){const n=t.pointers[e].hold;n&&n.timeout&&(clearTimeout(n.timeout),n.timeout=null)}export default r; | ||
//# sourceMappingURL=base.prod.js.map |
@@ -1,3 +0,1 @@ | ||
import Interaction from "../core/Interaction.js"; | ||
import PointerEvent from "./PointerEvent.js"; | ||
import basePlugin from "./base.js"; | ||
@@ -18,6 +16,3 @@ | ||
}) { | ||
if (pointerEvent.type !== 'hold') { | ||
return; | ||
} | ||
if (pointerEvent.type !== 'hold') return; | ||
pointerEvent.count = (pointerEvent.count || 0) + 1; | ||
@@ -32,14 +27,8 @@ } | ||
}, scope) { | ||
if (pointerEvent.type !== 'hold' || !targets.length) { | ||
return; | ||
} // get the repeat interval from the first eventable | ||
if (pointerEvent.type !== 'hold' || !targets.length) return; // get the repeat interval from the first eventable | ||
const interval = targets[0].eventable.options.holdRepeatInterval; // don't repeat if the interval is 0 or less | ||
if (interval <= 0) { | ||
return; | ||
} // set a timeout to fire the holdrepeat event | ||
if (interval <= 0) return; // set a timeout to fire the holdrepeat event | ||
interaction.holdIntervalHandle = setTimeout(() => { | ||
@@ -71,2 +60,3 @@ scope.pointerEvents.fire({ | ||
listeners: ['move', 'up', 'cancel', 'endall'].reduce((acc, enderTypes) => { | ||
; | ||
acc[`pointerEvents:${enderTypes}`] = endHoldRepeat; | ||
@@ -73,0 +63,0 @@ return acc; |
@@ -1,2 +0,2 @@ | ||
import e from"../core/Interaction.prod.js";import t from"./PointerEvent.prod.js";import n from"./base.prod.js";function o({interaction:e}){e.holdIntervalHandle&&(clearInterval(e.holdIntervalHandle),e.holdIntervalHandle=null)}const r={id:"pointer-events/holdRepeat",install(e){e.usePlugin(n);const{pointerEvents:t}=e;t.defaults.holdRepeatInterval=0,t.types.holdrepeat=e.actions.phaselessTypes.holdrepeat=!0},listeners:["move","up","cancel","endall"].reduce(((e,t)=>(e["pointerEvents:"+t]=o,e)),{"pointerEvents:new"({pointerEvent:e}){"hold"===e.type&&(e.count=(e.count||0)+1)},"pointerEvents:fired"({interaction:e,pointerEvent:t,eventTarget:n,targets:o},r){if("hold"!==t.type||!o.length)return;const l=o[0].eventable.options.holdRepeatInterval;l<=0||(e.holdIntervalHandle=setTimeout((()=>{r.pointerEvents.fire({interaction:e,eventTarget:n,type:"hold",pointer:t,event:t},r)}),l))}})};export default r; | ||
import e from"./base.prod.js";function t({interaction:e}){e.holdIntervalHandle&&(clearInterval(e.holdIntervalHandle),e.holdIntervalHandle=null)}const n={id:"pointer-events/holdRepeat",install(t){t.usePlugin(e);const{pointerEvents:n}=t;n.defaults.holdRepeatInterval=0,n.types.holdrepeat=t.actions.phaselessTypes.holdrepeat=!0},listeners:["move","up","cancel","endall"].reduce(((e,n)=>(e["pointerEvents:"+n]=t,e)),{"pointerEvents:new"({pointerEvent:e}){"hold"===e.type&&(e.count=(e.count||0)+1)},"pointerEvents:fired"({interaction:e,pointerEvent:t,eventTarget:n,targets:o},l){if("hold"!==t.type||!o.length)return;const r=o[0].eventable.options.holdRepeatInterval;r<=0||(e.holdIntervalHandle=setTimeout((()=>{l.pointerEvents.fire({interaction:e,eventTarget:n,type:"hold",pointer:t,event:t},l)}),r))}})};export default n; | ||
//# sourceMappingURL=holdRepeat.prod.js.map |
@@ -1,2 +0,1 @@ | ||
import { Interactable } from "../core/Interactable.js"; | ||
import extend from "../utils/extend.js"; | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,2 @@ | ||
import{Interactable as t}from"../core/Interactable.prod.js";import e from"../utils/extend.prod.js";function n(t){return e(this.events.options,t),this}const o={id:"pointer-events/interactableTargets",install(t){const{Interactable:e}=t;e.prototype.pointerEvents=n;const o=e.prototype._backCompatOption;e.prototype._backCompatOption=function(t,e){const n=o.call(this,t,e);return n===this&&(this.events.options[t]=e),n}},listeners:{"pointerEvents:collect-targets"({targets:t,node:e,type:n,eventTarget:o},s){s.interactables.forEachMatch(e,(s=>{const r=s.events,a=r.options;r.types[n]&&r.types[n].length&&s.testIgnoreAllow(a,e,o)&&t.push({node:e,eventable:r,props:{interactable:s}})}))},"interactable:new"({interactable:t}){t.events.getRect=e=>t.getRect(e)},"interactable:set"({interactable:t,options:n},o){e(t.events.options,o.pointerEvents.defaults),e(t.events.options,n.pointerEvents||{})}}};export default o; | ||
import t from"../utils/extend.prod.js";function e(e){return t(this.events.options,e),this}const n={id:"pointer-events/interactableTargets",install(t){const{Interactable:n}=t;n.prototype.pointerEvents=e;const o=n.prototype._backCompatOption;n.prototype._backCompatOption=function(t,e){const n=o.call(this,t,e);return n===this&&(this.events.options[t]=e),n}},listeners:{"pointerEvents:collect-targets"({targets:t,node:e,type:n,eventTarget:o},s){s.interactables.forEachMatch(e,(s=>{const i=s.events,r=i.options;i.types[n]&&i.types[n].length&&s.testIgnoreAllow(r,e,o)&&t.push({node:e,eventable:i,props:{interactable:s}})}))},"interactable:new"({interactable:t}){t.events.getRect=e=>t.getRect(e)},"interactable:set"({interactable:e,options:n},o){t(e.events.options,o.pointerEvents.defaults),t(e.events.options,n.pointerEvents||{})}}};export default n; | ||
//# sourceMappingURL=interactableTargets.prod.js.map |
{ | ||
"name": "@interactjs/pointer-events", | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/core": "1.10.2", | ||
"@interactjs/utils": "1.10.2" | ||
"@interactjs/core": "1.10.3", | ||
"@interactjs/utils": "1.10.3" | ||
}, | ||
"optionalDependencies": { | ||
"@interactjs/interact": "1.10.2" | ||
"@interactjs/interact": "1.10.3" | ||
}, | ||
@@ -12,0 +12,0 @@ "publishConfig": { |
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
81052
481