@interactjs/core
Advanced tools
Comparing version 1.9.4 to 1.9.5
@@ -11,3 +11,3 @@ export interface Defaults { | ||
deltaSource?: 'page' | 'client'; | ||
context?: Interact.EventTarget; | ||
context?: Node; | ||
} | ||
@@ -14,0 +14,0 @@ export interface PerActionDefaults { |
@@ -12,3 +12,3 @@ import { Defaults, Options } from './defaultOptions'; | ||
readonly events: Eventable; | ||
readonly _context: Document | Interact.Element; | ||
readonly _context: Interact.Context; | ||
readonly _win: Window; | ||
@@ -15,0 +15,0 @@ readonly _doc: Document; |
@@ -8,3 +8,3 @@ import browser from "../utils/browser.js"; | ||
import finder from "./interactionFinder.js"; | ||
import { Scope } from "./scope.js"; | ||
import Scope from "./scope.js"; | ||
import interactablePreventDefault from "./interactablePreventDefault.js"; | ||
@@ -11,0 +11,0 @@ const methodNames = ['pointerDown', 'pointerMove', 'pointerUp', 'updatePointer', 'removePointer', 'windowBlur']; |
@@ -1,2 +0,2 @@ | ||
import e from"../utils/browser.min.js";import t from"../utils/domObjects.min.js";import{nodeContains as n}from"../utils/domUtils.min.js";import o from"../utils/events.min.js";import*as r from"../utils/pointerUtils.min.js";import i from"./Interaction.min.js";import s from"./interactionFinder.min.js";import{Scope as p}from"./scope.min.js";import c from"./interactablePreventDefault.min.js";const a=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function l(t,n){return o=>{const i=n.interactions.list,s=r.getPointerType(o),[p,c]=r.getEventTargets(o),a=[];if(/^touch/.test(o.type)){n.prevTouchTime=n.now();for(const e of o.changedTouches){const t=e,i={pointer:t,pointerId:r.getPointerId(t),pointerType:s,eventType:o.type,eventTarget:p,curEventTarget:c,scope:n},l=u(i);a.push([i.pointer,i.eventTarget,i.curEventTarget,l])}}else{let t=!1;if(!e.supportsPointerEvent&&/mouse/.test(o.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===o.timeStamp}if(!t){const e={pointer:o,pointerId:r.getPointerId(o),pointerType:s,eventType:o.type,curEventTarget:c,eventTarget:p,scope:n},t=u(e);a.push([e.pointer,e.eventTarget,e.curEventTarget,t])}}for(const[e,n,r,i]of a)i[t](e,o,n,r)}}function u(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 m({doc:e,scope:t,options:n},r){const{docEvents:i}=t.interactions,s=o[r];t.browser.isIOS&&!n.events&&(n.events={passive:!1});for(const t in o.delegatedEvents)s(e,t,o.delegateListener),s(e,t,o.delegateUseCapture,!0);const p=n&&n.events;for(const{type:t,listener:n}of i)s(e,t,n,p)}const v={id:"core/interactions",install(o){const r={};for(const e of a)r[e]=l(e,o);const s=e.pEventTypes;let p;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)}p=t.PointerEvent?[{type:s.down,listener:u},{type:s.down,listener:r.pointerDown},{type:s.move,listener:r.pointerMove},{type:s.up,listener:r.pointerUp},{type:s.cancel,listener:r.pointerUp}]:[{type:"mousedown",listener:r.pointerDown},{type:"mousemove",listener:r.pointerMove},{type:"mouseup",listener:r.pointerUp},{type:"touchstart",listener:u},{type:"touchstart",listener:r.pointerDown},{type:"touchmove",listener:r.pointerMove},{type:"touchend",listener:r.pointerUp},{type:"touchcancel",listener:r.pointerUp}],p.push({type:"blur",listener(e){for(const t of o.interactions.list)t.documentBlur(e)}}),o.prevTouchTime=0,o.Interaction=class extends i{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:r,docEvents:p,pointerMoveTolerance:1},o.usePlugin(c)},listeners:{"scope:add-document"(e){return m(e,"add")},"scope:remove-document"(e){return m(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:m,doOnInteractions:l,methodNames:a};export default v; | ||
import e from"../utils/browser.min.js";import t from"../utils/domObjects.min.js";import{nodeContains as n}from"../utils/domUtils.min.js";import o from"../utils/events.min.js";import*as r from"../utils/pointerUtils.min.js";import i from"./Interaction.min.js";import s from"./interactionFinder.min.js";import p from"./scope.min.js";import c from"./interactablePreventDefault.min.js";const a=["pointerDown","pointerMove","pointerUp","updatePointer","removePointer","windowBlur"];function l(t,n){return o=>{const i=n.interactions.list,s=r.getPointerType(o),[p,c]=r.getEventTargets(o),a=[];if(/^touch/.test(o.type)){n.prevTouchTime=n.now();for(const e of o.changedTouches){const t=e,i={pointer:t,pointerId:r.getPointerId(t),pointerType:s,eventType:o.type,eventTarget:p,curEventTarget:c,scope:n},l=u(i);a.push([i.pointer,i.eventTarget,i.curEventTarget,l])}}else{let t=!1;if(!e.supportsPointerEvent&&/mouse/.test(o.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===o.timeStamp}if(!t){const e={pointer:o,pointerId:r.getPointerId(o),pointerType:s,eventType:o.type,curEventTarget:c,eventTarget:p,scope:n},t=u(e);a.push([e.pointer,e.eventTarget,e.curEventTarget,t])}}for(const[e,n,r,i]of a)i[t](e,o,n,r)}}function u(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 m({doc:e,scope:t,options:n},r){const{docEvents:i}=t.interactions,s=o[r];t.browser.isIOS&&!n.events&&(n.events={passive:!1});for(const t in o.delegatedEvents)s(e,t,o.delegateListener),s(e,t,o.delegateUseCapture,!0);const p=n&&n.events;for(const{type:t,listener:n}of i)s(e,t,n,p)}const v={id:"core/interactions",install(o){const r={};for(const e of a)r[e]=l(e,o);const s=e.pEventTypes;let p;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)}p=t.PointerEvent?[{type:s.down,listener:u},{type:s.down,listener:r.pointerDown},{type:s.move,listener:r.pointerMove},{type:s.up,listener:r.pointerUp},{type:s.cancel,listener:r.pointerUp}]:[{type:"mousedown",listener:r.pointerDown},{type:"mousemove",listener:r.pointerMove},{type:"mouseup",listener:r.pointerUp},{type:"touchstart",listener:u},{type:"touchstart",listener:r.pointerDown},{type:"touchmove",listener:r.pointerMove},{type:"touchend",listener:r.pointerUp},{type:"touchcancel",listener:r.pointerUp}],p.push({type:"blur",listener(e){for(const t of o.interactions.list)t.documentBlur(e)}}),o.prevTouchTime=0,o.Interaction=class extends i{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:r,docEvents:p,pointerMoveTolerance:1},o.usePlugin(c)},listeners:{"scope:add-document"(e){return m(e,"add")},"scope:remove-document"(e){return m(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:m,doOnInteractions:l,methodNames:a};export default v; | ||
//# sourceMappingURL=interactions.min.js.map |
{ | ||
"name": "@interactjs/core", | ||
"version": "1.9.4", | ||
"version": "1.9.5", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/dev-tools": "1.9.4", | ||
"@interactjs/utils": "1.9.4" | ||
"@interactjs/dev-tools": "1.9.5", | ||
"@interactjs/utils": "1.9.5" | ||
}, | ||
"devDependencies": { | ||
"@interactjs/_dev": "1.9.4", | ||
"@interactjs/actions": "1.9.4", | ||
"@interactjs/auto-start": "1.9.4" | ||
"@interactjs/_dev": "1.9.5", | ||
"@interactjs/actions": "1.9.5", | ||
"@interactjs/auto-start": "1.9.5" | ||
}, | ||
@@ -17,3 +17,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "090f296d" | ||
"gitHead": "cb94f9a0" | ||
} |
import * as utils from '@interactjs/utils/index'; | ||
import defaults from './defaultOptions'; | ||
import Eventable from './Eventable'; | ||
@@ -7,2 +6,3 @@ import InteractableBase from './Interactable'; | ||
import InteractEvent, { PhaseMap } from './InteractEvent'; | ||
import InteractStatic from './InteractStatic'; | ||
export interface SignalArgs { | ||
@@ -47,4 +47,2 @@ 'scope:add-document': DocSignalArg; | ||
} | ||
export declare function createScope(): Scope; | ||
export declare type Defaults = typeof defaults; | ||
export interface Plugin { | ||
@@ -57,3 +55,3 @@ [key: string]: any; | ||
} | ||
export declare class Scope { | ||
export default class Scope { | ||
id: string; | ||
@@ -111,5 +109,6 @@ isInitialized: boolean; | ||
utils: typeof utils; | ||
defaults: Defaults; | ||
defaults: import("@interactjs/core/defaultOptions").Defaults; | ||
Eventable: typeof Eventable; | ||
actions: Actions; | ||
interactStatic: InteractStatic; | ||
InteractEvent: typeof InteractEvent; | ||
@@ -135,3 +134,3 @@ Interactable: typeof InteractableBase; | ||
onWindowUnload: (event: BeforeUnloadEvent) => void; | ||
init(window: Window): Scope; | ||
init(window: Window): import("@interactjs/core/scope").default; | ||
pluginIsInstalled(plugin: Plugin): boolean | Plugin; | ||
@@ -148,3 +147,3 @@ usePlugin(plugin: Plugin, options?: { | ||
export declare function isNonNativeEvent(type: string, actions: Actions): boolean; | ||
export declare function initScope(scope: Scope, window: Window): Scope; | ||
export {}; | ||
export declare function initScope(scope: Scope, window: Window): import("@interactjs/core/scope").default; | ||
export { Scope }; |
@@ -9,2 +9,3 @@ import domObjects from "../utils/domObjects.js"; | ||
import interactions from "./interactions.js"; | ||
import InteractStatic from "./InteractStatic.js"; | ||
const { | ||
@@ -17,6 +18,3 @@ win, | ||
export function createScope() { | ||
return new Scope(); | ||
} | ||
export class Scope { | ||
export default class Scope { | ||
// main window | ||
@@ -45,2 +43,3 @@ // main document | ||
}; | ||
this.interactStatic = new InteractStatic(this); | ||
this.InteractEvent = InteractEvent; | ||
@@ -245,2 +244,3 @@ this.Interactable = void 0; | ||
} | ||
export { Scope }; | ||
//# sourceMappingURL=scope.js.map |
@@ -1,2 +0,2 @@ | ||
import t from"../utils/domObjects.min.js";import*as i from"../utils/index.min.js";import e from"./defaultOptions.min.js";import s from"./Eventable.min.js";import n from"./Interactable.min.js";import o from"./InteractableSet.min.js";import r from"./InteractEvent.min.js";import a from"./interactions.min.js";const{win:d,browser:l,raf:c,events:h}=i;export function createScope(){return new Scope}export class Scope{constructor(){this.id=`__interact_scope_${Math.floor(100*Math.random())}`,this.isInitialized=!1,this.listenerMaps=[],this.browser=l,this.events=h,this.utils=i,this.defaults=i.clone(e),this.Eventable=s,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.InteractEvent=r,this.Interactable=void 0,this.interactables=new o(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 t=this;this.Interactable=class extends n{get _defaults(){return t.defaults}set(i){return super.set(i),t.fire("interactable:set",{options:i,interactable:this}),this}unset(){super.unset(),t.interactables.list.splice(t.interactables.list.indexOf(this),1),t.fire("interactable:unset",{interactable:this})}}}addListeners(t,i){this.listenerMaps.push({id:i,map:t})}fire(t,i){for(const{map:{[t]:e}}of this.listenerMaps)if(e&&!1===e(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.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 e=this.listenerMaps.length,s=t.before.reduce((t,i)=>(t[i]=!0,t),{});for(;i<e;i++){if(s[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,e){if(-1!==this.getDocIndex(t))return!1;const s=d.getWindow(t);e=e?i.extend({},e):{},this.documents.push({doc:t,options:e}),h.documents.push(t),t!==this.document&&h.add(s,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:s,scope:this,options:e})}removeDocument(t){const i=this.getDocIndex(t),e=d.getWindow(t),s=this.documents[i].options;h.remove(e,"unload",this.onWindowUnload),this.documents.splice(i,1),h.documents.splice(i,1),this.fire("scope:remove-document",{doc:t,window:e,scope:this,options:s})}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 e in i.map)if(0===t.indexOf(e)&&t.substr(e.length)in i.phases)return!0;return!1}export function initScope(i,e){return i.isInitialized=!0,d.init(e),t.init(e),l.init(e),c.init(e),h.init(e),i.usePlugin(a),i.document=e.document,i.window=e,i} | ||
import t from"../utils/domObjects.min.js";import*as i from"../utils/index.min.js";import s from"./defaultOptions.min.js";import e from"./Eventable.min.js";import n from"./Interactable.min.js";import o from"./InteractableSet.min.js";import r from"./InteractEvent.min.js";import a from"./interactions.min.js";import d from"./InteractStatic.min.js";const{win:l,browser:h,raf:c,events:u}=i;export default class p{constructor(){this.id=`__interact_scope_${Math.floor(100*Math.random())}`,this.isInitialized=!1,this.listenerMaps=[],this.browser=h,this.events=u,this.utils=i,this.defaults=i.clone(s),this.Eventable=e,this.actions={map:{},phases:{start:!0,move:!0,end:!0},methodDict:{},phaselessTypes:{}},this.interactStatic=new d(this),this.InteractEvent=r,this.Interactable=void 0,this.interactables=new o(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 t=this;this.Interactable=class extends n{get _defaults(){return t.defaults}set(i){return super.set(i),t.fire("interactable:set",{options:i,interactable:this}),this}unset(){super.unset(),t.interactables.list.splice(t.interactables.list.indexOf(this),1),t.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.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,s){if(-1!==this.getDocIndex(t))return!1;const e=l.getWindow(t);s=s?i.extend({},s):{},this.documents.push({doc:t,options:s}),u.documents.push(t),t!==this.document&&u.add(e,"unload",this.onWindowUnload),this.fire("scope:add-document",{doc:t,window:e,scope:this,options:s})}removeDocument(t){const i=this.getDocIndex(t),s=l.getWindow(t),e=this.documents[i].options;u.remove(s,"unload",this.onWindowUnload),this.documents.splice(i,1),u.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,s){return i.isInitialized=!0,l.init(s),t.init(s),h.init(s),c.init(s),u.init(s),i.usePlugin(a),i.document=s.document,i.window=s,i}export{p as Scope}; | ||
//# sourceMappingURL=scope.min.js.map |
@@ -62,3 +62,3 @@ import * as utils from '@interactjs/utils/index'; | ||
export declare function newPointer(n?: number): import("@interactjs/types/types").PointerType; | ||
export declare function mockScope(options?: any): import("@interactjs/core/scope").Scope; | ||
export declare function mockScope(options?: any): import("@interactjs/core/scope").default; | ||
export declare function getProps<T extends { | ||
@@ -72,3 +72,3 @@ [key: string]: any; | ||
}): { | ||
scope: import("@interactjs/core/scope").Scope; | ||
scope: import("@interactjs/core/scope").default; | ||
interaction: import("@interactjs/core/Interaction").Interaction<"resize" | "drag" | "drop" | "gesture">; | ||
@@ -454,2 +454,3 @@ target: T; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<never, "end" | "resume" | "start" | "move" | "inertiastart" | "reflow"> & TouchEvent); | ||
interact: import("@interactjs/core/InteractStatic").InteractStatic; | ||
start: (action: import("@interactjs/core/Interaction").ActionProps<any>) => any; | ||
@@ -461,3 +462,3 @@ stop: () => void; | ||
}; | ||
export declare function timeout(n: any): Promise<unknown>; | ||
export declare function timeout(n: number): Promise<unknown>; | ||
export declare function ltrbwh(left: number, top: number, right: number, bottom: number, width: number, height: number): { | ||
@@ -464,0 +465,0 @@ left: number; |
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
403833
76
3439