@interactjs/interact
Advanced tools
Comparing version 1.9.4 to 1.9.5
@@ -1,76 +0,4 @@ | ||
/** @module interact */ | ||
import '@interactjs/types/index'; | ||
import { Options } from '@interactjs/core/defaultOptions'; | ||
import Interactable from '@interactjs/core/Interactable'; | ||
import { Scope } from '@interactjs/core/scope'; | ||
import * as utils from '@interactjs/utils/index'; | ||
declare module '@interactjs/core/scope' { | ||
interface Scope { | ||
interact?: InteractStatic; | ||
} | ||
} | ||
export interface InteractStatic { | ||
(target: Interact.Target, options?: Options): Interactable; | ||
on: typeof on; | ||
pointerMoveTolerance: typeof pointerMoveTolerance; | ||
stop: typeof stop; | ||
supportsPointerEvent: typeof supportsPointerEvent; | ||
supportsTouch: typeof supportsTouch; | ||
debug: typeof debug; | ||
off: typeof off; | ||
isSet: typeof isSet; | ||
use: typeof use; | ||
getPointerAverage: typeof utils.pointer.pointerAverage; | ||
getTouchBBox: typeof utils.pointer.touchBBox; | ||
getTouchDistance: typeof utils.pointer.touchDistance; | ||
getTouchAngle: typeof utils.pointer.touchAngle; | ||
getElementRect: typeof utils.dom.getElementRect; | ||
getElementClientRect: typeof utils.dom.getElementClientRect; | ||
matchesSelector: typeof utils.dom.matchesSelector; | ||
closest: typeof utils.dom.closest; | ||
addDocument: typeof scope.addDocument; | ||
removeDocument: typeof scope.removeDocument; | ||
dynamicDrop: (newValue?: boolean) => boolean | Interact.interact; | ||
version: string; | ||
} | ||
declare const scope: Scope; | ||
export declare function init(win: Window): InteractStatic; | ||
/** | ||
* ```js | ||
* interact('#draggable').draggable(true) | ||
* | ||
* var rectables = interact('rect') | ||
* rectables | ||
* .gesturable(true) | ||
* .on('gesturemove', function (event) { | ||
* // ... | ||
* }) | ||
* ``` | ||
* | ||
* The methods of this variable can be used to set elements as interactables | ||
* and also to change various default settings. | ||
* | ||
* Calling it as a function and passing an element or a valid CSS selector | ||
* string returns an Interactable object which has various methods to configure | ||
* it. | ||
* | ||
* @global | ||
* | ||
* @param {Element | string} target The HTML or SVG Element to interact with | ||
* or CSS selector | ||
* @return {Interactable} | ||
*/ | ||
export declare const interact: InteractStatic; | ||
declare function use(plugin: Interact.Plugin, options?: { | ||
[key: string]: any; | ||
}): InteractStatic; | ||
declare function isSet(target: Interact.Element, options?: any): boolean; | ||
declare function on(type: string | Interact.EventTypes, listener: Interact.ListenersArg, options?: object): InteractStatic; | ||
declare function off(type: Interact.EventTypes, listener: any, options?: object): InteractStatic; | ||
declare function debug(): Scope; | ||
declare function supportsTouch(): boolean; | ||
declare function supportsPointerEvent(): boolean; | ||
declare function stop(): InteractStatic; | ||
declare function pointerMoveTolerance(newValue?: number): number | InteractStatic; | ||
export { scope }; | ||
declare const interact: import("@interactjs/core/InteractStatic").InteractStatic; | ||
export default interact; | ||
export declare const init: (win: Window) => import("@interactjs/core/scope").default; |
273
index.js
@@ -1,272 +0,11 @@ | ||
/** @module interact */ | ||
import "../types/index.js"; | ||
import { isNonNativeEvent, Scope } from "../core/scope.js"; | ||
import browser from "../utils/browser.js"; | ||
import events from "../utils/events.js"; | ||
import * as utils from "../utils/index.js"; | ||
const globalEvents = {}; | ||
import Scope from "../core/scope.js"; | ||
const scope = new Scope(); | ||
export function init(win) { | ||
scope.init(win); | ||
return interact; | ||
} | ||
/** | ||
* ```js | ||
* interact('#draggable').draggable(true) | ||
* | ||
* var rectables = interact('rect') | ||
* rectables | ||
* .gesturable(true) | ||
* .on('gesturemove', function (event) { | ||
* // ... | ||
* }) | ||
* ``` | ||
* | ||
* The methods of this variable can be used to set elements as interactables | ||
* and also to change various default settings. | ||
* | ||
* Calling it as a function and passing an element or a valid CSS selector | ||
* string returns an Interactable object which has various methods to configure | ||
* it. | ||
* | ||
* @global | ||
* | ||
* @param {Element | string} target The HTML or SVG Element to interact with | ||
* or CSS selector | ||
* @return {Interactable} | ||
*/ | ||
const interact = scope.interactStatic; | ||
export default interact; | ||
export const init = win => scope.init(win); | ||
export const interact = function interact(target, options) { | ||
let interactable = scope.interactables.get(target, options); | ||
if (!interactable) { | ||
interactable = scope.interactables.new(target, options); | ||
interactable.events.global = globalEvents; | ||
} | ||
return interactable; | ||
}; | ||
/** | ||
* Use a plugin | ||
* | ||
* @alias module:interact.use | ||
* | ||
* @param {Object} plugin | ||
* @param {function} plugin.install | ||
* @return {interact} | ||
*/ | ||
interact.use = use; | ||
function use(plugin, options) { | ||
scope.usePlugin(plugin, options); | ||
return interact; | ||
if (typeof window === 'object' && !!window) { | ||
init(window); | ||
} | ||
/** | ||
* Check if an element or selector has been set with the {@link interact} | ||
* function | ||
* | ||
* @alias module:interact.isSet | ||
* | ||
* @param {Element} element The Element being searched for | ||
* @return {boolean} Indicates if the element or CSS selector was previously | ||
* passed to interact | ||
*/ | ||
interact.isSet = isSet; | ||
function isSet(target, options) { | ||
return !!scope.interactables.get(target, options && options.context); | ||
} | ||
/** | ||
* Add a global listener for an InteractEvent or adds a DOM event to `document` | ||
* | ||
* @alias module:interact.on | ||
* | ||
* @param {string | array | object} type The types of events to listen for | ||
* @param {function} listener The function event (s) | ||
* @param {object | boolean} [options] object or useCapture flag for | ||
* addEventListener | ||
* @return {object} interact | ||
*/ | ||
interact.on = on; | ||
function on(type, listener, options) { | ||
if (utils.is.string(type) && type.search(' ') !== -1) { | ||
type = type.trim().split(/ +/); | ||
} | ||
if (utils.is.array(type)) { | ||
for (const eventType of type) { | ||
interact.on(eventType, listener, options); | ||
} | ||
return interact; | ||
} | ||
if (utils.is.object(type)) { | ||
for (const prop in type) { | ||
interact.on(prop, type[prop], listener); | ||
} | ||
return interact; | ||
} // if it is an InteractEvent type, add listener to globalEvents | ||
if (isNonNativeEvent(type, scope.actions)) { | ||
// if this type of event was never bound | ||
if (!globalEvents[type]) { | ||
globalEvents[type] = [listener]; | ||
} else { | ||
globalEvents[type].push(listener); | ||
} | ||
} // If non InteractEvent type, addEventListener to document | ||
else { | ||
events.add(scope.document, type, listener, { | ||
options | ||
}); | ||
} | ||
return interact; | ||
} | ||
/** | ||
* Removes a global InteractEvent listener or DOM event from `document` | ||
* | ||
* @alias module:interact.off | ||
* | ||
* @param {string | array | object} type The types of events that were listened | ||
* for | ||
* @param {function} listener The listener function to be removed | ||
* @param {object | boolean} options [options] object or useCapture flag for | ||
* removeEventListener | ||
* @return {object} interact | ||
*/ | ||
interact.off = off; | ||
function off(type, listener, options) { | ||
if (utils.is.string(type) && type.search(' ') !== -1) { | ||
type = type.trim().split(/ +/); | ||
} | ||
if (utils.is.array(type)) { | ||
for (const eventType of type) { | ||
interact.off(eventType, listener, options); | ||
} | ||
return interact; | ||
} | ||
if (utils.is.object(type)) { | ||
for (const prop in type) { | ||
interact.off(prop, type[prop], listener); | ||
} | ||
return interact; | ||
} | ||
if (isNonNativeEvent(type, scope.actions)) { | ||
let index; | ||
if (type in globalEvents && (index = globalEvents[type].indexOf(listener)) !== -1) { | ||
globalEvents[type].splice(index, 1); | ||
} | ||
} else { | ||
events.remove(scope.document, type, listener, options); | ||
} | ||
return interact; | ||
} | ||
interact.debug = debug; | ||
function debug() { | ||
return scope; | ||
} // expose the functions used to calculate multi-touch properties | ||
interact.getPointerAverage = utils.pointer.pointerAverage; | ||
interact.getTouchBBox = utils.pointer.touchBBox; | ||
interact.getTouchDistance = utils.pointer.touchDistance; | ||
interact.getTouchAngle = utils.pointer.touchAngle; | ||
interact.getElementRect = utils.dom.getElementRect; | ||
interact.getElementClientRect = utils.dom.getElementClientRect; | ||
interact.matchesSelector = utils.dom.matchesSelector; | ||
interact.closest = utils.dom.closest; | ||
/** | ||
* @alias module:interact.supportsTouch | ||
* | ||
* @return {boolean} Whether or not the browser supports touch input | ||
*/ | ||
interact.supportsTouch = supportsTouch; | ||
function supportsTouch() { | ||
return browser.supportsTouch; | ||
} | ||
/** | ||
* @alias module:interact.supportsPointerEvent | ||
* | ||
* @return {boolean} Whether or not the browser supports PointerEvents | ||
*/ | ||
interact.supportsPointerEvent = supportsPointerEvent; | ||
function supportsPointerEvent() { | ||
return browser.supportsPointerEvent; | ||
} | ||
/** | ||
* Cancels all interactions (end events are not fired) | ||
* | ||
* @alias module:interact.stop | ||
* | ||
* @return {object} interact | ||
*/ | ||
interact.stop = stop; | ||
function stop() { | ||
for (const interaction of scope.interactions.list) { | ||
interaction.stop(); | ||
} | ||
return interact; | ||
} | ||
/** | ||
* Returns or sets the distance the pointer must be moved before an action | ||
* sequence occurs. This also affects tolerance for tap events. | ||
* | ||
* @alias module:interact.pointerMoveTolerance | ||
* | ||
* @param {number} [newValue] The movement from the start position must be greater than this value | ||
* @return {interact | number} | ||
*/ | ||
interact.pointerMoveTolerance = pointerMoveTolerance; | ||
function pointerMoveTolerance(newValue) { | ||
if (utils.is.number(newValue)) { | ||
scope.interactions.pointerMoveTolerance = newValue; | ||
return interact; | ||
} | ||
return scope.interactions.pointerMoveTolerance; | ||
} | ||
interact.addDocument = (doc, options) => scope.addDocument(doc, options); | ||
interact.removeDocument = doc => scope.removeDocument(doc); // eslint-disable-next-line no-undef | ||
interact.version = "1.9.4"; | ||
scope.interact = interact; | ||
export { scope }; | ||
export default interact; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import"../types/index.min.js";import{isNonNativeEvent as t,Scope as e}from"../core/scope.min.js";import n from"../utils/browser.min.js";import r from"../utils/events.min.js";import*as i from"../utils/index.min.js";const o={},c=new e;export function init(t){return c.init(t),interact}export const interact=function(t,e){let n=c.interactables.get(t,e);return n||(n=c.interactables.new(t,e),n.events.global=o),n};interact.use=function(t,e){return c.usePlugin(t,e),interact},interact.isSet=function(t,e){return!!c.interactables.get(t,e&&e.context)},interact.on=function(e,n,a){i.is.string(e)&&-1!==e.search(" ")&&(e=e.trim().split(/ +/));if(i.is.array(e)){for(const t of e)interact.on(t,n,a);return interact}if(i.is.object(e)){for(const t in e)interact.on(t,e[t],n);return interact}t(e,c.actions)?o[e]?o[e].push(n):o[e]=[n]:r.add(c.document,e,n,{options:a});return interact},interact.off=function(e,n,a){i.is.string(e)&&-1!==e.search(" ")&&(e=e.trim().split(/ +/));if(i.is.array(e)){for(const t of e)interact.off(t,n,a);return interact}if(i.is.object(e)){for(const t in e)interact.off(t,e[t],n);return interact}if(t(e,c.actions)){let t;e in o&&-1!==(t=o[e].indexOf(n))&&o[e].splice(t,1)}else r.remove(c.document,e,n,a);return interact},interact.debug=function(){return c},interact.getPointerAverage=i.pointer.pointerAverage,interact.getTouchBBox=i.pointer.touchBBox,interact.getTouchDistance=i.pointer.touchDistance,interact.getTouchAngle=i.pointer.touchAngle,interact.getElementRect=i.dom.getElementRect,interact.getElementClientRect=i.dom.getElementClientRect,interact.matchesSelector=i.dom.matchesSelector,interact.closest=i.dom.closest,interact.supportsTouch=function(){return n.supportsTouch},interact.supportsPointerEvent=function(){return n.supportsPointerEvent},interact.stop=function(){for(const t of c.interactions.list)t.stop();return interact},interact.pointerMoveTolerance=function(t){if(i.is.number(t))return c.interactions.pointerMoveTolerance=t,interact;return c.interactions.pointerMoveTolerance},interact.addDocument=(t,e)=>c.addDocument(t,e),interact.removeDocument=t=>c.removeDocument(t),interact.version="1.9.4",c.interact=interact;export{c as scope};export default interact; | ||
import"../types/index.min.js";import t from"../core/scope.min.js";const i=new t,o=i.interactStatic;export default o;export const init=t=>i.init(t);var n;"object"==typeof window&&window&&(n=window,i.init(n)); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@interactjs/interact", | ||
"version": "1.9.4", | ||
"version": "1.9.5", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@interactjs/core": "1.9.4", | ||
"@interactjs/utils": "1.9.4", | ||
"@interactjs/types": "1.9.4" | ||
"dependencies": { | ||
"@interactjs/core": "1.9.5", | ||
"@interactjs/types": "1.9.5", | ||
"@interactjs/utils": "1.9.5" | ||
}, | ||
"devDependencies": { | ||
"@interactjs/_dev": "1.9.4" | ||
"@interactjs/_dev": "1.9.5" | ||
}, | ||
@@ -16,3 +16,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "090f296d" | ||
"gitHead": "cb94f9a0" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
3881
15
1
+ Added@interactjs/core@1.9.5
+ Added@interactjs/types@1.9.5
+ Added@interactjs/utils@1.9.5
+ Added@interactjs/actions@1.9.5(transitive)
+ Added@interactjs/arrange@1.9.5(transitive)
+ Added@interactjs/auto-scroll@1.9.5(transitive)
+ Added@interactjs/auto-start@1.9.5(transitive)
+ Added@interactjs/core@1.9.5(transitive)
+ Added@interactjs/dev-tools@1.9.5(transitive)
+ Added@interactjs/inertia@1.9.5(transitive)
+ Added@interactjs/modifiers@1.9.5(transitive)
+ Added@interactjs/offset@1.9.5(transitive)
+ Added@interactjs/pointer-events@1.9.5(transitive)
+ Added@interactjs/reflow@1.9.5(transitive)
+ Added@interactjs/snappers@1.9.5(transitive)
+ Added@interactjs/symbol-tree@1.9.5(transitive)
+ Added@interactjs/types@1.9.5(transitive)
+ Added@interactjs/utils@1.9.5(transitive)
- Removed@interactjs/actions@1.9.4(transitive)
- Removed@interactjs/auto-scroll@1.9.4(transitive)
- Removed@interactjs/auto-start@1.9.4(transitive)
- Removed@interactjs/core@1.9.4(transitive)
- Removed@interactjs/dev-tools@1.9.4(transitive)
- Removed@interactjs/inertia@1.9.4(transitive)
- Removed@interactjs/modifiers@1.9.4(transitive)
- Removed@interactjs/offset@1.9.4(transitive)
- Removed@interactjs/pointer-events@1.9.4(transitive)
- Removed@interactjs/reflow@1.9.4(transitive)
- Removed@interactjs/types@1.9.4(transitive)
- Removed@interactjs/utils@1.9.4(transitive)