@interactjs/interact
Advanced tools
Comparing version 1.4.0-alpha.20 to 1.4.0-alpha.21
@@ -1,2 +0,9 @@ | ||
import { default as interact } from './interact'; | ||
import * as actions from '@interactjs/actions'; | ||
import autoScroll from '@interactjs/auto-scroll'; | ||
import interactablePreventDefault from '@interactjs/core/interactablePreventDefault'; | ||
import inertia from '@interactjs/inertia'; | ||
import modifiersBase from '@interactjs/modifiers/base'; | ||
import * as pointerEvents from '@interactjs/pointer-events'; | ||
import reflow from '@interactjs/reflow'; | ||
import interact from './interact'; | ||
export declare function init(window: Window): typeof interact; | ||
@@ -7,2 +14,2 @@ export declare namespace init { | ||
export default interact; | ||
export { interact }; | ||
export { interact, actions, autoScroll, interactablePreventDefault, inertia, modifiersBase as modifiers, pointerEvents, reflow, }; |
@@ -11,3 +11,3 @@ /* browser entry point */ | ||
import reflow from '@interactjs/reflow'; | ||
import { default as interact, scope } from './interact'; | ||
import interact, { scope } from './interact'; | ||
export function init(window) { | ||
@@ -41,3 +41,3 @@ scope.init(window); | ||
export default interact; | ||
export { interact }; | ||
export { interact, actions, autoScroll, interactablePreventDefault, inertia, modifiersBase as modifiers, pointerEvents, reflow, }; | ||
//# sourceMappingURL=index.js.map |
62
index.ts
/* browser entry point */ | ||
import * as actions from '@interactjs/actions'; | ||
import autoScroll from '@interactjs/auto-scroll'; | ||
import * as autoStart from '@interactjs/auto-start'; | ||
import interactablePreventDefault from '@interactjs/core/interactablePreventDefault'; | ||
import inertia from '@interactjs/inertia'; | ||
import * as modifiers from '@interactjs/modifiers'; | ||
import modifiersBase from '@interactjs/modifiers/base'; | ||
import * as pointerEvents from '@interactjs/pointer-events'; | ||
import reflow from '@interactjs/reflow'; | ||
import { default as interact, scope } from './interact'; | ||
import * as actions from '@interactjs/actions' | ||
import autoScroll from '@interactjs/auto-scroll' | ||
import * as autoStart from '@interactjs/auto-start' | ||
import interactablePreventDefault from '@interactjs/core/interactablePreventDefault' | ||
import inertia from '@interactjs/inertia' | ||
import * as modifiers from '@interactjs/modifiers' | ||
import modifiersBase from '@interactjs/modifiers/base' | ||
import * as pointerEvents from '@interactjs/pointer-events' | ||
import reflow from '@interactjs/reflow' | ||
import interact, { scope } from './interact' | ||
export function init (window: Window): typeof interact { | ||
scope.init(window); | ||
scope.init(window) | ||
interact.use(interactablePreventDefault); | ||
interact.use(interactablePreventDefault) | ||
// inertia | ||
interact.use(inertia); | ||
interact.use(inertia) | ||
// pointerEvents | ||
interact.use(pointerEvents); | ||
interact.use(pointerEvents) | ||
// autoStart, hold | ||
interact.use(autoStart); | ||
interact.use(autoStart) | ||
// drag and drop, resize, gesture | ||
interact.use(actions); | ||
interact.use(actions) | ||
// snap, resize, etc. | ||
interact.use(modifiersBase); | ||
interact.use(modifiersBase) | ||
// for backwrads compatibility | ||
for (const type in modifiers) { | ||
const { _defaults, _methods } = modifiers[type]; | ||
const { _defaults, _methods } = modifiers[type] | ||
_defaults._methods = _methods; | ||
scope.defaults.perAction[type] = _defaults; | ||
_defaults._methods = _methods | ||
scope.defaults.perAction[type] = _defaults | ||
} | ||
// autoScroll | ||
interact.use(autoScroll); | ||
interact.use(autoScroll) | ||
// reflow | ||
interact.use(reflow); | ||
interact.use(reflow) | ||
return interact; | ||
return interact | ||
} | ||
// eslint-disable-next-line no-undef | ||
interact.version = init.version = process.env.npm_package_version; | ||
interact.version = init.version = process.env.npm_package_version | ||
export default interact; | ||
export { interact }; | ||
export default interact | ||
export { | ||
interact, | ||
actions, | ||
autoScroll, | ||
interactablePreventDefault, | ||
inertia, | ||
modifiersBase as modifiers, | ||
pointerEvents, | ||
reflow, | ||
} |
/** @module interact */ | ||
import { Options } from '@interactjs/core/defaultOptions'; | ||
import Interactable from '@interactjs/core/Interactable'; | ||
import { Scope } from '@interactjs/core/scope'; | ||
@@ -9,3 +11,3 @@ import * as utils from '@interactjs/utils'; | ||
interface Scope { | ||
interact: typeof interactExport; | ||
interact: InteractStatic; | ||
_plugins: Plugin[]; | ||
@@ -15,2 +17,3 @@ } | ||
export interface InteractStatic { | ||
(target: Interact.Target, options?: Options): Interactable; | ||
on: typeof on; | ||
@@ -40,5 +43,5 @@ pointerMoveTolerance: typeof pointerMoveTolerance; | ||
* ```js | ||
* interact('#draggable').draggable(true); | ||
* interact('#draggable').draggable(true) | ||
* | ||
* var rectables = interact('rect'); | ||
* var rectables = interact('rect') | ||
* rectables | ||
@@ -48,3 +51,3 @@ * .gesturable(true) | ||
* // ... | ||
* }); | ||
* }) | ||
* ``` | ||
@@ -65,49 +68,13 @@ * | ||
*/ | ||
export declare function interact<InteractStatic>(target: Interact.Target, options?: any): import("@interactjs/core/Interactable").Interactable; | ||
export declare namespace interact { | ||
var use: typeof use; | ||
var isSet: typeof isSet; | ||
var on: typeof on; | ||
var off: typeof off; | ||
var debug: typeof debug; | ||
var getPointerAverage: (pointers: PointerEvent[] | Event[]) => { | ||
pageX: number; | ||
pageY: number; | ||
clientX: number; | ||
clientY: number; | ||
screenX: number; | ||
screenY: number; | ||
}; | ||
var getTouchBBox: (event: Event | PointerEvent[]) => { | ||
x: number; | ||
y: number; | ||
left: number; | ||
top: number; | ||
width: number; | ||
height: number; | ||
}; | ||
var getTouchDistance: (event: any, deltaSource: any) => number; | ||
var getTouchAngle: (event: any, deltaSource: any) => number; | ||
var getElementRect: typeof utils.dom.getElementRect; | ||
var getElementClientRect: typeof utils.dom.getElementClientRect; | ||
var matchesSelector: typeof utils.dom.matchesSelector; | ||
var closest: typeof utils.dom.closest; | ||
var supportsTouch: typeof supportsTouch; | ||
var supportsPointerEvent: typeof supportsPointerEvent; | ||
var stop: typeof stop; | ||
var pointerMoveTolerance: typeof pointerMoveTolerance; | ||
var addDocument: (doc: Document, options?: any) => false | void; | ||
var removeDocument: (doc: any) => void; | ||
} | ||
declare function use(plugin: Plugin): typeof interact; | ||
export declare const interact: InteractStatic; | ||
declare function use(plugin: Plugin): InteractStatic; | ||
declare function isSet(element: Element, options?: any): boolean; | ||
declare function on(type: String | Interact.EventTypes, listener: Interact.Listeners, options?: any): typeof interact; | ||
declare function off(type: any, listener: any, options: any): typeof interact; | ||
declare function on(type: string | Interact.EventTypes, listener: Interact.Listeners, options?: any): InteractStatic; | ||
declare function off(type: any, listener: any, options: any): InteractStatic; | ||
declare function debug(): Scope; | ||
declare function supportsTouch(): boolean; | ||
declare function supportsPointerEvent(): boolean; | ||
declare function stop(): typeof interact; | ||
declare function pointerMoveTolerance(newValue: any): number | typeof interact; | ||
export declare const interactExport: InteractStatic & typeof interact; | ||
declare function stop(): InteractStatic; | ||
declare function pointerMoveTolerance(newValue: any): number | InteractStatic; | ||
export { scope }; | ||
export default interactExport; | ||
export default interact; |
@@ -10,5 +10,5 @@ /** @module interact */ | ||
* ```js | ||
* interact('#draggable').draggable(true); | ||
* interact('#draggable').draggable(true) | ||
* | ||
* var rectables = interact('rect'); | ||
* var rectables = interact('rect') | ||
* rectables | ||
@@ -18,3 +18,3 @@ * .gesturable(true) | ||
* // ... | ||
* }); | ||
* }) | ||
* ``` | ||
@@ -35,3 +35,3 @@ * | ||
*/ | ||
export function interact(target, options) { | ||
export const interact = function interact(target, options) { | ||
let interactable = scope.interactables.get(target, options); | ||
@@ -43,3 +43,3 @@ if (!interactable) { | ||
return interactable; | ||
} | ||
}; | ||
scope._plugins = []; | ||
@@ -54,3 +54,3 @@ /** | ||
* @return {interact} | ||
*/ | ||
*/ | ||
interact.use = use; | ||
@@ -65,3 +65,2 @@ function use(plugin) { | ||
} | ||
; | ||
/** | ||
@@ -76,3 +75,3 @@ * Check if an element or selector has been set with the {@link interact} | ||
* passed to interact | ||
*/ | ||
*/ | ||
interact.isSet = isSet; | ||
@@ -82,3 +81,2 @@ function isSet(element, options) { | ||
} | ||
; | ||
/** | ||
@@ -128,3 +126,2 @@ * Add a global listener for an InteractEvent or adds a DOM event to `document` | ||
} | ||
; | ||
/** | ||
@@ -164,4 +161,4 @@ * Removes a global InteractEvent listener or DOM event from `document` | ||
let index; | ||
if (type in globalEvents | ||
&& (index = globalEvents[type].indexOf(listener)) !== -1) { | ||
if (type in globalEvents && | ||
(index = globalEvents[type].indexOf(listener)) !== -1) { | ||
globalEvents[type].splice(index, 1); | ||
@@ -172,6 +169,4 @@ } | ||
} | ||
; | ||
/** | ||
* Returns an object which exposes internal data | ||
* @alias module:interact.debug | ||
@@ -186,3 +181,2 @@ * | ||
} | ||
; | ||
// expose the functions used to calculate multi-touch properties | ||
@@ -206,3 +200,2 @@ interact.getPointerAverage = utils.pointer.pointerAverage; | ||
} | ||
; | ||
/** | ||
@@ -217,3 +210,2 @@ * @alias module:interact.supportsPointerEvent | ||
} | ||
; | ||
/** | ||
@@ -233,3 +225,2 @@ * Cancels all interactions (end events are not fired) | ||
} | ||
; | ||
/** | ||
@@ -252,3 +243,2 @@ * Returns or sets the distance the pointer must be moved before an action | ||
} | ||
; | ||
scope.interactables.signals.on('unset', ({ interactable }) => { | ||
@@ -265,6 +255,5 @@ scope.interactables.list.splice(scope.interactables.list.indexOf(interactable), 1); | ||
interact.removeDocument = scope.removeDocument; | ||
export const interactExport = interact; | ||
scope.interact = interactExport; | ||
scope.interact = interact; | ||
export { scope }; | ||
export default interactExport; | ||
export default interact; | ||
//# sourceMappingURL=interact.js.map |
182
interact.ts
/** @module interact */ | ||
import { Scope } from '@interactjs/core/scope'; | ||
import * as utils from '@interactjs/utils'; | ||
import browser from '@interactjs/utils/browser'; | ||
import events from '@interactjs/utils/events'; | ||
import { Options } from '@interactjs/core/defaultOptions' | ||
import Interactable from '@interactjs/core/Interactable' | ||
import { Scope } from '@interactjs/core/scope' | ||
import * as utils from '@interactjs/utils' | ||
import browser from '@interactjs/utils/browser' | ||
import events from '@interactjs/utils/events' | ||
export interface Plugin extends Partial<any>{ | ||
install ( scope: any ) : void // TODO: Add typings for scope | ||
install (scope: any): void | ||
} | ||
@@ -14,3 +16,3 @@ | ||
interface Scope { | ||
interact: typeof interactExport | ||
interact: InteractStatic | ||
_plugins: Plugin[] | ||
@@ -21,2 +23,3 @@ } | ||
export interface InteractStatic { | ||
(target: Interact.Target, options?: Options): Interactable | ||
on: typeof on | ||
@@ -44,10 +47,10 @@ pointerMoveTolerance: typeof pointerMoveTolerance | ||
const globalEvents: any = {}; | ||
const scope = new Scope(); | ||
const globalEvents: any = {} | ||
const scope = new Scope() | ||
/** | ||
* ```js | ||
* interact('#draggable').draggable(true); | ||
* interact('#draggable').draggable(true) | ||
* | ||
* var rectables = interact('rect'); | ||
* var rectables = interact('rect') | ||
* rectables | ||
@@ -57,3 +60,3 @@ * .gesturable(true) | ||
* // ... | ||
* }); | ||
* }) | ||
* ``` | ||
@@ -74,15 +77,14 @@ * | ||
*/ | ||
export function interact<InteractStatic> (target: Interact.Target, options?: any) { | ||
let interactable = scope.interactables.get(target, options); | ||
export const interact: InteractStatic = function interact (target: Interact.Target, options?: any) { | ||
let interactable = scope.interactables.get(target, options) | ||
if (!interactable) { | ||
interactable = scope.interactables.new(target, options); | ||
interactable.events.global = globalEvents; | ||
interactable = scope.interactables.new(target, options) | ||
interactable.events.global = globalEvents | ||
} | ||
return interactable; | ||
} | ||
return interactable | ||
} as InteractStatic | ||
scope._plugins = []; | ||
scope._plugins = [] | ||
@@ -97,13 +99,13 @@ /** | ||
* @return {interact} | ||
*/ | ||
interact.use = use; | ||
*/ | ||
interact.use = use | ||
function use (plugin: Plugin) { | ||
if (scope._plugins.indexOf(plugin) !== -1) { | ||
return interact; | ||
return interact | ||
} | ||
plugin.install(scope); | ||
scope._plugins.push(plugin); | ||
return interact; | ||
}; | ||
plugin.install(scope) | ||
scope._plugins.push(plugin) | ||
return interact | ||
} | ||
@@ -119,7 +121,7 @@ /** | ||
* passed to interact | ||
*/ | ||
interact.isSet = isSet; | ||
*/ | ||
interact.isSet = isSet | ||
function isSet (element: Element, options?: any) { | ||
return scope.interactables.indexOfElement(element, options && options.context) !== -1; | ||
}; | ||
return scope.interactables.indexOfElement(element, options && options.context) !== -1 | ||
} | ||
@@ -137,6 +139,6 @@ /** | ||
*/ | ||
interact.on = on; | ||
function on (type: String | Interact.EventTypes, listener: Interact.Listeners, options?) { | ||
interact.on = on | ||
function on (type: string | Interact.EventTypes, listener: Interact.Listeners, options?) { | ||
if (utils.is.string(type) && type.search(' ') !== -1) { | ||
type = type.trim().split(/ +/); | ||
type = type.trim().split(/ +/) | ||
} | ||
@@ -146,6 +148,6 @@ | ||
for (const eventType of (type as any[])) { | ||
interact.on(eventType, listener, options); | ||
interact.on(eventType, listener, options) | ||
} | ||
return interact; | ||
return interact | ||
} | ||
@@ -155,6 +157,6 @@ | ||
for (const prop in type) { | ||
interact.on(prop, type[prop], listener); | ||
interact.on(prop, (type as Interact.EventTypes)[prop], listener) | ||
} | ||
return interact; | ||
return interact | ||
} | ||
@@ -166,6 +168,6 @@ | ||
if (!globalEvents[type]) { | ||
globalEvents[type] = [listener]; | ||
globalEvents[type] = [listener] | ||
} | ||
else { | ||
globalEvents[type].push(listener); | ||
globalEvents[type].push(listener) | ||
} | ||
@@ -175,7 +177,7 @@ } | ||
else { | ||
events.add(scope.document, type, listener as Function, { options }); | ||
events.add(scope.document, type, listener as Interact.Listener, { options }) | ||
} | ||
return interact; | ||
}; | ||
return interact | ||
} | ||
@@ -194,6 +196,6 @@ /** | ||
*/ | ||
interact.off = off; | ||
interact.off = off | ||
function off (type, listener, options) { | ||
if (utils.is.string(type) && type.search(' ') !== -1) { | ||
type = type.trim().split(/ +/); | ||
type = type.trim().split(/ +/) | ||
} | ||
@@ -203,6 +205,6 @@ | ||
for (const eventType of type) { | ||
interact.off(eventType, listener, options); | ||
interact.off(eventType, listener, options) | ||
} | ||
return interact; | ||
return interact | ||
} | ||
@@ -212,26 +214,25 @@ | ||
for (const prop in type) { | ||
interact.off(prop, type[prop], listener); | ||
interact.off(prop, type[prop], listener) | ||
} | ||
return interact; | ||
return interact | ||
} | ||
if (!utils.arr.contains(scope.actions.eventTypes, type)) { | ||
events.remove(scope.document, type, listener, options); | ||
events.remove(scope.document, type, listener, options) | ||
} | ||
else { | ||
let index; | ||
let index | ||
if (type in globalEvents | ||
&& (index = globalEvents[type].indexOf(listener)) !== -1) { | ||
globalEvents[type].splice(index, 1); | ||
if (type in globalEvents && | ||
(index = globalEvents[type].indexOf(listener)) !== -1) { | ||
globalEvents[type].splice(index, 1) | ||
} | ||
} | ||
return interact; | ||
}; | ||
return interact | ||
} | ||
/** | ||
* Returns an object which exposes internal data | ||
* @alias module:interact.debug | ||
@@ -242,17 +243,17 @@ * | ||
*/ | ||
interact.debug = debug; | ||
interact.debug = debug | ||
function debug () { | ||
return scope; | ||
}; | ||
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.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; | ||
interact.getElementRect = utils.dom.getElementRect | ||
interact.getElementClientRect = utils.dom.getElementClientRect | ||
interact.matchesSelector = utils.dom.matchesSelector | ||
interact.closest = utils.dom.closest | ||
@@ -264,6 +265,6 @@ /** | ||
*/ | ||
interact.supportsTouch = supportsTouch; | ||
interact.supportsTouch = supportsTouch | ||
function supportsTouch () { | ||
return browser.supportsTouch; | ||
}; | ||
return browser.supportsTouch | ||
} | ||
@@ -275,6 +276,6 @@ /** | ||
*/ | ||
interact.supportsPointerEvent = supportsPointerEvent; | ||
interact.supportsPointerEvent = supportsPointerEvent | ||
function supportsPointerEvent () { | ||
return browser.supportsPointerEvent; | ||
}; | ||
return browser.supportsPointerEvent | ||
} | ||
@@ -288,10 +289,10 @@ /** | ||
*/ | ||
interact.stop = stop; | ||
interact.stop = stop | ||
function stop () { | ||
for (const interaction of scope.interactions.list) { | ||
interaction.stop(); | ||
interaction.stop() | ||
} | ||
return interact; | ||
}; | ||
return interact | ||
} | ||
@@ -307,15 +308,15 @@ /** | ||
*/ | ||
interact.pointerMoveTolerance = pointerMoveTolerance; | ||
interact.pointerMoveTolerance = pointerMoveTolerance | ||
function pointerMoveTolerance (newValue) { | ||
if (utils.is.number(newValue)) { | ||
scope.interactions.pointerMoveTolerance = newValue; | ||
scope.interactions.pointerMoveTolerance = newValue | ||
return interact; | ||
return interact | ||
} | ||
return scope.interactions.pointerMoveTolerance; | ||
}; | ||
return scope.interactions.pointerMoveTolerance | ||
} | ||
scope.interactables.signals.on('unset', ({ interactable }) => { | ||
scope.interactables.list.splice(scope.interactables.list.indexOf(interactable), 1); | ||
scope.interactables.list.splice(scope.interactables.list.indexOf(interactable), 1) | ||
@@ -325,14 +326,13 @@ // Stop related interactions when an Interactable is unset | ||
if (interaction.target === interactable && interaction.interacting() && interaction._ending) { | ||
interaction.stop(); | ||
interaction.stop() | ||
} | ||
} | ||
}); | ||
}) | ||
interact.addDocument = scope.addDocument; | ||
interact.removeDocument = scope.removeDocument; | ||
interact.addDocument = scope.addDocument | ||
interact.removeDocument = scope.removeDocument | ||
export const interactExport = interact as InteractStatic & typeof interact | ||
scope.interact = interactExport; | ||
scope.interact = interact | ||
export { scope }; | ||
export default interactExport; | ||
export { scope } | ||
export default interact |
{ | ||
"name": "@interactjs/interact", | ||
"version": "1.4.0-alpha.20+sha.ce0da21", | ||
"version": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"peerDependencies": { | ||
"@interactjs/actions": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/auto-scroll": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/auto-start": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/core": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/inertia": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/modifiers": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/pointer-events": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/reflow": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/utils": "1.4.0-alpha.20+sha.ce0da21" | ||
"@interactjs/actions": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/auto-scroll": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/auto-start": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/core": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/inertia": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/modifiers": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/pointer-events": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/reflow": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/utils": "1.4.0-alpha.21+sha.cdc1d5f" | ||
}, | ||
"devDependencies": { | ||
"@interactjs/_dev": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/actions": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/auto-scroll": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/auto-start": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/core": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/inertia": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/modifiers": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/pointer-events": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/reflow": "1.4.0-alpha.20+sha.ce0da21", | ||
"@interactjs/utils": "1.4.0-alpha.20+sha.ce0da21" | ||
"@interactjs/_dev": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/actions": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/auto-scroll": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/auto-start": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/core": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/inertia": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/modifiers": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/pointer-events": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/reflow": "1.4.0-alpha.21+sha.cdc1d5f", | ||
"@interactjs/utils": "1.4.0-alpha.21+sha.cdc1d5f" | ||
}, | ||
@@ -27,0 +27,0 @@ "publishConfig": { |
@@ -1,61 +0,61 @@ | ||
import { jsdom } from '@interactjs/_dev/test/domator'; | ||
import test from '@interactjs/_dev/test/test'; | ||
import { default as interact, scope } from '../interact'; | ||
import interactions from '@interactjs/core/interactions'; | ||
import { jsdom } from '@interactjs/_dev/test/domator' | ||
import test from '@interactjs/_dev/test/test' | ||
import interact, { scope } from '../interact' | ||
import interactions from '@interactjs/core/interactions' | ||
test('interact export', t => { | ||
scope.init(jsdom('').defaultView); | ||
interactions.install(scope); | ||
scope.init(jsdom('').defaultView) | ||
interactions.install(scope) | ||
const interactable1 = interact('selector'); | ||
const interactable1 = interact('selector') | ||
t.assert(interactable1 instanceof scope.Interactable, | ||
'interact function returns Interactable instance'); | ||
'interact function returns Interactable instance') | ||
t.equal(interact('selector'), interactable1, | ||
'same interactable is returned with same target and context'); | ||
'same interactable is returned with same target and context') | ||
t.equal(scope.interactables.list.length, 1, | ||
'new interactables are added to list'); | ||
'new interactables are added to list') | ||
interactable1.unset(); | ||
interactable1.unset() | ||
t.equal(scope.interactables.list.length, 0, | ||
'unset interactables are removed'); | ||
'unset interactables are removed') | ||
const constructsUniqueMessage = | ||
'unique contexts make unique interactables with identical targets'; | ||
'unique contexts make unique interactables with identical targets' | ||
const doc1 = jsdom(''); | ||
const doc2 = jsdom(''); | ||
const doc1 = jsdom('') | ||
const doc2 = jsdom('') | ||
const results = [ | ||
['repeat' , doc1], | ||
['repeat' , doc2], | ||
[doc1 , doc1], | ||
[doc2.body , doc2], | ||
['repeat', doc1], | ||
['repeat', doc2], | ||
[doc1, doc1], | ||
[doc2.body, doc2], | ||
].reduce((acc, [target, context]) => { | ||
const interactable = interact(target, { context }); | ||
const interactable = interact(target, { context }) | ||
if (acc.includes(interactable)) { | ||
t.fail(constructsUniqueMessage); | ||
t.fail(constructsUniqueMessage) | ||
} | ||
acc.push({ interactable, target, context }); | ||
return acc; | ||
}, []); | ||
acc.push({ interactable, target, context }) | ||
return acc | ||
}, []) | ||
t.pass(constructsUniqueMessage); | ||
t.pass(constructsUniqueMessage) | ||
const getsUniqueMessage = | ||
'interactions.get returns correct result with identical targets and different contexts'; | ||
'interactions.get returns correct result with identical targets and different contexts' | ||
for (const { interactable, target, context } of results) { | ||
if (scope.interactables.get(target, { context }) !== interactable) { | ||
t.fail(getsUniqueMessage); | ||
t.fail(getsUniqueMessage) | ||
} | ||
} | ||
t.pass(getsUniqueMessage); | ||
t.pass(getsUniqueMessage) | ||
scope.interactables.list.forEach(i => i.unset()); | ||
scope.interactables.list.forEach(i => i.unset()) | ||
delete scope.Interactable; | ||
delete scope.Interactable | ||
t.end(); | ||
}); | ||
t.end() | ||
}) |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
33178
11
741