@interactjs/auto-start
Advanced tools
Comparing version 1.10.2 to 1.10.3
11
base.js
@@ -1,2 +0,1 @@ | ||
import { Scope, SignalArgs } from "../core/scope.js"; | ||
import * as domUtils from "../utils/domUtils.js"; | ||
@@ -54,6 +53,3 @@ import extend from "../utils/extend.js"; | ||
}, scope) { | ||
if (interaction.interacting()) { | ||
return; | ||
} | ||
if (interaction.interacting()) return; | ||
const actionInfo = getActionInfo(interaction, pointer, event, eventTarget, scope); | ||
@@ -69,6 +65,3 @@ prepare(interaction, actionInfo, scope); | ||
}, scope) { | ||
if (interaction.pointerType !== 'mouse' || interaction.pointerIsDown || interaction.interacting()) { | ||
return; | ||
} | ||
if (interaction.pointerType !== 'mouse' || interaction.pointerIsDown || interaction.interacting()) return; | ||
const actionInfo = getActionInfo(interaction, pointer, event, eventTarget, scope); | ||
@@ -75,0 +68,0 @@ prepare(interaction, actionInfo, scope); |
@@ -1,2 +0,2 @@ | ||
import{Scope as t,SignalArgs as e}from"../core/scope.prod.js";import*as n from"../utils/domUtils.prod.js";import r from"../utils/extend.prod.js";import o from"../utils/is.prod.js";import{copyAction as a}from"../utils/misc.prod.js";import i from"./InteractableMethods.prod.js";function s(t,e,n,r,o){return e.testIgnoreAllow(e.options[t.name],n,r)&&e.options[t.name].enabled&&m(e,n,t,o)?t:null}function c(t,e,n,r,o,a,i){for(let c=0,l=r.length;c<l;c++){const l=r[c],u=o[c],m=l.getAction(e,n,t,u);if(!m)continue;const p=s(m,l,u,a,i);if(p)return{action:p,interactable:l,element:u}}return{action:null,interactable:null,element:null}}function l(t,e,r,a,i){let s=[],l=[],u=a;function m(t){s.push(t),l.push(u)}for(;o.element(u);){s=[],l=[],i.interactables.forEachMatch(u,m);const o=c(t,e,r,s,l,a,i);if(o.action&&!o.interactable.options[o.action.name].manualStart)return o;u=n.parentNode(u)}return{action:null,interactable:null,element:null}}function u(t,{action:e,interactable:n,element:r},o){e=e||{name:null},t.interactable=n,t.element=r,a(t.prepared,e),t.rect=n&&e.name?n.getRect(r):null,d(t,o),o.fire("autoStart:prepared",{interaction:t})}function m(t,e,n,r){const o=t.options,a=o[n.name].max,i=o[n.name].maxPerElement,s=r.autoStart.maxInteractions;let c=0,l=0,u=0;if(!(a&&i&&s))return!1;for(const o of r.interactions.list){const r=o.prepared.name;if(o.interacting()){if(c++,c>=s)return!1;if(o.interactable===t){if(l+=r===n.name?1:0,l>=a)return!1;if(o.element===e&&(u++,r===n.name&&u>=i))return!1}}}return s>0}function p(t,e){return o.number(t)?(e.autoStart.maxInteractions=t,this):e.autoStart.maxInteractions}function f(t,e,n){const{cursorElement:r}=n.autoStart;r&&r!==t&&(r.style.cursor=""),t.ownerDocument.documentElement.style.cursor=e,t.style.cursor=e,n.autoStart.cursorElement=e?t:null}function d(t,e){const{interactable:n,element:r,prepared:a}=t;if("mouse"!==t.pointerType||!n||!n.options.styleCursor)return void(e.autoStart.cursorElement&&f(e.autoStart.cursorElement,"",e));let i="";if(a.name){const s=n.options[a.name].cursorChecker;i=o.func(s)?s(a,n,r,t._interacting):e.actions.map[a.name].getCursor(a)}f(t.element,i||"",e)}const b={id:"auto-start/base",before:["actions"],install(t){const{interactStatic:e,defaults:n}=t;t.usePlugin(i),n.base.actionChecker=null,n.base.styleCursor=!0,r(n.perAction,{manualStart:!1,max:1/0,maxPerElement:1,allowFrom:null,ignoreFrom:null,mouseButtons:1}),e.maxInteractions=e=>p(e,t),t.autoStart={maxInteractions:1/0,withinInteractionLimit:m,cursorElement:null}},listeners:{"interactions:down"({interaction:t,pointer:e,event:n,eventTarget:r},o){t.interacting()||u(t,l(t,e,n,r,o),o)},"interactions:move"(t,e){(({interaction:t,pointer:e,event:n,eventTarget:r},o)=>{"mouse"!==t.pointerType||t.pointerIsDown||t.interacting()||u(t,l(t,e,n,r,o),o)})(t,e),((t,e)=>{const{interaction:n}=t;if(!n.pointerIsDown||n.interacting()||!n.pointerWasMoved||!n.prepared.name)return;e.fire("autoStart:before-start",t);const{interactable:r}=n,o=n.prepared.name;o&&r&&(r.options[o].manualStart||!m(r,n.element,n.prepared,e)?n.stop():(n.start(n.prepared,r,n.element),d(n,e)))})(t,e)},"interactions:stop"({interaction:t},e){const{interactable:n}=t;n&&n.options.styleCursor&&f(t.element,"",e)}},maxInteractions:p,withinInteractionLimit:m,validateAction:s};export default b; | ||
import*as t from"../utils/domUtils.prod.js";import e from"../utils/extend.prod.js";import n from"../utils/is.prod.js";import{copyAction as r}from"../utils/misc.prod.js";import o from"./InteractableMethods.prod.js";function a(t,e,n,r,o){return e.testIgnoreAllow(e.options[t.name],n,r)&&e.options[t.name].enabled&&c(e,n,t,o)?t:null}function i(t,e,n,r,o,i,s){for(let l=0,c=r.length;l<c;l++){const c=r[l],u=o[l],m=c.getAction(e,n,t,u);if(!m)continue;const p=a(m,c,u,i,s);if(p)return{action:p,interactable:c,element:u}}return{action:null,interactable:null,element:null}}function s(e,r,o,a,s){let l=[],c=[],u=a;function m(t){l.push(t),c.push(u)}for(;n.element(u);){l=[],c=[],s.interactables.forEachMatch(u,m);const n=i(e,r,o,l,c,a,s);if(n.action&&!n.interactable.options[n.action.name].manualStart)return n;u=t.parentNode(u)}return{action:null,interactable:null,element:null}}function l(t,{action:e,interactable:n,element:o},a){e=e||{name:null},t.interactable=n,t.element=o,r(t.prepared,e),t.rect=n&&e.name?n.getRect(o):null,p(t,a),a.fire("autoStart:prepared",{interaction:t})}function c(t,e,n,r){const o=t.options,a=o[n.name].max,i=o[n.name].maxPerElement,s=r.autoStart.maxInteractions;let l=0,c=0,u=0;if(!(a&&i&&s))return!1;for(const o of r.interactions.list){const r=o.prepared.name;if(o.interacting()){if(l++,l>=s)return!1;if(o.interactable===t){if(c+=r===n.name?1:0,c>=a)return!1;if(o.element===e&&(u++,r===n.name&&u>=i))return!1}}}return s>0}function u(t,e){return n.number(t)?(e.autoStart.maxInteractions=t,this):e.autoStart.maxInteractions}function m(t,e,n){const{cursorElement:r}=n.autoStart;r&&r!==t&&(r.style.cursor=""),t.ownerDocument.documentElement.style.cursor=e,t.style.cursor=e,n.autoStart.cursorElement=e?t:null}function p(t,e){const{interactable:r,element:o,prepared:a}=t;if("mouse"!==t.pointerType||!r||!r.options.styleCursor)return void(e.autoStart.cursorElement&&m(e.autoStart.cursorElement,"",e));let i="";if(a.name){const s=r.options[a.name].cursorChecker;i=n.func(s)?s(a,r,o,t._interacting):e.actions.map[a.name].getCursor(a)}m(t.element,i||"",e)}const f={id:"auto-start/base",before:["actions"],install(t){const{interactStatic:n,defaults:r}=t;t.usePlugin(o),r.base.actionChecker=null,r.base.styleCursor=!0,e(r.perAction,{manualStart:!1,max:1/0,maxPerElement:1,allowFrom:null,ignoreFrom:null,mouseButtons:1}),n.maxInteractions=e=>u(e,t),t.autoStart={maxInteractions:1/0,withinInteractionLimit:c,cursorElement:null}},listeners:{"interactions:down"({interaction:t,pointer:e,event:n,eventTarget:r},o){t.interacting()||l(t,s(t,e,n,r,o),o)},"interactions:move"(t,e){(({interaction:t,pointer:e,event:n,eventTarget:r},o)=>{"mouse"!==t.pointerType||t.pointerIsDown||t.interacting()||l(t,s(t,e,n,r,o),o)})(t,e),((t,e)=>{const{interaction:n}=t;if(!n.pointerIsDown||n.interacting()||!n.pointerWasMoved||!n.prepared.name)return;e.fire("autoStart:before-start",t);const{interactable:r}=n,o=n.prepared.name;o&&r&&(r.options[o].manualStart||!c(r,n.element,n.prepared,e)?n.stop():(n.start(n.prepared,r,n.element),p(n,e)))})(t,e)},"interactions:stop"({interaction:t},e){const{interactable:n}=t;n&&n.options.styleCursor&&m(t.element,"",e)}},maxInteractions:u,withinInteractionLimit:c,validateAction:a};export default f; | ||
//# sourceMappingURL=base.prod.js.map |
@@ -11,7 +11,4 @@ import { parentNode } from "../utils/domUtils.js"; | ||
}, scope) { | ||
if (interaction.prepared.name !== 'drag') { | ||
return; | ||
} // check if a drag is in the correct axis | ||
if (interaction.prepared.name !== 'drag') return; // check if a drag is in the correct axis | ||
const absX = Math.abs(dx); | ||
@@ -22,7 +19,8 @@ const absY = Math.abs(dy); | ||
const currentAxis = absX > absY ? 'x' : absX < absY ? 'y' : 'xy'; | ||
interaction.prepared.axis = targetOptions.lockAxis === 'start' ? currentAxis[0] // always lock to one axis even if currentAxis === 'xy' | ||
: targetOptions.lockAxis; // if the movement isn't in the startAxis of the interactable | ||
interaction.prepared.axis = targetOptions.lockAxis === 'start' ? currentAxis[0] : // always lock to one axis even if currentAxis === 'xy' | ||
targetOptions.lockAxis; // if the movement isn't in the startAxis of the interactable | ||
if (currentAxis !== 'xy' && startAxis !== 'xy' && startAxis !== currentAxis) { | ||
// cancel the prepared action | ||
; | ||
interaction.prepared.name = null; // then try to get a drag from another ineractable | ||
@@ -33,6 +31,3 @@ | ||
const getDraggable = function (interactable) { | ||
if (interactable === interaction.interactable) { | ||
return; | ||
} | ||
if (interactable === interaction.interactable) return; | ||
const options = interaction.interactable.options.drag; | ||
@@ -54,2 +49,3 @@ | ||
if (interactable) { | ||
; | ||
interaction.prepared.name = 'drag'; | ||
@@ -56,0 +52,0 @@ interaction.interactable = interactable; |
@@ -1,2 +0,1 @@ | ||
import Interaction from "../core/Interaction.js"; | ||
import basePlugin from "./base.js"; | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,2 @@ | ||
import t from"../core/Interaction.prod.js";import e from"./base.prod.js";function r(t){const e=t.prepared&&t.prepared.name;if(!e)return null;const r=t.interactable.options;return r[e].hold||r[e].delay}const o={id:"auto-start/hold",install(t){const{defaults:r}=t;t.usePlugin(e),r.perAction.hold=0,r.perAction.delay=0},listeners:{"interactions:new"({interaction:t}){t.autoStartHoldTimer=null},"autoStart:prepared"({interaction:t}){const e=r(t);e>0&&(t.autoStartHoldTimer=setTimeout((()=>{t.start(t.prepared,t.interactable,t.element)}),e))},"interactions:move"({interaction:t,duplicate:e}){t.autoStartHoldTimer&&t.pointerWasMoved&&!e&&(clearTimeout(t.autoStartHoldTimer),t.autoStartHoldTimer=null)},"autoStart:before-start"({interaction:t}){r(t)>0&&(t.prepared.name=null)}},getHoldDuration:r};export default o; | ||
import t from"./base.prod.js";function e(t){const e=t.prepared&&t.prepared.name;if(!e)return null;const r=t.interactable.options;return r[e].hold||r[e].delay}const r={id:"auto-start/hold",install(e){const{defaults:r}=e;e.usePlugin(t),r.perAction.hold=0,r.perAction.delay=0},listeners:{"interactions:new"({interaction:t}){t.autoStartHoldTimer=null},"autoStart:prepared"({interaction:t}){const r=e(t);r>0&&(t.autoStartHoldTimer=setTimeout((()=>{t.start(t.prepared,t.interactable,t.element)}),r))},"interactions:move"({interaction:t,duplicate:e}){t.autoStartHoldTimer&&t.pointerWasMoved&&!e&&(clearTimeout(t.autoStartHoldTimer),t.autoStartHoldTimer=null)},"autoStart:before-start"({interaction:t}){e(t)>0&&(t.prepared.name=null)}},getHoldDuration:e};export default r; | ||
//# sourceMappingURL=hold.prod.js.map |
@@ -1,2 +0,1 @@ | ||
import { Interactable } from "../core/Interactable.js"; | ||
import is from "../utils/is.js"; | ||
@@ -3,0 +2,0 @@ import { warnOnce } from "../utils/misc.js"; |
@@ -1,2 +0,2 @@ | ||
import{Interactable as t}from"../core/Interactable.prod.js";import o from"../utils/is.prod.js";import{warnOnce as e}from"../utils/misc.prod.js";function r(t){return o.bool(t)?(this.options.styleCursor=t,this):null===t?(delete this.options.styleCursor,this):this.options.styleCursor}function n(t){return o.func(t)?(this.options.actionChecker=t,this):null===t?(delete this.options.actionChecker,this):this.options.actionChecker}export default{id:"auto-start/interactableMethods",install(t){const{Interactable:o}=t;o.prototype.getAction=function(o,e,r,n){const i=((t,o,e,r,n)=>{const i=t.getRect(r),s={action:null,interactable:t,interaction:e,element:r,rect:i,buttons:o.buttons||{0:1,1:4,3:8,4:16}[o.button]};return n.fire("auto-start:check",s),s.action})(this,e,r,n,t);return this.options.actionChecker?this.options.actionChecker(o,e,i,this,n,r):i},o.prototype.ignoreFrom=e((function(t){return this._backCompatOption("ignoreFrom",t)}),"Interactable.ignoreFrom() has been deprecated. Use Interactble.draggable({ignoreFrom: newValue})."),o.prototype.allowFrom=e((function(t){return this._backCompatOption("allowFrom",t)}),"Interactable.allowFrom() has been deprecated. Use Interactble.draggable({allowFrom: newValue})."),o.prototype.actionChecker=n,o.prototype.styleCursor=r}}; | ||
import t from"../utils/is.prod.js";import{warnOnce as o}from"../utils/misc.prod.js";function e(o){return t.bool(o)?(this.options.styleCursor=o,this):null===o?(delete this.options.styleCursor,this):this.options.styleCursor}function r(o){return t.func(o)?(this.options.actionChecker=o,this):null===o?(delete this.options.actionChecker,this):this.options.actionChecker}export default{id:"auto-start/interactableMethods",install(t){const{Interactable:n}=t;n.prototype.getAction=function(o,e,r,n){const i=((t,o,e,r,n)=>{const i=t.getRect(r),s={action:null,interactable:t,interaction:e,element:r,rect:i,buttons:o.buttons||{0:1,1:4,3:8,4:16}[o.button]};return n.fire("auto-start:check",s),s.action})(this,e,r,n,t);return this.options.actionChecker?this.options.actionChecker(o,e,i,this,n,r):i},n.prototype.ignoreFrom=o((function(t){return this._backCompatOption("ignoreFrom",t)}),"Interactable.ignoreFrom() has been deprecated. Use Interactble.draggable({ignoreFrom: newValue})."),n.prototype.allowFrom=o((function(t){return this._backCompatOption("allowFrom",t)}),"Interactable.allowFrom() has been deprecated. Use Interactble.draggable({allowFrom: newValue})."),n.prototype.actionChecker=r,n.prototype.styleCursor=e}}; | ||
//# sourceMappingURL=InteractableMethods.prod.js.map |
{ | ||
"name": "@interactjs/auto-start", | ||
"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
102132
575