@interactjs/utils
Advanced tools
Comparing version 1.6.3 to 1.7.0
30
arr.js
export function contains(array, target) { | ||
return array.indexOf(target) !== -1; | ||
return array.indexOf(target) !== -1; | ||
} | ||
export function remove(array, target) { | ||
return array.splice(array.indexOf(target), 1); | ||
return array.splice(array.indexOf(target), 1); | ||
} | ||
export function merge(target, source) { | ||
for (const item of source) { | ||
target.push(item); | ||
} | ||
return target; | ||
for (const item of source) { | ||
target.push(item); | ||
} | ||
return target; | ||
} | ||
export function from(source) { | ||
return merge([], source); | ||
return merge([], source); | ||
} | ||
export function findIndex(array, func) { | ||
for (let i = 0; i < array.length; i++) { | ||
if (func(array[i], i, array)) { | ||
return i; | ||
} | ||
for (let i = 0; i < array.length; i++) { | ||
if (func(array[i], i, array)) { | ||
return i; | ||
} | ||
return -1; | ||
} | ||
return -1; | ||
} | ||
export function find(array, func) { | ||
return array[findIndex(array, func)]; | ||
return array[findIndex(array, func)]; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiYXJyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sVUFBVSxRQUFRLENBQUUsS0FBSyxFQUFFLE1BQU07SUFDckMsT0FBTyxLQUFLLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFBO0FBQ3JDLENBQUM7QUFFRCxNQUFNLFVBQVUsTUFBTSxDQUFFLEtBQUssRUFBRSxNQUFNO0lBQ25DLE9BQU8sS0FBSyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFBO0FBQy9DLENBQUM7QUFFRCxNQUFNLFVBQVUsS0FBSyxDQUFFLE1BQU0sRUFBRSxNQUFNO0lBQ25DLEtBQUssTUFBTSxJQUFJL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IHtcbiAgZm9yIChjb25zdCBpdGVtIG9mIHNvdXJjZSkge1xuICAgIHRhcmdldC5wdXNoKGl0ZW0pXG4gIH1cblxuICByZXR1cm4gdGFyZ2V0XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBmcm9tIChzb3VyY2UpIHtcbiAgcmV0dXJuIG1lcmdlKFtdLCBzb3VyY2UpXG59XG5cbmV4cG9ydCBmdW5jdGlvbiBmaW5kSW5kZXggKGFycmF5LCBmdW5jKSB7XG4gIGZvciAobGV0IGkgPSAwOyBpIDwgYXJyYXkubGVuZ3RoOyBpKyspIHtcbiAgICBpZiAoZnVuYyhhcnJheVtpXSwgaSwgYXJyYXkpKSB7XG4gICAgICByZXR1cm4gaVxuICAgIH1cbiAgfVxuXG4gIHJldHVybiAtMVxufVxuXG5leHBvcnQgZnVuY3Rpb24gZmluZCAoYXJyYXksIGZ1bmMpIHtcbiAgcmV0dXJuIGFycmF5W2ZpbmRJbmRleChhcnJheSwgZnVuYyldXG59XG4iXX0= | ||
//# sourceMappingURL=arr.js.map |
108
browser.js
@@ -1,66 +0,52 @@ | ||
import domObjects from './domObjects'; | ||
import * as is from './is'; | ||
import win from './window'; | ||
import domObjects from "./domObjects.js"; | ||
import * as is from "./is.js"; | ||
import win from "./window.js"; | ||
const browser = { | ||
init, | ||
supportsTouch: null, | ||
supportsPointerEvent: null, | ||
isIOS7: null, | ||
isIOS: null, | ||
isIe9: null, | ||
isOperaMobile: null, | ||
prefixedMatchesSelector: null, | ||
pEventTypes: null, | ||
wheelEvent: null, | ||
init, | ||
supportsTouch: null, | ||
supportsPointerEvent: null, | ||
isIOS7: null, | ||
isIOS: null, | ||
isIe9: null, | ||
isOperaMobile: null, | ||
prefixedMatchesSelector: null, | ||
pEventTypes: null, | ||
wheelEvent: null | ||
}; | ||
function init(window) { | ||
const Element = domObjects.Element; | ||
const navigator = win.window.navigator; | ||
// Does the browser support touch input? | ||
browser.supportsTouch = ('ontouchstart' in window) || | ||
(is.func(window.DocumentTouch) && domObjects.document instanceof window.DocumentTouch); | ||
// Does the browser support PointerEvents | ||
browser.supportsPointerEvent = navigator.pointerEnabled !== false && !!domObjects.PointerEvent; | ||
browser.isIOS = (/iP(hone|od|ad)/.test(navigator.platform)); | ||
// scrolling doesn't change the result of getClientRects on iOS 7 | ||
browser.isIOS7 = (/iP(hone|od|ad)/.test(navigator.platform) && | ||
/OS 7[^\d]/.test(navigator.appVersion)); | ||
browser.isIe9 = /MSIE 9/.test(navigator.userAgent); | ||
// Opera Mobile must be handled differently | ||
browser.isOperaMobile = (navigator.appName === 'Opera' && | ||
browser.supportsTouch && | ||
/Presto/.test(navigator.userAgent)); | ||
// prefix matchesSelector | ||
browser.prefixedMatchesSelector = 'matches' in Element.prototype | ||
? 'matches' | ||
: 'webkitMatchesSelector' in Element.prototype | ||
? 'webkitMatchesSelector' | ||
: 'mozMatchesSelector' in Element.prototype | ||
? 'mozMatchesSelector' | ||
: 'oMatchesSelector' in Element.prototype | ||
? 'oMatchesSelector' | ||
: 'msMatchesSelector'; | ||
browser.pEventTypes = (browser.supportsPointerEvent | ||
? (domObjects.PointerEvent === window.MSPointerEvent | ||
? { | ||
up: 'MSPointerUp', | ||
down: 'MSPointerDown', | ||
over: 'mouseover', | ||
out: 'mouseout', | ||
move: 'MSPointerMove', | ||
cancel: 'MSPointerCancel', | ||
} | ||
: { | ||
up: 'pointerup', | ||
down: 'pointerdown', | ||
over: 'pointerover', | ||
out: 'pointerout', | ||
move: 'pointermove', | ||
cancel: 'pointercancel', | ||
}) | ||
: null); | ||
// because Webkit and Opera still use 'mousewheel' event type | ||
browser.wheelEvent = 'onmousewheel' in domObjects.document ? 'mousewheel' : 'wheel'; | ||
const Element = domObjects.Element; | ||
const navigator = win.window.navigator; // Does the browser support touch input? | ||
browser.supportsTouch = 'ontouchstart' in window || is.func(window.DocumentTouch) && domObjects.document instanceof window.DocumentTouch; // Does the browser support PointerEvents | ||
browser.supportsPointerEvent = navigator.pointerEnabled !== false && !!domObjects.PointerEvent; | ||
browser.isIOS = /iP(hone|od|ad)/.test(navigator.platform); // scrolling doesn't change the result of getClientRects on iOS 7 | ||
browser.isIOS7 = /iP(hone|od|ad)/.test(navigator.platform) && /OS 7[^\d]/.test(navigator.appVersion); | ||
browser.isIe9 = /MSIE 9/.test(navigator.userAgent); // Opera Mobile must be handled differently | ||
browser.isOperaMobile = navigator.appName === 'Opera' && browser.supportsTouch && /Presto/.test(navigator.userAgent); // prefix matchesSelector | ||
browser.prefixedMatchesSelector = 'matches' in Element.prototype ? 'matches' : 'webkitMatchesSelector' in Element.prototype ? 'webkitMatchesSelector' : 'mozMatchesSelector' in Element.prototype ? 'mozMatchesSelector' : 'oMatchesSelector' in Element.prototype ? 'oMatchesSelector' : 'msMatchesSelector'; | ||
browser.pEventTypes = browser.supportsPointerEvent ? domObjects.PointerEvent === window.MSPointerEvent ? { | ||
up: 'MSPointerUp', | ||
down: 'MSPointerDown', | ||
over: 'mouseover', | ||
out: 'mouseout', | ||
move: 'MSPointerMove', | ||
cancel: 'MSPointerCancel' | ||
} : { | ||
up: 'pointerup', | ||
down: 'pointerdown', | ||
over: 'pointerover', | ||
out: 'pointerout', | ||
move: 'pointermove', | ||
cancel: 'pointercancel' | ||
} : null; // because Webkit and Opera still use 'mousewheel' event type | ||
browser.wheelEvent = 'onmousewheel' in domObjects.document ? 'mousewheel' : 'wheel'; | ||
} | ||
export default browser; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvd3Nlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImJyb3dzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxVQUFVLE1BQU0sY0FBYyxDQUFBO0FBQ3JDLE9BQU8sS0FBSyxFQUFFLE1BQU0sTUFBTSxDQUFBO0FBQzFCLE9BQU8sR0FBRyxNQUFNLFVBQVUsQ0FBQTtBQUUxQixNQUFNLE9BQU8sR0F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W50ZXJVcCcsXG4gICAgICAgIGRvd246ICAgJ01TUG9pbnRlckRvd24nLFxuICAgICAgICBvdmVyOiAgICdtb3VzZW92ZXInLFxuICAgICAgICBvdXQ6ICAgICdtb3VzZW91dCcsXG4gICAgICAgIG1vdmU6ICAgJ01TUG9pbnRlck1vdmUnLFxuICAgICAgICBjYW5jZWw6ICdNU1BvaW50ZXJDYW5jZWwnLFxuICAgICAgfVxuICAgICAgOiB7XG4gICAgICAgIHVwOiAgICAgJ3BvaW50ZXJ1cCcsXG4gICAgICAgIGRvd246ICAgJ3BvaW50ZXJkb3duJyxcbiAgICAgICAgb3ZlcjogICAncG9pbnRlcm92ZXInLFxuICAgICAgICBvdXQ6ICAgICdwb2ludGVyb3V0JyxcbiAgICAgICAgbW92ZTogICAncG9pbnRlcm1vdmUnLFxuICAgICAgICBjYW5jZWw6ICdwb2ludGVyY2FuY2VsJyxcbiAgICAgIH0pXG4gICAgOiBudWxsKVxuXG4gIC8vIGJlY2F1c2UgV2Via2l0IGFuZCBPcGVyYSBzdGlsbCB1c2UgJ21vdXNld2hlZWwnIGV2ZW50IHR5cGVcbiAgYnJvd3Nlci53aGVlbEV2ZW50ID0gJ29ubW91c2V3aGVlbCcgaW4gZG9tT2JqZWN0cy5kb2N1bWVudCA/ICdtb3VzZXdoZWVsJyA6ICd3aGVlbCdcbn1cblxuZXhwb3J0IGRlZmF1bHQgYnJvd3NlclxuIl19 | ||
//# sourceMappingURL=browser.js.map |
33
clone.js
@@ -1,19 +0,20 @@ | ||
import * as arr from './arr'; | ||
import * as is from './is'; | ||
import * as arr from "./arr.js"; | ||
import * as is from "./is.js"; | ||
export default function clone(source) { | ||
const dest = {}; | ||
for (const prop in source) { | ||
const value = source[prop]; | ||
if (is.plainObject(value)) { | ||
dest[prop] = clone(value); | ||
} | ||
else if (is.array(value)) { | ||
dest[prop] = arr.from(value); | ||
} | ||
else { | ||
dest[prop] = value; | ||
} | ||
const dest = {}; | ||
for (const prop in source) { | ||
const value = source[prop]; | ||
if (is.plainObject(value)) { | ||
dest[prop] = clone(value); | ||
} else if (is.array(value)) { | ||
dest[prop] = arr.from(value); | ||
} else { | ||
dest[prop] = value; | ||
} | ||
return dest; | ||
} | ||
return dest; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xvbmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJjbG9uZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssR0FBRyxNQUFNLE9BQU8sQ0FBQTtBQUM1QixPQUFPLEtBQUssRUFBRSxNQUFNLE1BQU0sQ0FBQTtBQUUxQixNQUFNLENBQUMsT0FBTyxVQUFVLEtBQUssQ0FBb0MsTUFBUztJQUN4RSxNQUFNLElBQUksR0FBRyxFQUFnQixDQUFBO0lBRTdCLEtBQUssTUFBTSxJQUFJLElBQUksTUFBTSxFQUFFO1FBQ3pCLE1BQU0sS0FBSyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUUxQixJQUFJLEVBQUUsQ0FBQyxXQUFXLENBQUMsS0FBSyxDQUFDLEVBQUU7WUFDekIsSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLEtBQUssQ0FBQyxLQUFLLENBQVEsQ0FBQTtTQUNqQzthQUNJLElBQUksRUFBRSxDQUFDLEtBQUssQ0FBQyxLQUFLLENBQUMsRUFBRTtZQUN4QixJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsR0FBRyxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsQ0FBQTtTQUM3QjthQUNJO1lBQ0gsSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLEtBQUssQ0FBQTtTQUNuQjtLQUNGO0lBRUQsT0FBTyxJQUFJLENBQUE7QUFDYixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0ICogYXMgYXJyIGZyb20gJy4vYXJyJ1xuaW1wb3J0ICogYXMgaXMgZnJvbSAnLi9pcydcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gY2xvbmU8VCBleHRlbmRzIHsgW2tleTogc3RyaW5nXTogYW55IH0+IChzb3VyY2U6IFQpOiBQYXJ0aWFsPFQ+IHtcbiAgY29uc3QgZGVzdCA9IHt9IGFzIFBhcnRpYWw8VD5cblxuICBmb3IgKGNvbnN0IHByb3AgaW4gc291cmNlKSB7XG4gICAgY29uc3QgdmFsdWUgPSBzb3VyY2VbcHJvcF1cblxuICAgIGlmIChpcy5wbGFpbk9iamVjdCh2YWx1ZSkpIHtcbiAgICAgIGRlc3RbcHJvcF0gPSBjbG9uZSh2YWx1ZSkgYXMgYW55XG4gICAgfVxuICAgIGVsc2UgaWYgKGlzLmFycmF5KHZhbHVlKSkge1xuICAgICAgZGVzdFtwcm9wXSA9IGFyci5mcm9tKHZhbHVlKVxuICAgIH1cbiAgICBlbHNlIHtcbiAgICAgIGRlc3RbcHJvcF0gPSB2YWx1ZVxuICAgIH1cbiAgfVxuXG4gIHJldHVybiBkZXN0XG59XG4iXX0= | ||
//# sourceMappingURL=clone.js.map |
const domObjects = { | ||
init, | ||
document: null, | ||
DocumentFragment: null, | ||
SVGElement: null, | ||
SVGSVGElement: null, | ||
// eslint-disable-next-line no-undef | ||
SVGElementInstance: null, | ||
Element: null, | ||
HTMLElement: null, | ||
Event: null, | ||
Touch: null, | ||
PointerEvent: null, | ||
init, | ||
document: null, | ||
DocumentFragment: null, | ||
SVGElement: null, | ||
SVGSVGElement: null, | ||
// eslint-disable-next-line no-undef | ||
SVGElementInstance: null, | ||
Element: null, | ||
HTMLElement: null, | ||
Event: null, | ||
Touch: null, | ||
PointerEvent: null | ||
}; | ||
function blank() { } | ||
function blank() {} | ||
export default domObjects; | ||
function init(window) { | ||
const win = window; | ||
domObjects.document = win.document; | ||
domObjects.DocumentFragment = win.DocumentFragment || blank; | ||
domObjects.SVGElement = win.SVGElement || blank; | ||
domObjects.SVGSVGElement = win.SVGSVGElement || blank; | ||
domObjects.SVGElementInstance = win.SVGElementInstance || blank; | ||
domObjects.Element = win.Element || blank; | ||
domObjects.HTMLElement = win.HTMLElement || domObjects.Element; | ||
domObjects.Event = win.Event; | ||
domObjects.Touch = win.Touch || blank; | ||
domObjects.PointerEvent = (win.PointerEvent || win.MSPointerEvent); | ||
const win = window; | ||
domObjects.document = win.document; | ||
domObjects.DocumentFragment = win.DocumentFragment || blank; | ||
domObjects.SVGElement = win.SVGElement || blank; | ||
domObjects.SVGSVGElement = win.SVGSVGElement || blank; | ||
domObjects.SVGElementInstance = win.SVGElementInstance || blank; | ||
domObjects.Element = win.Element || blank; | ||
domObjects.HTMLElement = win.HTMLElement || domObjects.Element; | ||
domObjects.Event = win.Event; | ||
domObjects.Touch = win.Touch || blank; | ||
domObjects.PointerEvent = win.PointerEvent || win.MSPointerEvent; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9tT2JqZWN0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImRvbU9iamVjdHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsTUFBTSxVQUFVLEdBYWhCO0lBQ0UsSUFBSTtJQUNKLFFBQVEsRUFBRSxJQUFXO0lBQ3JCLGdCQUFnQixFQUFFLElBQVc7SUFDN0IsVUFBVSxFQUFFLElBQVc7SUFDdkIsYUFBYSxFQUFFLElBQVc7SUFDMUIsb0NBQW9DO0lBQ3BDLGtCQUFrQixFQUFFLElBQVc7SUFDL0IsT0FBTyxFQUFFLElBQVc7SUFDcEIsV0FBVyxFQUFFLElBQVc7SUFDeEIsS0FBSyxFQUFFLElBQVc7SUFDbEIsS0FBSyxFQUFFLElBQVc7SUFDbEIsWUFBWSxFQUFFLElBQVc7Q0FDMUIsQ0FBQTtBQUVELFNBQVMsS0FBSyxLQUFLLENBQUM7QUFFcEIsZUFBZSxVQUFVLENBQUE7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ZWN0cy5TVkdFbGVtZW50ICAgICAgICAgPSB3aW4uU1ZHRWxlbWVudCAgICAgICAgIHx8IGJsYW5rXG4gIGRvbU9iamVjdHMuU1ZHU1ZHRWxlbWVudCAgICAgID0gd2luLlNWR1NWR0VsZW1lbnQgICAgICB8fCBibGFua1xuICBkb21PYmplY3RzLlNWR0VsZW1lbnRJbnN0YW5jZSA9IHdpbi5TVkdFbGVtZW50SW5zdGFuY2UgfHwgYmxhbmtcbiAgZG9tT2JqZWN0cy5FbGVtZW50ICAgICAgICAgICAgPSB3aW4uRWxlbWVudCAgICAgICAgICAgIHx8IGJsYW5rXG4gIGRvbU9iamVjdHMuSFRNTEVsZW1lbnQgICAgICAgID0gd2luLkhUTUxFbGVtZW50ICAgICAgICB8fCBkb21PYmplY3RzLkVsZW1lbnRcblxuICBkb21PYmplY3RzLkV2ZW50ICAgICAgICA9IHdpbi5FdmVudFxuICBkb21PYmplY3RzLlRvdWNoICAgICAgICA9IHdpbi5Ub3VjaCB8fCBibGFua1xuICBkb21PYmplY3RzLlBvaW50ZXJFdmVudCA9ICh3aW4uUG9pbnRlckV2ZW50IHx8IHdpbi5NU1BvaW50ZXJFdmVudClcbn1cbiJdfQ== | ||
//# sourceMappingURL=domObjects.js.map |
@@ -1,2 +0,2 @@ | ||
export declare function nodeContains(parent: Node, child: Node): boolean; | ||
export declare function nodeContains(parent: Node | Interact.EventTarget, child: Node | Interact.EventTarget): boolean; | ||
export declare function closest(element: any, selector: any): import("../types/types").Element; | ||
@@ -3,0 +3,0 @@ export declare function parentNode(node: any): any; |
362
domUtils.js
@@ -1,200 +0,222 @@ | ||
import browser from './browser'; | ||
import domObjects from './domObjects'; | ||
import * as is from './is'; | ||
import win, { getWindow } from './window'; | ||
import browser from "./browser.js"; | ||
import domObjects from "./domObjects.js"; | ||
import * as is from "./is.js"; | ||
import win, { getWindow } from "./window.js"; | ||
export function nodeContains(parent, child) { | ||
while (child) { | ||
if (child === parent) { | ||
return true; | ||
} | ||
child = child.parentNode; | ||
while (child) { | ||
if (child === parent) { | ||
return true; | ||
} | ||
return false; | ||
child = child.parentNode; | ||
} | ||
return false; | ||
} | ||
export function closest(element, selector) { | ||
while (is.element(element)) { | ||
if (matchesSelector(element, selector)) { | ||
return element; | ||
} | ||
element = parentNode(element); | ||
while (is.element(element)) { | ||
if (matchesSelector(element, selector)) { | ||
return element; | ||
} | ||
return null; | ||
element = parentNode(element); | ||
} | ||
return null; | ||
} | ||
export function parentNode(node) { | ||
let parent = node.parentNode; | ||
if (is.docFrag(parent)) { | ||
// skip past #shado-root fragments | ||
// tslint:disable-next-line | ||
while ((parent = parent.host) && is.docFrag(parent)) { | ||
continue; | ||
} | ||
return parent; | ||
let parent = node.parentNode; | ||
if (is.docFrag(parent)) { | ||
// skip past #shado-root fragments | ||
// tslint:disable-next-line | ||
while ((parent = parent.host) && is.docFrag(parent)) { | ||
continue; | ||
} | ||
return parent; | ||
} | ||
return parent; | ||
} | ||
export function matchesSelector(element, selector) { | ||
// remove /deep/ from selectors if shadowDOM polyfill is used | ||
if (win.window !== win.realWindow) { | ||
selector = selector.replace(/\/deep\//g, ' '); | ||
} | ||
return element[browser.prefixedMatchesSelector](selector); | ||
// remove /deep/ from selectors if shadowDOM polyfill is used | ||
if (win.window !== win.realWindow) { | ||
selector = selector.replace(/\/deep\//g, ' '); | ||
} | ||
return element[browser.prefixedMatchesSelector](selector); | ||
} | ||
const getParent = el => el.parentNode ? el.parentNode : el.host; | ||
// Test for the element that's "above" all other qualifiers | ||
const getParent = el => el.parentNode ? el.parentNode : el.host; // Test for the element that's "above" all other qualifiers | ||
export function indexOfDeepestElement(elements) { | ||
let deepestZoneParents = []; | ||
let deepestZone = elements[0]; | ||
let index = deepestZone ? 0 : -1; | ||
let i; | ||
let n; | ||
for (i = 1; i < elements.length; i++) { | ||
const dropzone = elements[i]; | ||
// an element might belong to multiple selector dropzones | ||
if (!dropzone || dropzone === deepestZone) { | ||
continue; | ||
} | ||
if (!deepestZone) { | ||
deepestZone = dropzone; | ||
index = i; | ||
continue; | ||
} | ||
// check if the deepest or current are document.documentElement or document.rootElement | ||
// - if the current dropzone is, do nothing and continue | ||
if (dropzone.parentNode === dropzone.ownerDocument) { | ||
continue; | ||
} | ||
// - if deepest is, update with the current dropzone and continue to next | ||
else if (deepestZone.parentNode === dropzone.ownerDocument) { | ||
deepestZone = dropzone; | ||
index = i; | ||
continue; | ||
} | ||
// compare zIndex of siblings | ||
if (dropzone.parentNode === deepestZone.parentNode) { | ||
const deepestZIndex = parseInt(getWindow(deepestZone).getComputedStyle(deepestZone).zIndex, 10) || 0; | ||
const dropzoneZIndex = parseInt(getWindow(dropzone).getComputedStyle(dropzone).zIndex, 10) || 0; | ||
if (dropzoneZIndex >= deepestZIndex) { | ||
deepestZone = dropzone; | ||
index = i; | ||
} | ||
continue; | ||
} | ||
// populate the ancestry array for the latest deepest dropzone | ||
if (!deepestZoneParents.length) { | ||
let parent = deepestZone; | ||
let parentParent; | ||
while ((parentParent = getParent(parent)) && parentParent !== parent.ownerDocument) { | ||
deepestZoneParents.unshift(parent); | ||
parent = parentParent; | ||
} | ||
} | ||
let parent; | ||
// if this element is an svg element and the current deepest is an | ||
// HTMLElement | ||
if (deepestZone instanceof domObjects.HTMLElement && | ||
dropzone instanceof domObjects.SVGElement && | ||
!(dropzone instanceof domObjects.SVGSVGElement)) { | ||
if (dropzone === deepestZone.parentNode) { | ||
continue; | ||
} | ||
parent = dropzone.ownerSVGElement; | ||
} | ||
else { | ||
parent = dropzone; | ||
} | ||
const dropzoneParents = []; | ||
while (parent.parentNode !== parent.ownerDocument) { | ||
dropzoneParents.unshift(parent); | ||
parent = getParent(parent); | ||
} | ||
n = 0; | ||
// get (position of last common ancestor) + 1 | ||
while (dropzoneParents[n] && dropzoneParents[n] === deepestZoneParents[n]) { | ||
n++; | ||
} | ||
const parents = [ | ||
dropzoneParents[n - 1], | ||
dropzoneParents[n], | ||
deepestZoneParents[n], | ||
]; | ||
let child = parents[0].lastChild; | ||
while (child) { | ||
if (child === parents[1]) { | ||
deepestZone = dropzone; | ||
index = i; | ||
deepestZoneParents = dropzoneParents; | ||
break; | ||
} | ||
else if (child === parents[2]) { | ||
break; | ||
} | ||
child = child.previousSibling; | ||
} | ||
let deepestZoneParents = []; | ||
let deepestZone = elements[0]; | ||
let index = deepestZone ? 0 : -1; | ||
let i; | ||
let n; | ||
for (i = 1; i < elements.length; i++) { | ||
const dropzone = elements[i]; // an element might belong to multiple selector dropzones | ||
if (!dropzone || dropzone === deepestZone) { | ||
continue; | ||
} | ||
return index; | ||
if (!deepestZone) { | ||
deepestZone = dropzone; | ||
index = i; | ||
continue; | ||
} // check if the deepest or current are document.documentElement or document.rootElement | ||
// - if the current dropzone is, do nothing and continue | ||
if (dropzone.parentNode === dropzone.ownerDocument) { | ||
continue; | ||
} // - if deepest is, update with the current dropzone and continue to next | ||
else if (deepestZone.parentNode === dropzone.ownerDocument) { | ||
deepestZone = dropzone; | ||
index = i; | ||
continue; | ||
} // compare zIndex of siblings | ||
if (dropzone.parentNode === deepestZone.parentNode) { | ||
const deepestZIndex = parseInt(getWindow(deepestZone).getComputedStyle(deepestZone).zIndex, 10) || 0; | ||
const dropzoneZIndex = parseInt(getWindow(dropzone).getComputedStyle(dropzone).zIndex, 10) || 0; | ||
if (dropzoneZIndex >= deepestZIndex) { | ||
deepestZone = dropzone; | ||
index = i; | ||
} | ||
continue; | ||
} // populate the ancestry array for the latest deepest dropzone | ||
if (!deepestZoneParents.length) { | ||
let parent = deepestZone; | ||
let parentParent; | ||
while ((parentParent = getParent(parent)) && parentParent !== parent.ownerDocument) { | ||
deepestZoneParents.unshift(parent); | ||
parent = parentParent; | ||
} | ||
} | ||
let parent; // if this element is an svg element and the current deepest is an | ||
// HTMLElement | ||
if (deepestZone instanceof domObjects.HTMLElement && dropzone instanceof domObjects.SVGElement && !(dropzone instanceof domObjects.SVGSVGElement)) { | ||
if (dropzone === deepestZone.parentNode) { | ||
continue; | ||
} | ||
parent = dropzone.ownerSVGElement; | ||
} else { | ||
parent = dropzone; | ||
} | ||
const dropzoneParents = []; | ||
while (parent.parentNode !== parent.ownerDocument) { | ||
dropzoneParents.unshift(parent); | ||
parent = getParent(parent); | ||
} | ||
n = 0; // get (position of last common ancestor) + 1 | ||
while (dropzoneParents[n] && dropzoneParents[n] === deepestZoneParents[n]) { | ||
n++; | ||
} | ||
const parents = [dropzoneParents[n - 1], dropzoneParents[n], deepestZoneParents[n]]; | ||
let child = parents[0].lastChild; | ||
while (child) { | ||
if (child === parents[1]) { | ||
deepestZone = dropzone; | ||
index = i; | ||
deepestZoneParents = dropzoneParents; | ||
break; | ||
} else if (child === parents[2]) { | ||
break; | ||
} | ||
child = child.previousSibling; | ||
} | ||
} | ||
return index; | ||
} | ||
export function matchesUpTo(element, selector, limit) { | ||
while (is.element(element)) { | ||
if (matchesSelector(element, selector)) { | ||
return true; | ||
} | ||
element = parentNode(element); | ||
if (element === limit) { | ||
return matchesSelector(element, selector); | ||
} | ||
while (is.element(element)) { | ||
if (matchesSelector(element, selector)) { | ||
return true; | ||
} | ||
return false; | ||
element = parentNode(element); | ||
if (element === limit) { | ||
return matchesSelector(element, selector); | ||
} | ||
} | ||
return false; | ||
} | ||
export function getActualElement(element) { | ||
return (element instanceof domObjects.SVGElementInstance | ||
? element.correspondingUseElement | ||
: element); | ||
return element instanceof domObjects.SVGElementInstance ? element.correspondingUseElement : element; | ||
} | ||
export function getScrollXY(relevantWindow) { | ||
relevantWindow = relevantWindow || win.window; | ||
return { | ||
x: relevantWindow.scrollX || relevantWindow.document.documentElement.scrollLeft, | ||
y: relevantWindow.scrollY || relevantWindow.document.documentElement.scrollTop, | ||
}; | ||
relevantWindow = relevantWindow || win.window; | ||
return { | ||
x: relevantWindow.scrollX || relevantWindow.document.documentElement.scrollLeft, | ||
y: relevantWindow.scrollY || relevantWindow.document.documentElement.scrollTop | ||
}; | ||
} | ||
export function getElementClientRect(element) { | ||
const clientRect = (element instanceof domObjects.SVGElement | ||
? element.getBoundingClientRect() | ||
: element.getClientRects()[0]); | ||
return clientRect && { | ||
left: clientRect.left, | ||
right: clientRect.right, | ||
top: clientRect.top, | ||
bottom: clientRect.bottom, | ||
width: clientRect.width || clientRect.right - clientRect.left, | ||
height: clientRect.height || clientRect.bottom - clientRect.top, | ||
}; | ||
const clientRect = element instanceof domObjects.SVGElement ? element.getBoundingClientRect() : element.getClientRects()[0]; | ||
return clientRect && { | ||
left: clientRect.left, | ||
right: clientRect.right, | ||
top: clientRect.top, | ||
bottom: clientRect.bottom, | ||
width: clientRect.width || clientRect.right - clientRect.left, | ||
height: clientRect.height || clientRect.bottom - clientRect.top | ||
}; | ||
} | ||
export function getElementRect(element) { | ||
const clientRect = getElementClientRect(element); | ||
if (!browser.isIOS7 && clientRect) { | ||
const scroll = getScrollXY(win.getWindow(element)); | ||
clientRect.left += scroll.x; | ||
clientRect.right += scroll.x; | ||
clientRect.top += scroll.y; | ||
clientRect.bottom += scroll.y; | ||
} | ||
return clientRect; | ||
const clientRect = getElementClientRect(element); | ||
if (!browser.isIOS7 && clientRect) { | ||
const scroll = getScrollXY(win.getWindow(element)); | ||
clientRect.left += scroll.x; | ||
clientRect.right += scroll.x; | ||
clientRect.top += scroll.y; | ||
clientRect.bottom += scroll.y; | ||
} | ||
return clientRect; | ||
} | ||
export function getPath(node) { | ||
const path = []; | ||
while (node) { | ||
path.push(node); | ||
node = parentNode(node); | ||
} | ||
return path; | ||
const path = []; | ||
while (node) { | ||
path.push(node); | ||
node = parentNode(node); | ||
} | ||
return path; | ||
} | ||
export function trySelector(value) { | ||
if (!is.string(value)) { | ||
return false; | ||
} | ||
// an exception will be raised if it is invalid | ||
domObjects.document.querySelector(value); | ||
return true; | ||
if (!is.string(value)) { | ||
return false; | ||
} // an exception will be raised if it is invalid | ||
domObjects.document.querySelector(value); | ||
return true; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG9tVXRpbHMuanMiLCJzb3VyY2V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gaWYgKCFpcy5zdHJpbmcodmFsdWUpKSB7IHJldHVybiBmYWxzZSB9XG5cbiAgLy8gYW4gZXhjZXB0aW9uIHdpbGwgYmUgcmFpc2VkIGlmIGl0IGlzIGludmFsaWRcbiAgZG9tT2JqZWN0cy5kb2N1bWVudC5xdWVyeVNlbGVjdG9yKHZhbHVlKVxuICByZXR1cm4gdHJ1ZVxufVxuIl19 | ||
//# sourceMappingURL=domUtils.js.map |
419
events.js
@@ -1,6 +0,8 @@ | ||
import { contains } from './arr'; | ||
import * as domUtils from './domUtils'; | ||
import * as is from './is'; | ||
import pExtend from './pointerExtend'; | ||
import pointerUtils from './pointerUtils'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import { contains } from "./arr.js"; | ||
import * as domUtils from "./domUtils.js"; | ||
import * as is from "./is.js"; | ||
import pExtend from "./pointerExtend.js"; | ||
import pointerUtils from "./pointerUtils.js"; | ||
const elements = []; | ||
@@ -10,213 +12,256 @@ const targets = []; | ||
const documents = []; | ||
function add(element, type, listener, optionalArg) { | ||
const options = getOptions(optionalArg); | ||
let elementIndex = elements.indexOf(element); | ||
let target = targets[elementIndex]; | ||
if (!target) { | ||
target = { | ||
events: {}, | ||
typeCount: 0, | ||
}; | ||
elementIndex = elements.push(element) - 1; | ||
targets.push(target); | ||
} | ||
if (!target.events[type]) { | ||
target.events[type] = []; | ||
target.typeCount++; | ||
} | ||
if (!contains(target.events[type], listener)) { | ||
element.addEventListener(type, listener, events.supportsOptions ? options : !!options.capture); | ||
target.events[type].push(listener); | ||
} | ||
const options = getOptions(optionalArg); | ||
let elementIndex = elements.indexOf(element); | ||
let target = targets[elementIndex]; | ||
if (!target) { | ||
target = { | ||
events: {}, | ||
typeCount: 0 | ||
}; | ||
elementIndex = elements.push(element) - 1; | ||
targets.push(target); | ||
} | ||
if (!target.events[type]) { | ||
target.events[type] = []; | ||
target.typeCount++; | ||
} | ||
if (!contains(target.events[type], listener)) { | ||
element.addEventListener(type, listener, events.supportsOptions ? options : !!options.capture); | ||
target.events[type].push(listener); | ||
} | ||
} | ||
function remove(element, type, listener, optionalArg) { | ||
const options = getOptions(optionalArg); | ||
const elementIndex = elements.indexOf(element); | ||
const target = targets[elementIndex]; | ||
if (!target || !target.events) { | ||
return; | ||
const options = getOptions(optionalArg); | ||
const elementIndex = elements.indexOf(element); | ||
const target = targets[elementIndex]; | ||
if (!target || !target.events) { | ||
return; | ||
} | ||
if (type === 'all') { | ||
for (type in target.events) { | ||
if (target.events.hasOwnProperty(type)) { | ||
remove(element, type, 'all'); | ||
} | ||
} | ||
if (type === 'all') { | ||
for (type in target.events) { | ||
if (target.events.hasOwnProperty(type)) { | ||
remove(element, type, 'all'); | ||
} | ||
return; | ||
} | ||
if (target.events[type]) { | ||
const len = target.events[type].length; | ||
if (listener === 'all') { | ||
for (let i = 0; i < len; i++) { | ||
remove(element, type, target.events[type][i], options); | ||
} | ||
return; | ||
} else { | ||
for (let i = 0; i < len; i++) { | ||
if (target.events[type][i] === listener) { | ||
element.removeEventListener(type, listener, events.supportsOptions ? options : !!options.capture); | ||
target.events[type].splice(i, 1); | ||
break; | ||
} | ||
return; | ||
} | ||
} | ||
if (target.events[type]) { | ||
const len = target.events[type].length; | ||
if (listener === 'all') { | ||
for (let i = 0; i < len; i++) { | ||
remove(element, type, target.events[type][i], options); | ||
} | ||
return; | ||
} | ||
else { | ||
for (let i = 0; i < len; i++) { | ||
if (target.events[type][i] === listener) { | ||
element.removeEventListener(type, listener, events.supportsOptions ? options : !!options.capture); | ||
target.events[type].splice(i, 1); | ||
break; | ||
} | ||
} | ||
} | ||
if (target.events[type] && target.events[type].length === 0) { | ||
target.events[type] = null; | ||
target.typeCount--; | ||
} | ||
if (target.events[type] && target.events[type].length === 0) { | ||
target.events[type] = null; | ||
target.typeCount--; | ||
} | ||
if (!target.typeCount) { | ||
targets.splice(elementIndex, 1); | ||
elements.splice(elementIndex, 1); | ||
} | ||
} | ||
if (!target.typeCount) { | ||
targets.splice(elementIndex, 1); | ||
elements.splice(elementIndex, 1); | ||
} | ||
} | ||
function addDelegate(selector, context, type, listener, optionalArg) { | ||
const options = getOptions(optionalArg); | ||
if (!delegatedEvents[type]) { | ||
delegatedEvents[type] = { | ||
contexts: [], | ||
listeners: [], | ||
selectors: [], | ||
}; | ||
// add delegate listener functions | ||
for (const doc of documents) { | ||
add(doc, type, delegateListener); | ||
add(doc, type, delegateUseCapture, true); | ||
} | ||
const options = getOptions(optionalArg); | ||
if (!delegatedEvents[type]) { | ||
delegatedEvents[type] = { | ||
contexts: [], | ||
listeners: [], | ||
selectors: [] | ||
}; // add delegate listener functions | ||
for (const doc of documents) { | ||
add(doc, type, delegateListener); | ||
add(doc, type, delegateUseCapture, true); | ||
} | ||
const delegated = delegatedEvents[type]; | ||
let index; | ||
for (index = delegated.selectors.length - 1; index >= 0; index--) { | ||
if (delegated.selectors[index] === selector && | ||
delegated.contexts[index] === context) { | ||
break; | ||
} | ||
} | ||
const delegated = delegatedEvents[type]; | ||
let index; | ||
for (index = delegated.selectors.length - 1; index >= 0; index--) { | ||
if (delegated.selectors[index] === selector && delegated.contexts[index] === context) { | ||
break; | ||
} | ||
if (index === -1) { | ||
index = delegated.selectors.length; | ||
delegated.selectors.push(selector); | ||
delegated.contexts.push(context); | ||
delegated.listeners.push([]); | ||
} | ||
// keep listener and capture and passive flags | ||
delegated.listeners[index].push([listener, !!options.capture, options.passive]); | ||
} | ||
if (index === -1) { | ||
index = delegated.selectors.length; | ||
delegated.selectors.push(selector); | ||
delegated.contexts.push(context); | ||
delegated.listeners.push([]); | ||
} // keep listener and capture and passive flags | ||
delegated.listeners[index].push([listener, !!options.capture, options.passive]); | ||
} | ||
function removeDelegate(selector, context, type, listener, optionalArg) { | ||
const options = getOptions(optionalArg); | ||
const delegated = delegatedEvents[type]; | ||
let matchFound = false; | ||
let index; | ||
if (!delegated) { | ||
return; | ||
} | ||
// count from last index of delegated to 0 | ||
for (index = delegated.selectors.length - 1; index >= 0; index--) { | ||
// look for matching selector and context Node | ||
if (delegated.selectors[index] === selector && | ||
delegated.contexts[index] === context) { | ||
const listeners = delegated.listeners[index]; | ||
// each item of the listeners array is an array: [function, capture, passive] | ||
for (let i = listeners.length - 1; i >= 0; i--) { | ||
const [fn, capture, passive] = listeners[i]; | ||
// check if the listener functions and capture and passive flags match | ||
if (fn === listener && capture === !!options.capture && passive === options.passive) { | ||
// remove the listener from the array of listeners | ||
listeners.splice(i, 1); | ||
// if all listeners for this interactable have been removed | ||
// remove the interactable from the delegated arrays | ||
if (!listeners.length) { | ||
delegated.selectors.splice(index, 1); | ||
delegated.contexts.splice(index, 1); | ||
delegated.listeners.splice(index, 1); | ||
// remove delegate function from context | ||
remove(context, type, delegateListener); | ||
remove(context, type, delegateUseCapture, true); | ||
// remove the arrays if they are empty | ||
if (!delegated.selectors.length) { | ||
delegatedEvents[type] = null; | ||
} | ||
} | ||
// only remove one listener | ||
matchFound = true; | ||
break; | ||
} | ||
const options = getOptions(optionalArg); | ||
const delegated = delegatedEvents[type]; | ||
let matchFound = false; | ||
let index; | ||
if (!delegated) { | ||
return; | ||
} // count from last index of delegated to 0 | ||
for (index = delegated.selectors.length - 1; index >= 0; index--) { | ||
// look for matching selector and context Node | ||
if (delegated.selectors[index] === selector && delegated.contexts[index] === context) { | ||
const listeners = delegated.listeners[index]; // each item of the listeners array is an array: [function, capture, passive] | ||
for (let i = listeners.length - 1; i >= 0; i--) { | ||
const [fn, capture, passive] = listeners[i]; // check if the listener functions and capture and passive flags match | ||
if (fn === listener && capture === !!options.capture && passive === options.passive) { | ||
// remove the listener from the array of listeners | ||
listeners.splice(i, 1); // if all listeners for this interactable have been removed | ||
// remove the interactable from the delegated arrays | ||
if (!listeners.length) { | ||
delegated.selectors.splice(index, 1); | ||
delegated.contexts.splice(index, 1); | ||
delegated.listeners.splice(index, 1); // remove delegate function from context | ||
remove(context, type, delegateListener); | ||
remove(context, type, delegateUseCapture, true); // remove the arrays if they are empty | ||
if (!delegated.selectors.length) { | ||
delegatedEvents[type] = null; | ||
} | ||
if (matchFound) { | ||
break; | ||
} | ||
} // only remove one listener | ||
matchFound = true; | ||
break; | ||
} | ||
} | ||
if (matchFound) { | ||
break; | ||
} | ||
} | ||
} | ||
// bound to the interactable context when a DOM event | ||
} | ||
} // bound to the interactable context when a DOM event | ||
// listener is added to a selector interactable | ||
function delegateListener(event, optionalArg) { | ||
const options = getOptions(optionalArg); | ||
const fakeEvent = new FakeEvent(event); | ||
const delegated = delegatedEvents[event.type]; | ||
const [eventTarget] = (pointerUtils.getEventTargets(event)); | ||
let element = eventTarget; | ||
// climb up document tree looking for selector matches | ||
while (is.element(element)) { | ||
for (let i = 0; i < delegated.selectors.length; i++) { | ||
const selector = delegated.selectors[i]; | ||
const context = delegated.contexts[i]; | ||
if (domUtils.matchesSelector(element, selector) && | ||
domUtils.nodeContains(context, eventTarget) && | ||
domUtils.nodeContains(context, element)) { | ||
const listeners = delegated.listeners[i]; | ||
fakeEvent.currentTarget = element; | ||
for (const [fn, capture, passive] of listeners) { | ||
if (capture === !!options.capture && passive === options.passive) { | ||
fn(fakeEvent); | ||
} | ||
} | ||
} | ||
const options = getOptions(optionalArg); | ||
const fakeEvent = new FakeEvent(event); | ||
const delegated = delegatedEvents[event.type]; | ||
const [eventTarget] = pointerUtils.getEventTargets(event); | ||
let element = eventTarget; // climb up document tree looking for selector matches | ||
while (is.element(element)) { | ||
for (let i = 0; i < delegated.selectors.length; i++) { | ||
const selector = delegated.selectors[i]; | ||
const context = delegated.contexts[i]; | ||
if (domUtils.matchesSelector(element, selector) && domUtils.nodeContains(context, eventTarget) && domUtils.nodeContains(context, element)) { | ||
const listeners = delegated.listeners[i]; | ||
fakeEvent.currentTarget = element; | ||
for (const [fn, capture, passive] of listeners) { | ||
if (capture === !!options.capture && passive === options.passive) { | ||
fn(fakeEvent); | ||
} | ||
} | ||
element = domUtils.parentNode(element); | ||
} | ||
} | ||
element = domUtils.parentNode(element); | ||
} | ||
} | ||
function delegateUseCapture(event) { | ||
return delegateListener.call(this, event, true); | ||
return delegateListener.call(this, event, true); | ||
} | ||
function getOptions(param) { | ||
return is.object(param) ? param : { capture: param }; | ||
return is.object(param) ? param : { | ||
capture: param | ||
}; | ||
} | ||
export class FakeEvent { | ||
constructor(originalEvent) { | ||
this.originalEvent = originalEvent; | ||
// duplicate the event so that currentTarget can be changed | ||
pExtend(this, originalEvent); | ||
} | ||
preventOriginalDefault() { | ||
this.originalEvent.preventDefault(); | ||
} | ||
stopPropagation() { | ||
this.originalEvent.stopPropagation(); | ||
} | ||
stopImmediatePropagation() { | ||
this.originalEvent.stopImmediatePropagation(); | ||
} | ||
constructor(originalEvent) { | ||
this.originalEvent = originalEvent; | ||
_defineProperty(this, "currentTarget", void 0); | ||
// duplicate the event so that currentTarget can be changed | ||
pExtend(this, originalEvent); | ||
} | ||
preventOriginalDefault() { | ||
this.originalEvent.preventDefault(); | ||
} | ||
stopPropagation() { | ||
this.originalEvent.stopPropagation(); | ||
} | ||
stopImmediatePropagation() { | ||
this.originalEvent.stopImmediatePropagation(); | ||
} | ||
} | ||
const events = { | ||
add, | ||
remove, | ||
addDelegate, | ||
removeDelegate, | ||
delegateListener, | ||
delegateUseCapture, | ||
delegatedEvents, | ||
documents, | ||
supportsOptions: false, | ||
supportsPassive: false, | ||
_elements: elements, | ||
_targets: targets, | ||
init(window) { | ||
window.document.createElement('div').addEventListener('test', null, { | ||
get capture() { return (events.supportsOptions = true); }, | ||
get passive() { return (events.supportsPassive = true); }, | ||
}); | ||
}, | ||
add, | ||
remove, | ||
addDelegate, | ||
removeDelegate, | ||
delegateListener, | ||
delegateUseCapture, | ||
delegatedEvents, | ||
documents, | ||
supportsOptions: false, | ||
supportsPassive: false, | ||
_elements: elements, | ||
_targets: targets, | ||
init(window) { | ||
window.document.createElement('div').addEventListener('test', null, { | ||
get capture() { | ||
return events.supportsOptions = true; | ||
}, | ||
get passive() {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sXG4gIGRvY3VtZW50cyxcblxuICBzdXBwb3J0c09wdGlvbnM6IGZhbHNlLFxuICBzdXBwb3J0c1Bhc3NpdmU6IGZhbHNlLFxuXG4gIF9lbGVtZW50czogZWxlbWVudHMsXG4gIF90YXJnZXRzOiB0YXJnZXRzLFxuXG4gIGluaXQgKHdpbmRvdzogV2luZG93KSB7XG4gICAgd2luZG93LmRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpLmFkZEV2ZW50TGlzdGVuZXIoJ3Rlc3QnLCBudWxsLCB7XG4gICAgICBnZXQgY2FwdHVyZSAoKSB7IHJldHVybiAoZXZlbnRzLnN1cHBvcnRzT3B0aW9ucyA9IHRydWUpIH0sXG4gICAgICBnZXQgcGFzc2l2ZSAoKSB7IHJldHVybiAoZXZlbnRzLnN1cHBvcnRzUGFzc2l2ZSA9IHRydWUpIH0sXG4gICAgfSlcbiAgfSxcbn1cblxuZXhwb3J0IGRlZmF1bHQgZXZlbnRzXG4iXX0= | ||
//# sourceMappingURL=events.js.map |
@@ -1,1 +0,1 @@ | ||
export default function extend<T, U extends Partial<T>>(dest: U, source: T): T & U; | ||
export default function extend<T, U extends object>(dest: U, source: T): T & U; |
export default function extend(dest, source) { | ||
for (const prop in source) { | ||
dest[prop] = source[prop]; | ||
} | ||
return dest; | ||
for (const prop in source) { | ||
dest[prop] = source[prop]; | ||
} | ||
const ret = dest; | ||
return ret; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXh0ZW5kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZXh0ZW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sQ0FBQyxPQUFPLFVBQVUsTUFBTSxDQUEyQixJQUFPLEVBQUUsTUFBUztJQUN6RSxLQUFLLE1BQU0sSUFBSSxJQUFJLE1BQU0sRUFBRTtRQUN4QixJQUFxQixDQUFDLElBQUksQ0FBQyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQTtLQUM1QztJQUNELE9BQU8sSUFBYSxDQUFBO0FBQ3RCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCBmdW5jdGlvbiBleHRlbmQ8VCwgVSBleHRlbmRzIFBhcnRpYWw8VD4+IChkZXN0OiBVLCBzb3VyY2U6IFQpIHtcbiAgZm9yIChjb25zdCBwcm9wIGluIHNvdXJjZSkge1xuICAgIChkZXN0IGFzIHVua25vd24gYXMgVClbcHJvcF0gPSBzb3VyY2VbcHJvcF1cbiAgfVxuICByZXR1cm4gZGVzdCBhcyBUICYgVVxufVxuIl19 | ||
//# sourceMappingURL=extend.js.map |
@@ -1,3 +0,2 @@ | ||
import { HasGetRect } from '@interactjs/types/types'; | ||
export default function (target: HasGetRect & { | ||
export default function (target: Interact.HasGetRect & { | ||
options: Interact.PerActionDefaults; | ||
@@ -4,0 +3,0 @@ }, element: any, action?: any): { |
@@ -1,9 +0,12 @@ | ||
import { rectToXY, resolveRectLike } from './rect'; | ||
import { rectToXY, resolveRectLike } from "./rect.js"; | ||
export default function (target, element, action) { | ||
const actionOptions = target.options[action]; | ||
const actionOrigin = actionOptions && actionOptions.origin; | ||
const origin = actionOrigin || target.options.origin; | ||
const originRect = resolveRectLike(origin, target, element, [target && element]); | ||
return rectToXY(originRect) || { x: 0, y: 0 }; | ||
const actionOptions = target.options[action]; | ||
const actionOrigin = actionOptions && actionOptions.origin; | ||
const origin = actionOrigin || target.options.origin; | ||
const originRect = resolveRectLike(origin, target, element, [target && element]); | ||
return rectToXY(originRect) || { | ||
x: 0, | ||
y: 0 | ||
}; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0T3JpZ2luWFkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJnZXRPcmlnaW5YWS50cyJdLCJuYW1lcyI6W10sIm1hcH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b25zICYmIGFjdGlvbk9wdGlvbnMub3JpZ2luXG4gIGNvbnN0IG9yaWdpbiA9IGFjdGlvbk9yaWdpbiB8fCB0YXJnZXQub3B0aW9ucy5vcmlnaW5cblxuICBjb25zdCBvcmlnaW5SZWN0ID0gcmVzb2x2ZVJlY3RMaWtlKG9yaWdpbiwgdGFyZ2V0LCBlbGVtZW50LCBbdGFyZ2V0ICYmIGVsZW1lbnRdKVxuXG4gIHJldHVybiByZWN0VG9YWShvcmlnaW5SZWN0KSB8fCB7IHg6IDAsIHk6IDAgfVxufVxuIl19 | ||
//# sourceMappingURL=getOriginXY.js.map |
@@ -1,2 +0,2 @@ | ||
export default (x, y) => Math.sqrt(x * x + y * y); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHlwb3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJoeXBvdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxlQUFlLENBQUMsQ0FBUyxFQUFFLENBQVMsRUFBRSxFQUFFLENBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0ICh4OiBudW1iZXIsIHk6IG51bWJlcikgPT4gIE1hdGguc3FydCh4ICogeCArIHkgKiB5KVxuIl19 | ||
export default ((x, y) => Math.sqrt(x * x + y * y)); | ||
//# sourceMappingURL=hypot.js.map |
@@ -12,3 +12,3 @@ import * as arr from './arr'; | ||
export declare function easeOutQuad(t: number, b: number, c: number, d: number): number; | ||
export declare function copyAction(dest: Interact.ActionProps, src: Interact.ActionProps): import("@interactjs/core/Interaction").ActionProps<any>; | ||
export declare function copyAction(dest: Interact.ActionProps, src: Interact.ActionProps): import("../types/types").ActionProps<any>; | ||
export { default as browser } from './browser'; | ||
@@ -24,3 +24,2 @@ export { default as clone } from './clone'; | ||
export { default as rect } from './rect'; | ||
export { default as Signals } from './Signals'; | ||
export { win, arr, dom, is }; |
82
index.js
@@ -1,50 +0,50 @@ | ||
import * as arr from './arr'; | ||
import * as dom from './domUtils'; | ||
import * as is from './is'; | ||
import win from './window'; | ||
import * as arr from "./arr.js"; | ||
import * as dom from "./domUtils.js"; | ||
import * as is from "./is.js"; | ||
import win from "./window.js"; | ||
export function warnOnce(method, message) { | ||
let warned = false; | ||
// eslint-disable-next-line no-shadow | ||
return function () { | ||
if (!warned) { | ||
win.window.console.warn(message); | ||
warned = true; | ||
} | ||
return method.apply(this, arguments); | ||
}; | ||
} | ||
// http://stackoverflow.com/a/5634528/2280888 | ||
let warned = false; // eslint-disable-next-line no-shadow | ||
return function () { | ||
if (!warned) { | ||
win.window.console.warn(message); | ||
warned = true; | ||
} | ||
return method.apply(this, arguments); | ||
}; | ||
} // http://stackoverflow.com/a/5634528/2280888 | ||
export function _getQBezierValue(t, p1, p2, p3) { | ||
const iT = 1 - t; | ||
return iT * iT * p1 + 2 * iT * t * p2 + t * t * p3; | ||
const iT = 1 - t; | ||
return iT * iT * p1 + 2 * iT * t * p2 + t * t * p3; | ||
} | ||
export function getQuadraticCurvePoint(startX, startY, cpX, cpY, endX, endY, position) { | ||
return { | ||
x: _getQBezierValue(position, startX, cpX, endX), | ||
y: _getQBezierValue(position, startY, cpY, endY), | ||
}; | ||
} | ||
// http://gizma.com/easing/ | ||
return { | ||
x: _getQBezierValue(position, startX, cpX, endX), | ||
y: _getQBezierValue(position, startY, cpY, endY) | ||
}; | ||
} // http://gizma.com/easing/ | ||
export function easeOutQuad(t, b, c, d) { | ||
t /= d; | ||
return -c * t * (t - 2) + b; | ||
t /= d; | ||
return -c * t * (t - 2) + b; | ||
} | ||
export function copyAction(dest, src) { | ||
dest.name = src.name; | ||
dest.axis = src.axis; | ||
dest.edges = src.edges; | ||
return dest; | ||
dest.name = src.name; | ||
dest.axis = src.axis; | ||
dest.edges = src.edges; | ||
return dest; | ||
} | ||
export { default as browser } from './browser'; | ||
export { default as clone } from './clone'; | ||
export { default as events } from './events'; | ||
export { default as extend } from './extend'; | ||
export { default as getOriginXY } from './getOriginXY'; | ||
export { default as hypot } from './hypot'; | ||
export { default as normalizeListeners } from './normalizeListeners'; | ||
export { default as pointer } from './pointerUtils'; | ||
export { default as raf } from './raf'; | ||
export { default as rect } from './rect'; | ||
export { default as Signals } from './Signals'; | ||
export { default as browser } from "./browser.js"; | ||
export { default as clone } from "./clone.js"; | ||
export { default as events } from "./events.js"; | ||
export { default as extend } from "./extend.js"; | ||
export { default as getOriginXY } from "./getOriginXY.js"; | ||
export { default as hypot } from "./hypot.js"; | ||
export { default as normalizeListeners } from "./normalizeListeners.js"; | ||
export { default as pointer } from "./pointerUtils.js"; | ||
export { default as raf } from "./raf.js"; | ||
export { default as rect } from "./rect.js"; | ||
export { win, arr, dom, is }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssR0FBRyxNQUFNLE9BQU8sQ0FBQTtBQUM1QixPQUFPLEtBQUssR0FBRyxNQUFNLFlBQVksQ0FBQTtBQUNqQyxPQUFPLEtBQUssRUFBRSxNQUFNLE1BQU0sQ0FBQTtBQUMxQixPQUFPLEdBQUcsTUFBTSxVQUFVLENBQUE7QUFFMUIsTUFBTSxVQUFVLFFBQVEsQ0FBYyxNQUE2QixFQUFFLE9BQWU7SUFDbEYsSUFBSSxNQUFNLEdBQUcsS0FBSyxDQUFBO0lBRWxCLHFDQUFxQztJQUNyQyxPQUFPO1FBQ0wsSUFBSSxDQUFDLE1BQU0sRUFBRTtZQUNWLEdBQVcsQ0FBQyxNQUFNLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ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GZyb20gJy4vZ2V0T3JpZ2luWFknXG5leHBvcnQgeyBkZWZhdWx0IGFzIGh5cG90IH0gZnJvbSAnLi9oeXBvdCdcbmV4cG9ydCB7IGRlZmF1bHQgYXMgbm9ybWFsaXplTGlzdGVuZXJzIH0gZnJvbSAnLi9ub3JtYWxpemVMaXN0ZW5lcnMnXG5leHBvcnQgeyBkZWZhdWx0IGFzIHBvaW50ZXIgfSBmcm9tICcuL3BvaW50ZXJVdGlscydcbmV4cG9ydCB7IGRlZmF1bHQgYXMgcmFmIH0gZnJvbSAnLi9yYWYnXG5leHBvcnQgeyBkZWZhdWx0IGFzIHJlY3QgfSBmcm9tICcuL3JlY3QnXG5leHBvcnQgeyBkZWZhdWx0IGFzIFNpZ25hbHMgfSBmcm9tICcuL1NpZ25hbHMnXG5leHBvcnQgeyB3aW4sIGFyciwgZG9tLCBpcyB9XG4iXX0= | ||
//# sourceMappingURL=index.js.map |
45
is.js
// tslint:disable variable-name | ||
import isWindow from './isWindow'; | ||
import win from './window'; | ||
export const window = (thing) => thing === win.window || isWindow(thing); | ||
export const docFrag = (thing) => object(thing) && thing.nodeType === 11; | ||
export const object = (thing) => !!thing && (typeof thing === 'object'); | ||
export const func = (thing) => typeof thing === 'function'; | ||
export const number = (thing) => typeof thing === 'number'; | ||
export const bool = (thing) => typeof thing === 'boolean'; | ||
export const string = (thing) => typeof thing === 'string'; | ||
export const element = (thing) => { | ||
if (!thing || (typeof thing !== 'object')) { | ||
return false; | ||
} | ||
const _window = win.getWindow(thing) || win.window; | ||
return (/object|function/.test(typeof _window.Element) | ||
? thing instanceof _window.Element // DOM2 | ||
: thing.nodeType === 1 && typeof thing.nodeName === 'string'); | ||
import isWindow from "./isWindow.js"; | ||
import win from "./window.js"; | ||
export const window = thing => thing === win.window || isWindow(thing); | ||
export const docFrag = thing => object(thing) && thing.nodeType === 11; | ||
export const object = thing => !!thing && typeof thing === 'object'; | ||
export const func = thing => typeof thing === 'function'; | ||
export const number = thing => typeof thing === 'number'; | ||
export const bool = thing => typeof thing === 'boolean'; | ||
export const string = thing => typeof thing === 'string'; | ||
export const element = thing => { | ||
if (!thing || typeof thing !== 'object') { | ||
return false; | ||
} | ||
const _window = win.getWindow(thing) || win.window; | ||
return /object|function/.test(typeof _window.Element) ? thing instanceof _window.Element // DOM2 | ||
: thing.nodeType === 1 && typeof thing.nodeName === 'string'; | ||
}; | ||
export const plainObject = (thing) => object(thing) && | ||
!!thing.constructor && | ||
/function Object\b/.test(thing.constructor.toString()); | ||
export const array = (thing) => (object(thing) && | ||
(typeof thing.length !== 'undefined') && | ||
func(thing.splice)); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwrQkFBK0I7QUFFL0IsT0FBTyxRQUFRLE1BQU0sWUFBWSxDQUFBO0FBQ2pDLE9BQU8sR0FBRyxNQUFNLFVBQVUsQ0FBQTtBQUUxQixNQUFNLENBQUMsTUFBTSxNQUFNLEdBQUcsQ0FBQyxLQUFVLEVBQW1CLEVBQUUsQ0FDcEQsS0FBSyxLQUFLLEdBQUcsQ0FBQyxNQUFNLElBQUksUUFBUSxDQUFDLEtBQUssQ0FBQyxDQUFBO0FBRXpDLE1BQU0sQ0FBQyxNQUFNLE9BQU8sR0FBRyxDQUFDLEtBQVUsRUFBNkIsRUFBRSxDQUMvRCxNQUFNLENBQUMsS0FBSyxDQUFDLElBQUksS0FBSyxDQUFDLFFBQVEsS0FBSyxFQUFFLENBQUE7QUFFeEMsTUFBTSxDQUFDLE1BQU0sTUFBTSxHQUFHLENBQUMsS0FBVSxFQUFxQyxFQUFFLENBQ3RFLENBQUMsQ0FBQyxLQUFLLElBQUksQ0FBQyxPQUFPLEtBQUssS0FBSyxRQUFRLENBQUMsQ0FBQTtBQUV4QyxNQUFNLENBQUMsTUFBTSxJQUFJ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VjdG9yICYmXG4gIC9mdW5jdGlvbiBPYmplY3RcXGIvLnRlc3QodGhpbmcuY29uc3RydWN0b3IudG9TdHJpbmcoKSlcblxuZXhwb3J0IGNvbnN0IGFycmF5ID0gKHRoaW5nOiBhbnkpOiB0aGluZyBpcyBhbnlbXSA9PlxuICAob2JqZWN0KHRoaW5nKSAmJlxuICAodHlwZW9mIHRoaW5nLmxlbmd0aCAhPT0gJ3VuZGVmaW5lZCcpICYmXG4gIGZ1bmModGhpbmcuc3BsaWNlKSlcbiJdfQ== | ||
export const plainObject = thing => object(thing) && !!thing.constructor && /function Object\b/.test(thing.constructor.toString()); | ||
export const array = thing => object(thing) && typeof thing.length !== 'undefined' && func(thing.splice); | ||
//# sourceMappingURL=is.js.map |
@@ -1,2 +0,2 @@ | ||
export default thing => !!(thing && thing.Window) && (thing instanceof thing.Window); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaXNXaW5kb3cuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpc1dpbmRvdy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxlQUFlLEtBQUssQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUMsS0FBSyxJQUFJLEtBQUssQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssWUFBWSxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUEiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCB0aGluZyA9PiAhISh0aGluZyAmJiB0aGluZy5XaW5kb3cpICYmICh0aGluZyBpbnN0YW5jZW9mIHRoaW5nLldpbmRvdylcbiJdfQ== | ||
export default (thing => !!(thing && thing.Window) && thing instanceof thing.Window); | ||
//# sourceMappingURL=isWindow.js.map |
@@ -1,36 +0,40 @@ | ||
import extend from './extend'; | ||
import * as is from './is'; | ||
import extend from "./extend.js"; | ||
import * as is from "./is.js"; | ||
export default function normalize(type, listeners, result) { | ||
result = result || {}; | ||
if (is.string(type) && type.search(' ') !== -1) { | ||
type = split(type); | ||
result = result || {}; | ||
if (is.string(type) && type.search(' ') !== -1) { | ||
type = split(type); | ||
} | ||
if (is.array(type)) { | ||
return type.reduce((acc, t) => extend(acc, normalize(t, listeners, result)), result); | ||
} // ({ type: fn }) -> ('', { type: fn }) | ||
if (is.object(type)) { | ||
listeners = type; | ||
type = ''; | ||
} | ||
if (is.func(listeners)) { | ||
result[type] = result[type] || []; | ||
result[type].push(listeners); | ||
} else if (is.array(listeners)) { | ||
for (const l of listeners) { | ||
normalize(type, l, result); | ||
} | ||
if (is.array(type)) { | ||
return type.reduce((acc, t) => extend(acc, normalize(t, listeners, result)), result); | ||
} else if (is.object(listeners)) { | ||
for (const prefix in listeners) { | ||
const combinedTypes = split(prefix).map(p => `${type}${p}`); | ||
normalize(combinedTypes, listeners[prefix], result); | ||
} | ||
// ({ type: fn }) -> ('', { type: fn }) | ||
if (is.object(type)) { | ||
listeners = type; | ||
type = ''; | ||
} | ||
if (is.func(listeners)) { | ||
result[type] = result[type] || []; | ||
result[type].push(listeners); | ||
} | ||
else if (is.array(listeners)) { | ||
for (const l of listeners) { | ||
normalize(type, l, result); | ||
} | ||
} | ||
else if (is.object(listeners)) { | ||
for (const prefix in listeners) { | ||
const combinedTypes = split(prefix).map(p => `${type}${p}`); | ||
normalize(combinedTypes, listeners[prefix], result); | ||
} | ||
} | ||
return result; | ||
} | ||
return result; | ||
} | ||
function split(type) { | ||
return type.trim().split(/ +/); | ||
return type.trim().split(/ +/); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9ybWFsaXplTGlzdGVuZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibm9ybWFsaXplTGlzdGVuZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sTUFBTSxNQUFNLFVBQVUsQ0F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PSBzcGxpdChwcmVmaXgpLm1hcChwID0+IGAke3R5cGV9JHtwfWApXG5cbiAgICAgIG5vcm1hbGl6ZShjb21iaW5lZFR5cGVzLCBsaXN0ZW5lcnNbcHJlZml4XSwgcmVzdWx0KVxuICAgIH1cbiAgfVxuXG4gIHJldHVybiByZXN1bHQgYXMgTm9ybWFsaXplZExpc3RlbmVyc1xufVxuXG5mdW5jdGlvbiBzcGxpdCAodHlwZTogc3RyaW5nKSB7XG4gIHJldHVybiB0eXBlLnRyaW0oKS5zcGxpdCgvICsvKVxufVxuIl19 | ||
//# sourceMappingURL=normalizeListeners.js.map |
{ | ||
"name": "@interactjs/utils", | ||
"version": "1.6.3", | ||
"version": "1.7.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
function pointerExtend(dest, source) { | ||
for (const prop in source) { | ||
const prefixedPropREs = pointerExtend.prefixedPropREs; | ||
let deprecated = false; | ||
// skip deprecated prefixed properties | ||
for (const vendor in prefixedPropREs) { | ||
if (prop.indexOf(vendor) === 0 && prefixedPropREs[vendor].test(prop)) { | ||
deprecated = true; | ||
break; | ||
} | ||
} | ||
if (!deprecated && typeof source[prop] !== 'function') { | ||
dest[prop] = source[prop]; | ||
} | ||
for (const prop in source) { | ||
const prefixedPropREs = pointerExtend.prefixedPropREs; | ||
let deprecated = false; // skip deprecated prefixed properties | ||
for (const vendor in prefixedPropREs) { | ||
if (prop.indexOf(vendor) === 0 && prefixedPropREs[vendor].test(prop)) { | ||
deprecated = true; | ||
break; | ||
} | ||
} | ||
return dest; | ||
if (!deprecated && typeof source[prop] !== 'function') { | ||
dest[prop] = source[prop]; | ||
} | ||
} | ||
return dest; | ||
} | ||
pointerExtend.prefixedPropREs = { | ||
webkit: /(Movement[XY]|Radius[XY]|RotationAngle|Force)$/, | ||
moz: /(Pressure)$/, | ||
webkit: /(Movement[XY]|Radius[XY]|RotationAngle|Force)$/, | ||
moz: /(Pressure)$/ | ||
}; | ||
export default pointerExtend; | ||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iAgd2Via2l0OiBSZWdFeHBcbiAgW3ByZWZpeDogc3RyaW5nXTogUmVnRXhwXG59XG5cbmZ1bmN0aW9uIHBvaW50ZXJFeHRlbmQgKGRlc3QsIHNvdXJjZSkge1xuICBmb3IgKGNvbnN0IHByb3AgaW4gc291cmNlKSB7XG4gICAgY29uc3QgcHJlZml4ZWRQcm9wUkVzID0gcG9pbnRlckV4dGVuZC5wcmVmaXhlZFByb3BSRXNcbiAgICBsZXQgZGVwcmVjYXRlZCA9IGZhbHNlXG5cbiAgICAvLyBza2lwIGRlcHJlY2F0ZWQgcHJlZml4ZWQgcHJvcGVydGllc1xuICAgIGZvciAoY29uc3QgdmVuZG9yIGluIHByZWZpeGVkUHJvcFJFcykge1xuICAgICAgaWYgKHByb3AuaW5kZXhPZih2ZW5kb3IpID09PSAwICYmIHByZWZpeGVkUHJvcFJFc1t2ZW5kb3JdLnRlc3QocHJvcCkpIHtcbiAgICAgICAgZGVwcmVjYXRlZCA9IHRydWVcbiAgICAgICAgYnJlYWtcbiAgICAgIH1cbiAgICB9XG5cbiAgICBpZiAoIWRlcHJlY2F0ZWQgJiYgdHlwZW9mIHNvdXJjZVtwcm9wXSAhPT0gJ2Z1bmN0aW9uJykge1xuICAgICAgZGVzdFtwcm9wXSA9IHNvdXJjZVtwcm9wXVxuICAgIH1cbiAgfVxuICByZXR1cm4gZGVzdFxufVxuXG5wb2ludGVyRXh0ZW5kLnByZWZpeGVkUHJvcFJFcyA9IHtcbiAgd2Via2l0OiAvKE1vdmVtZW50W1hZXXxSYWRpdXNbWFldfFJvdGF0aW9uQW5nbGV8Rm9yY2UpJC8sXG4gIG1vejogLyhQcmVzc3VyZSkkLyxcbn1cblxuZXhwb3J0IGRlZmF1bHQgcG9pbnRlckV4dGVuZFxuIl19 | ||
//# sourceMappingURL=pointerExtend.js.map |
@@ -22,3 +22,3 @@ import pointerExtend from './pointerExtend'; | ||
}; | ||
touchBBox(event: Event | (Touch | MouseEvent | PointerEvent | TouchEvent | import("@interactjs/core/InteractEvent").InteractEvent<any, any>)[]): { | ||
touchBBox(event: Event | (MouseEvent | Touch | PointerEvent | import("../types/types").InteractEvent<any, any> | TouchEvent)[]): { | ||
x: number; | ||
@@ -62,3 +62,3 @@ y: number; | ||
readonly buttons: any; | ||
} & Touch & MouseEvent) | ({ | ||
} & MouseEvent) | ({ | ||
coords: MockCoords; | ||
@@ -77,3 +77,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & Touch & PointerEvent) | ({ | ||
} & MouseEvent & PointerEvent) | ({ | ||
coords: MockCoords; | ||
@@ -92,3 +92,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & Touch & TouchEvent) | ({ | ||
} & MouseEvent & import("../types/types").InteractEvent<any, any>) | ({ | ||
coords: MockCoords; | ||
@@ -107,3 +107,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & Touch & import("@interactjs/core/InteractEvent").InteractEvent<any, any>) | ({ | ||
} & MouseEvent & TouchEvent) | ({ | ||
coords: MockCoords; | ||
@@ -122,3 +122,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & MouseEvent) | ({ | ||
} & Touch & MouseEvent) | ({ | ||
coords: MockCoords; | ||
@@ -137,3 +137,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & MouseEvent & PointerEvent) | ({ | ||
} & Touch & PointerEvent) | ({ | ||
coords: MockCoords; | ||
@@ -152,3 +152,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & MouseEvent & TouchEvent) | ({ | ||
} & Touch & import("../types/types").InteractEvent<any, any>) | ({ | ||
coords: MockCoords; | ||
@@ -167,3 +167,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & MouseEvent & import("@interactjs/core/InteractEvent").InteractEvent<any, any>) | ({ | ||
} & Touch & TouchEvent) | ({ | ||
coords: MockCoords; | ||
@@ -210,3 +210,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & PointerEvent & TouchEvent) | ({ | ||
} & PointerEvent & import("../types/types").InteractEvent<any, any>) | ({ | ||
coords: MockCoords; | ||
@@ -225,3 +225,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & PointerEvent & import("@interactjs/core/InteractEvent").InteractEvent<any, any>) | ({ | ||
} & PointerEvent & TouchEvent) | ({ | ||
coords: MockCoords; | ||
@@ -240,3 +240,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<any, any> & MouseEvent) | ({ | ||
} & import("../types/types").InteractEvent<any, any> & MouseEvent) | ({ | ||
coords: MockCoords; | ||
@@ -255,3 +255,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<any, any> & PointerEvent) | ({ | ||
} & import("../types/types").InteractEvent<any, any> & PointerEvent) | ({ | ||
coords: MockCoords; | ||
@@ -270,3 +270,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<any, any> & TouchEvent) | ({ | ||
} & import("../types/types").InteractEvent<any, any>) | ({ | ||
coords: MockCoords; | ||
@@ -285,3 +285,3 @@ readonly page: any; | ||
readonly buttons: any; | ||
} & import("@interactjs/core/InteractEvent").InteractEvent<any, any>); | ||
} & import("../types/types").InteractEvent<any, any> & TouchEvent); | ||
}; | ||
@@ -288,0 +288,0 @@ export default pointerUtils; |
@@ -1,214 +0,269 @@ | ||
import browser from './browser'; | ||
import dom from './domObjects'; | ||
import * as domUtils from './domUtils'; | ||
import hypot from './hypot'; | ||
import * as is from './is'; | ||
import pointerExtend from './pointerExtend'; | ||
import browser from "./browser.js"; | ||
import dom from "./domObjects.js"; | ||
import * as domUtils from "./domUtils.js"; | ||
import hypot from "./hypot.js"; | ||
import * as is from "./is.js"; | ||
import pointerExtend from "./pointerExtend.js"; | ||
const pointerUtils = { | ||
copyCoords(dest, src) { | ||
dest.page = dest.page || {}; | ||
dest.page.x = src.page.x; | ||
dest.page.y = src.page.y; | ||
dest.client = dest.client || {}; | ||
dest.client.x = src.client.x; | ||
dest.client.y = src.client.y; | ||
dest.timeStamp = src.timeStamp; | ||
}, | ||
setCoordDeltas(targetObj, prev, cur) { | ||
targetObj.page.x = cur.page.x - prev.page.x; | ||
targetObj.page.y = cur.page.y - prev.page.y; | ||
targetObj.client.x = cur.client.x - prev.client.x; | ||
targetObj.client.y = cur.client.y - prev.client.y; | ||
targetObj.timeStamp = cur.timeStamp - prev.timeStamp; | ||
}, | ||
setCoordVelocity(targetObj, delta) { | ||
const dt = Math.max(delta.timeStamp / 1000, 0.001); | ||
targetObj.page.x = delta.page.x / dt; | ||
targetObj.page.y = delta.page.y / dt; | ||
targetObj.client.x = delta.client.x / dt; | ||
targetObj.client.y = delta.client.y / dt; | ||
targetObj.timeStamp = dt; | ||
}, | ||
isNativePointer(pointer) { | ||
return (pointer instanceof dom.Event || pointer instanceof dom.Touch); | ||
}, | ||
// Get specified X/Y coords for mouse or event.touches[0] | ||
getXY(type, pointer, xy) { | ||
xy = xy || {}; | ||
type = type || 'page'; | ||
xy.x = pointer[type + 'X']; | ||
xy.y = pointer[type + 'Y']; | ||
return xy; | ||
}, | ||
getPageXY(pointer, page) { | ||
page = page || { x: 0, y: 0 }; | ||
// Opera Mobile handles the viewport and scrolling oddly | ||
if (browser.isOperaMobile && pointerUtils.isNativePointer(pointer)) { | ||
pointerUtils.getXY('screen', pointer, page); | ||
page.x += window.scrollX; | ||
page.y += window.scrollY; | ||
copyCoords(dest, src) { | ||
dest.page = dest.page || {}; | ||
dest.page.x = src.page.x; | ||
dest.page.y = src.page.y; | ||
dest.client = dest.client || {}; | ||
dest.client.x = src.client.x; | ||
dest.client.y = src.client.y; | ||
dest.timeStamp = src.timeStamp; | ||
}, | ||
setCoordDeltas(targetObj, prev, cur) { | ||
targetObj.page.x = cur.page.x - prev.page.x; | ||
targetObj.page.y = cur.page.y - prev.page.y; | ||
targetObj.client.x = cur.client.x - prev.client.x; | ||
targetObj.client.y = cur.client.y - prev.client.y; | ||
targetObj.timeStamp = cur.timeStamp - prev.timeStamp; | ||
}, | ||
setCoordVelocity(targetObj, delta) { | ||
const dt = Math.max(delta.timeStamp / 1000, 0.001); | ||
targetObj.page.x = delta.page.x / dt; | ||
targetObj.page.y = delta.page.y / dt; | ||
targetObj.client.x = delta.client.x / dt; | ||
targetObj.client.y = delta.client.y / dt; | ||
targetObj.timeStamp = dt; | ||
}, | ||
isNativePointer(pointer) { | ||
return pointer instanceof dom.Event || pointer instanceof dom.Touch; | ||
}, | ||
// Get specified X/Y coords for mouse or event.touches[0] | ||
getXY(type, pointer, xy) { | ||
xy = xy || {}; | ||
type = type || 'page'; | ||
xy.x = pointer[type + 'X']; | ||
xy.y = pointer[type + 'Y']; | ||
return xy; | ||
}, | ||
getPageXY(pointer, page) { | ||
page = page || { | ||
x: 0, | ||
y: 0 | ||
}; // Opera Mobile handles the viewport and scrolling oddly | ||
if (browser.isOperaMobile && pointerUtils.isNativePointer(pointer)) { | ||
pointerUtils.getXY('screen', pointer, page); | ||
page.x += window.scrollX; | ||
page.y += window.scrollY; | ||
} else { | ||
pointerUtils.getXY('page', pointer, page); | ||
} | ||
return page; | ||
}, | ||
getClientXY(pointer, client) { | ||
client = client || {}; | ||
if (browser.isOperaMobile && pointerUtils.isNativePointer(pointer)) { | ||
// Opera Mobile handles the viewport and scrolling oddly | ||
pointerUtils.getXY('screen', pointer, client); | ||
} else { | ||
pointerUtils.getXY('client', pointer, client); | ||
} | ||
return client; | ||
}, | ||
getPointerId(pointer) { | ||
return is.number(pointer.pointerId) ? pointer.pointerId : pointer.identifier; | ||
}, | ||
setCoords(targetObj, pointers, timeStamp) { | ||
const pointer = pointers.length > 1 ? pointerUtils.pointerAverage(pointers) : pointers[0]; | ||
const tmpXY = {}; | ||
pointerUtils.getPageXY(pointer, tmpXY); | ||
targetObj.page.x = tmpXY.x; | ||
targetObj.page.y = tmpXY.y; | ||
pointerUtils.getClientXY(pointer, tmpXY); | ||
targetObj.client.x = tmpXY.x; | ||
targetObj.client.y = tmpXY.y; | ||
targetObj.timeStamp = timeStamp; | ||
}, | ||
pointerExtend, | ||
getTouchPair(event) { | ||
const touches = []; // array of touches is supplied | ||
if (is.array(event)) { | ||
touches[0] = event[0]; | ||
touches[1] = event[1]; | ||
} // an event | ||
else { | ||
if (event.type === 'touchend') { | ||
if (event.touches.length === 1) { | ||
touches[0] = event.touches[0]; | ||
touches[1] = event.changedTouches[0]; | ||
} else if (event.touches.length === 0) { | ||
touches[0] = event.changedTouches[0]; | ||
touches[1] = event.changedTouches[1]; | ||
} | ||
} else { | ||
touches[0] = event.touches[0]; | ||
touches[1] = event.touches[1]; | ||
} | ||
else { | ||
pointerUtils.getXY('page', pointer, page); | ||
} | ||
return page; | ||
}, | ||
getClientXY(pointer, client) { | ||
client = client || {}; | ||
if (browser.isOperaMobile && pointerUtils.isNativePointer(pointer)) { | ||
// Opera Mobile handles the viewport and scrolling oddly | ||
pointerUtils.getXY('screen', pointer, client); | ||
} | ||
else { | ||
pointerUtils.getXY('client', pointer, client); | ||
} | ||
return client; | ||
}, | ||
getPointerId(pointer) { | ||
return is.number(pointer.pointerId) ? pointer.pointerId : pointer.identifier; | ||
}, | ||
setCoords(targetObj, pointers, timeStamp) { | ||
const pointer = (pointers.length > 1 | ||
? pointerUtils.pointerAverage(pointers) | ||
: pointers[0]); | ||
const tmpXY = {}; | ||
pointerUtils.getPageXY(pointer, tmpXY); | ||
targetObj.page.x = tmpXY.x; | ||
targetObj.page.y = tmpXY.y; | ||
pointerUtils.getClientXY(pointer, tmpXY); | ||
targetObj.client.x = tmpXY.x; | ||
targetObj.client.y = tmpXY.y; | ||
targetObj.timeStamp = timeStamp; | ||
}, | ||
pointerExtend, | ||
getTouchPair(event) { | ||
const touches = []; | ||
// array of touches is supplied | ||
if (is.array(event)) { | ||
touches[0] = event[0]; | ||
touches[1] = event[1]; | ||
} | ||
// an event | ||
else { | ||
if (event.type === 'touchend') { | ||
if (event.touches.length === 1) { | ||
touches[0] = event.touches[0]; | ||
touches[1] = event.changedTouches[0]; | ||
} | ||
else if (event.touches.length === 0) { | ||
touches[0] = event.changedTouches[0]; | ||
touches[1] = event.changedTouches[1]; | ||
} | ||
} | ||
else { | ||
touches[0] = event.touches[0]; | ||
touches[1] = event.touches[1]; | ||
} | ||
} | ||
return touches; | ||
}, | ||
pointerAverage(pointers) { | ||
const average = { | ||
pageX: 0, | ||
pageY: 0, | ||
clientX: 0, | ||
clientY: 0, | ||
screenX: 0, | ||
screenY: 0, | ||
}; | ||
for (const pointer of pointers) { | ||
for (const prop in average) { | ||
average[prop] += pointer[prop]; | ||
} | ||
} | ||
for (const prop in average) { | ||
average[prop] /= pointers.length; | ||
} | ||
return average; | ||
}, | ||
touchBBox(event) { | ||
if (!event.length && | ||
!(event.touches && | ||
event.touches.length > 1)) { | ||
return null; | ||
} | ||
const touches = pointerUtils.getTouchPair(event); | ||
const minX = Math.min(touches[0].pageX, touches[1].pageX); | ||
const minY = Math.min(touches[0].pageY, touches[1].pageY); | ||
const maxX = Math.max(touches[0].pageX, touches[1].pageX); | ||
const maxY = Math.max(touches[0].pageY, touches[1].pageY); | ||
return { | ||
x: minX, | ||
y: minY, | ||
left: minX, | ||
top: minY, | ||
right: maxX, | ||
bottom: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY, | ||
}; | ||
}, | ||
touchDistance(event, deltaSource) { | ||
const sourceX = deltaSource + 'X'; | ||
const sourceY = deltaSource + 'Y'; | ||
const touches = pointerUtils.getTouchPair(event); | ||
const dx = touches[0][sourceX] - touches[1][sourceX]; | ||
const dy = touches[0][sourceY] - touches[1][sourceY]; | ||
return hypot(dx, dy); | ||
}, | ||
touchAngle(event, deltaSource) { | ||
const sourceX = deltaSource + 'X'; | ||
const sourceY = deltaSource + 'Y'; | ||
const touches = pointerUtils.getTouchPair(event); | ||
const dx = touches[1][sourceX] - touches[0][sourceX]; | ||
const dy = touches[1][sourceY] - touches[0][sourceY]; | ||
const angle = 180 * Math.atan2(dy, dx) / Math.PI; | ||
return angle; | ||
}, | ||
getPointerType(pointer) { | ||
return is.string(pointer.pointerType) | ||
? pointer.pointerType | ||
: is.number(pointer.pointerType) | ||
? [undefined, undefined, 'touch', 'pen', 'mouse'][pointer.pointerType] | ||
// if the PointerEvent API isn't available, then the "pointer" must | ||
// be either a MouseEvent, TouchEvent, or Touch object | ||
: /touch/.test(pointer.type) || pointer instanceof dom.Touch | ||
? 'touch' | ||
: 'mouse'; | ||
}, | ||
// [ event.target, event.currentTarget ] | ||
getEventTargets(event) { | ||
const path = is.func(event.composedPath) ? event.composedPath() : event.path; | ||
return [ | ||
domUtils.getActualElement(path ? path[0] : event.target), | ||
domUtils.getActualElement(event.currentTarget), | ||
]; | ||
}, | ||
newCoords() { | ||
return { | ||
page: { x: 0, y: 0 }, | ||
client: { x: 0, y: 0 }, | ||
timeStamp: 0, | ||
}; | ||
}, | ||
coordsToEvent(coords) { | ||
const event = { | ||
coords, | ||
get page() { return this.coords.page; }, | ||
get client() { return this.coords.client; }, | ||
get timeStamp() { return this.coords.timeStamp; }, | ||
get pageX() { return this.coords.page.x; }, | ||
get pageY() { return this.coords.page.y; }, | ||
get clientX() { return this.coords.client.x; }, | ||
get clientY() { return this.coords.client.y; }, | ||
get pointerId() { return this.coords.pointerId; }, | ||
get target() { return this.coords.target; }, | ||
get type() { return this.coords.type; }, | ||
get pointerType() { return this.coords.pointerType; }, | ||
get buttons() { return this.coords.buttons; }, | ||
}; | ||
return event; | ||
}, | ||
} | ||
return touches; | ||
}, | ||
pointerAverage(pointers) { | ||
const average = { | ||
pageX: 0, | ||
pageY: 0, | ||
clientX: 0, | ||
clientY: 0, | ||
screenX: 0, | ||
screenY: 0 | ||
}; | ||
for (const pointer of pointers) { | ||
for (const prop in average) { | ||
average[prop] += pointer[prop]; | ||
} | ||
} | ||
for (const prop in average) { | ||
average[prop] /= pointers.length; | ||
} | ||
return average; | ||
}, | ||
touchBBox(event) { | ||
if (!event.length && !(event.touches && event.touches.length > 1)) { | ||
return null; | ||
} | ||
const touches = pointerUtils.getTouchPair(event); | ||
const minX = Math.min(touches[0].pageX, touches[1].pageX); | ||
const minY = Math.min(touches[0].pageY, touches[1].pageY); | ||
const maxX = Math.max(touches[0].pageX, touches[1].pageX); | ||
const maxY = Math.max(touches[0].pageY, touches[1].pageY); | ||
return { | ||
x: minX, | ||
y: minY, | ||
left: minX, | ||
top: minY, | ||
right: maxX, | ||
bottom: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY | ||
}; | ||
}, | ||
touchDistance(event, deltaSource) { | ||
const sourceX = deltaSource + 'X'; | ||
const sourceY = deltaSource + 'Y'; | ||
const touches = pointerUtils.getTouchPair(event); | ||
const dx = touches[0][sourceX] - touches[1][sourceX]; | ||
const dy = touches[0][sourceY] - touches[1][sourceY]; | ||
return hypot(dx, dy); | ||
}, | ||
touchAngle(event, deltaSource) { | ||
const sourceX = deltaSource + 'X'; | ||
const sourceY = deltaSource + 'Y'; | ||
const touches = pointerUtils.getTouchPair(event); | ||
const dx = touches[1][sourceX] - touches[0][sourceX]; | ||
const dy = touches[1][sourceY] - touches[0][sourceY]; | ||
const angle = 180 * Math.atan2(dy, dx) / Math.PI; | ||
return angle; | ||
}, | ||
getPointerType(pointer) { | ||
return is.string(pointer.pointerType) ? pointer.pointerType : is.number(pointer.pointerType) ? [undefined, undefined, 'touch', 'pen', 'mouse'][pointer.pointerType] // if the PointerEvent API isn't available, then the "pointer" must | ||
// be either a MouseEvent, TouchEvent, or Touch object | ||
: /touch/.test(pointer.type) || pointer instanceof dom.Touch ? 'touch' : 'mouse'; | ||
}, | ||
// [ event.target, event.currentTarget ] | ||
getEventTargets(event) { | ||
const path = is.func(event.composedPath) ? event.composedPath() : event.path; | ||
return [domUtils.getActualElement(path ? path[0] : event.target), domUtils.getActualElement(event.currentTarget)]; | ||
}, | ||
newCoords() { | ||
return { | ||
page: { | ||
x: 0, | ||
y: 0 | ||
}, | ||
client: { | ||
x: 0, | ||
y: 0 | ||
}, | ||
timeStamp: 0 | ||
}; | ||
}, | ||
coordsToEvent(coords) { | ||
const event = { | ||
coords, | ||
get page() { | ||
return this.coords.page; | ||
}, | ||
get client() { | ||
return this.coords.client; | ||
}, | ||
get timeStamp() { | ||
return this.coords.timeStamp; | ||
}, | ||
get pageX() { | ||
return this.coords.page.x; | ||
}, | ||
get pageY() { | ||
return this.coords.page.y; | ||
}, | ||
get clientX() { | ||
return this.coords.client.x; | ||
}, | ||
get clientY() { | ||
return this.coords.client.y; | ||
}, | ||
get pointerId() { | ||
return this.coords.pointerId; | ||
}, | ||
get target() { | ||
return this.coords.target; | ||
}, | ||
get type() { | ||
return this.coords.type; | ||
}, | ||
get pointerType() { | ||
return this.coords.pointerType; | ||
}, | ||
get buttons() { | ||
return this.coords.buttons; | ||
} | ||
}; | ||
return event; | ||
} | ||
}; | ||
export default pointerUtils; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9pbnRlclV0aWxzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicG9pbnRlclV0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sT0FBTyxNQUFNLFdBQVcsQ0FBQTtBQUMvQixPQUFPLEdBQUcsTUFBTSxjQUFjLENBQUE7QUFDOUIsT0FBTyxLQUFLLFFBQVEsTUFBTSxZQUFZLENBQUE7QUFDdEMsT0FBTyxLQUFLLE1BQU0sU0FBUyxDQUFBO0FBQzNCLE9BQU8sS0FBSyxFQUFFLE1BQU0sTUFBTSxDQUFBO0FBQzFCLE9BQU8sYUFBYSxNQUFNLGlCQUFpQixDQUFBO0FBRTNDLE1BQU0sWUFBWSxHQUFHO0lBQ25CLFVBQVUsQ0FBRSxJQUFJLEVBQUUsR0FBRztRQUNuQixJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxJQUFJLElBQUksRUFBRSxDQUFBO1FBQzNCLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQyxHQUFHLEdBQ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pZW50LnkgfSxcbiAgICAgIGdldCBwb2ludGVySWQgKCkgeyByZXR1cm4gdGhpcy5jb29yZHMucG9pbnRlcklkIH0sXG4gICAgICBnZXQgdGFyZ2V0ICgpIHsgcmV0dXJuIHRoaXMuY29vcmRzLnRhcmdldCB9LFxuICAgICAgZ2V0IHR5cGUgKCkgeyByZXR1cm4gdGhpcy5jb29yZHMudHlwZSB9LFxuICAgICAgZ2V0IHBvaW50ZXJUeXBlICgpIHsgcmV0dXJuIHRoaXMuY29vcmRzLnBvaW50ZXJUeXBlIH0sXG4gICAgICBnZXQgYnV0dG9ucyAoKSB7IHJldHVybiB0aGlzLmNvb3Jkcy5idXR0b25zIH0sXG4gICAgfVxuXG4gICAgcmV0dXJuIGV2ZW50IGFzIHR5cGVvZiBldmVudCAmIEludGVyYWN0LlBvaW50ZXJUeXBlICYgSW50ZXJhY3QuUG9pbnRlckV2ZW50VHlwZVxuICB9LFxufVxuXG5leHBvcnQgZGVmYXVsdCBwb2ludGVyVXRpbHNcblxuZXhwb3J0IGludGVyZmFjZSBNb2NrQ29vcmRzIHtcbiAgcGFnZTogSW50ZXJhY3QuUG9pbnRcbiAgY2xpZW50OiBJbnRlcmFjdC5Qb2ludFxuICB0aW1lU3RhbXA/OiBudW1iZXJcbiAgcG9pbnRlcklkPzogYW55XG4gIHRhcmdldD86IGFueVxuICB0eXBlPzogc3RyaW5nXG4gIHBvaW50ZXJUeXBlPzogc3RyaW5nXG4gIGJ1dHRvbnM/OiBudW1iZXJcbn1cbiJdfQ== | ||
//# sourceMappingURL=pointerUtils.js.map |
54
raf.js
let lastTime = 0; | ||
let request; | ||
let cancel; | ||
function init(window) { | ||
request = window.requestAnimationFrame; | ||
cancel = window.cancelAnimationFrame; | ||
if (!request) { | ||
const vendors = ['ms', 'moz', 'webkit', 'o']; | ||
for (const vendor of vendors) { | ||
request = window[`${vendor}RequestAnimationFrame`]; | ||
cancel = window[`${vendor}CancelAnimationFrame`] || window[`${vendor}CancelRequestAnimationFrame`]; | ||
} | ||
request = window.requestAnimationFrame; | ||
cancel = window.cancelAnimationFrame; | ||
if (!request) { | ||
const vendors = ['ms', 'moz', 'webkit', 'o']; | ||
for (const vendor of vendors) { | ||
request = window[`${vendor}RequestAnimationFrame`]; | ||
cancel = window[`${vendor}CancelAnimationFrame`] || window[`${vendor}CancelRequestAnimationFrame`]; | ||
} | ||
if (!request) { | ||
request = callback => { | ||
const currTime = Date.now(); | ||
const timeToCall = Math.max(0, 16 - (currTime - lastTime)); | ||
// eslint-disable-next-line standard/no-callback-literal | ||
const token = setTimeout(() => { callback(currTime + timeToCall); }, timeToCall); | ||
lastTime = currTime + timeToCall; | ||
return token; | ||
}; | ||
cancel = token => clearTimeout(token); | ||
} | ||
} | ||
if (!request) { | ||
request = callback => { | ||
const currTime = Date.now(); | ||
const timeToCall = Math.max(0, 16 - (currTime - lastTime)); // eslint-disable-next-line standard/no-callback-literal | ||
const token = setTimeout(() => { | ||
callback(currTime + timeToCall); | ||
}, timeToCall); | ||
lastTime = currTime + timeToCall; | ||
return token; | ||
}; | ||
cancel = token => clearTimeout(token); | ||
} | ||
} | ||
export default { | ||
request: callback => request(callback), | ||
cancel: token => cancel(token), | ||
init, | ||
request: callback => request(callback), | ||
cancel: token => cancel(token), | ||
init | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmFmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsicmFmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLElBQUksUUFBUSxHQUFHLENBQUMsQ0FBQTtBQUNoQixJQUFJLE9BQU8sQ0FBQTtBQUNYLElBQUksTUFBTSxDQUFBO0FBRVYsU0FBUyxJQUFJLENBQUUsTUFBTTtJQUNuQixPQUFPLEdBQUcsTUFBTSxDQUFDLHFCQUFxQixDQUFBO0lBQ3RDLE1BQU0sR0FBRyxNQUFNLENBQUMsb0JBQW9CLENBQUE7SUFFcE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b25zdCB0b2tlbiA9IHNldFRpbWVvdXQoKCkgPT4geyBjYWxsYmFjayhjdXJyVGltZSArIHRpbWVUb0NhbGwpIH0sXG4gICAgICAgIHRpbWVUb0NhbGwpXG5cbiAgICAgIGxhc3RUaW1lID0gY3VyclRpbWUgKyB0aW1lVG9DYWxsXG4gICAgICByZXR1cm4gdG9rZW5cbiAgICB9XG5cbiAgICBjYW5jZWwgPSB0b2tlbiA9PiBjbGVhclRpbWVvdXQodG9rZW4pXG4gIH1cbn1cblxuZXhwb3J0IGRlZmF1bHQge1xuICByZXF1ZXN0OiBjYWxsYmFjayA9PiByZXF1ZXN0KGNhbGxiYWNrKSxcbiAgY2FuY2VsOiB0b2tlbiA9PiBjYW5jZWwodG9rZW4pLFxuICBpbml0LFxufVxuIl19 | ||
//# sourceMappingURL=raf.js.map |
97
rect.js
@@ -1,58 +0,63 @@ | ||
import { closest, getElementRect, parentNode } from './domUtils'; | ||
import extend from './extend'; | ||
import * as is from './is'; | ||
import { closest, getElementRect, parentNode } from "./domUtils.js"; | ||
import extend from "./extend.js"; | ||
import * as is from "./is.js"; | ||
export function getStringOptionResult(value, target, element) { | ||
if (value === 'parent') { | ||
return parentNode(element); | ||
} | ||
if (value === 'self') { | ||
return target.getRect(element); | ||
} | ||
return closest(element, value); | ||
if (value === 'parent') { | ||
return parentNode(element); | ||
} | ||
if (value === 'self') { | ||
return target.getRect(element); | ||
} | ||
return closest(element, value); | ||
} | ||
export function resolveRectLike(value, target, element, functionArgs) { | ||
if (is.string(value)) { | ||
value = getStringOptionResult(value, target, element); | ||
} | ||
else if (is.func(value)) { | ||
value = value(...functionArgs); | ||
} | ||
if (is.element(value)) { | ||
value = getElementRect(value); | ||
} | ||
return value; | ||
if (is.string(value)) { | ||
value = getStringOptionResult(value, target, element); | ||
} else if (is.func(value)) { | ||
value = value(...functionArgs); | ||
} | ||
if (is.element(value)) { | ||
value = getElementRect(value); | ||
} | ||
return value; | ||
} | ||
export function rectToXY(rect) { | ||
return rect && { | ||
x: 'x' in rect ? rect.x : rect.left, | ||
y: 'y' in rect ? rect.y : rect.top, | ||
}; | ||
return rect && { | ||
x: 'x' in rect ? rect.x : rect.left, | ||
y: 'y' in rect ? rect.y : rect.top | ||
}; | ||
} | ||
export function xywhToTlbr(rect) { | ||
if (rect && !('left' in rect && 'top' in rect)) { | ||
rect = extend({}, rect); | ||
rect.left = rect.x || 0; | ||
rect.top = rect.y || 0; | ||
rect.right = rect.right || (rect.left + rect.width); | ||
rect.bottom = rect.bottom || (rect.top + rect.height); | ||
} | ||
return rect; | ||
if (rect && !('left' in rect && 'top' in rect)) { | ||
rect = extend({}, rect); | ||
rect.left = rect.x || 0; | ||
rect.top = rect.y || 0; | ||
rect.right = rect.right || rect.left + rect.width; | ||
rect.bottom = rect.bottom || rect.top + rect.height; | ||
} | ||
return rect; | ||
} | ||
export function tlbrToXywh(rect) { | ||
if (rect && !('x' in rect && 'y' in rect)) { | ||
rect = extend({}, rect); | ||
rect.x = rect.left || 0; | ||
rect.y = rect.top || 0; | ||
rect.width = rect.width || (rect.right - rect.x); | ||
rect.height = rect.height || (rect.bottom - rect.y); | ||
} | ||
return rect; | ||
if (rect && !('x' in rect && 'y' in rect)) { | ||
rect = extend({}, rect); | ||
rect.x = rect.left || 0; | ||
rect.y = rect.top || 0; | ||
rect.width = rect.width || rect.right - rect.x; | ||
rect.height = rect.height || rect.bottom - rect.y; | ||
} | ||
return rect; | ||
} | ||
export default { | ||
getStringOptionResult, | ||
resolveRectLike, | ||
rectToXY, | ||
xywhToTlbr, | ||
tlbrToXywh, | ||
getStringOptionResult, | ||
resolveRectLike, | ||
rectToXY, | ||
xywhToTlbr, | ||
tlbrToXywh | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInJlY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0F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luIHJlY3QgJiYgJ3RvcCcgaW4gcmVjdCkpIHtcbiAgICByZWN0ID0gZXh0ZW5kKHt9LCByZWN0KVxuXG4gICAgcmVjdC5sZWZ0ICAgPSByZWN0LnggfHwgMFxuICAgIHJlY3QudG9wICAgID0gcmVjdC55IHx8IDBcbiAgICByZWN0LnJpZ2h0ICA9IHJlY3QucmlnaHQgICB8fCAocmVjdC5sZWZ0ICsgcmVjdC53aWR0aClcbiAgICByZWN0LmJvdHRvbSA9IHJlY3QuYm90dG9tICB8fCAocmVjdC50b3AgKyByZWN0LmhlaWdodClcbiAgfVxuXG4gIHJldHVybiByZWN0XG59XG5cbmV4cG9ydCBmdW5jdGlvbiB0bGJyVG9YeXdoIChyZWN0KSB7XG4gIGlmIChyZWN0ICYmICEoJ3gnIGluIHJlY3QgJiYgJ3knIGluIHJlY3QpKSB7XG4gICAgcmVjdCA9IGV4dGVuZCh7fSwgcmVjdClcblxuICAgIHJlY3QueCAgICAgID0gcmVjdC5sZWZ0IHx8IDBcbiAgICByZWN0LnkgICAgICA9IHJlY3QudG9wICB8fCAwXG4gICAgcmVjdC53aWR0aCAgPSByZWN0LndpZHRoICB8fCAocmVjdC5yaWdodCAgLSByZWN0LngpXG4gICAgcmVjdC5oZWlnaHQgPSByZWN0LmhlaWdodCB8fCAocmVjdC5ib3R0b20gLSByZWN0LnkpXG4gIH1cblxuICByZXR1cm4gcmVjdFxufVxuXG5leHBvcnQgZGVmYXVsdCB7XG4gIGdldFN0cmluZ09wdGlvblJlc3VsdCxcbiAgcmVzb2x2ZVJlY3RMaWtlLFxuICByZWN0VG9YWSxcbiAgeHl3aFRvVGxicixcbiAgdGxiclRvWHl3aCxcbn1cbiJdfQ== | ||
//# sourceMappingURL=rect.js.map |
@@ -5,5 +5,18 @@ declare function createGrid(grid: (Interact.Rect | Interact.Point) & { | ||
offset: Interact.Point; | ||
}): (x: any, y: any) => { | ||
range: number; | ||
}): { | ||
(x: any, y: any): { | ||
range: number; | ||
}; | ||
_isSnapGrid: boolean; | ||
grid: (import("../../types/types").Point & { | ||
range?: number; | ||
limits: import("../../types/types").Rect; | ||
offset: import("../../types/types").Point; | ||
}) | (import("../../types/types").Rect & { | ||
range?: number; | ||
limits: import("../../types/types").Rect; | ||
offset: import("../../types/types").Point; | ||
}); | ||
coordFields: string[][]; | ||
}; | ||
export default createGrid; |
function createGrid(grid) { | ||
const coordFields = [ | ||
['x', 'y'], | ||
['left', 'top'], | ||
['right', 'bottom'], | ||
['width', 'height'], | ||
].filter(([xField, yField]) => xField in grid || yField in grid); | ||
return function (x, y) { | ||
const { range, limits = { | ||
left: -Infinity, | ||
right: Infinity, | ||
top: -Infinity, | ||
bottom: Infinity, | ||
}, offset = { x: 0, y: 0 }, } = grid; | ||
const result = { range }; | ||
for (const [xField, yField] of coordFields) { | ||
const gridx = Math.round((x - offset.x) / grid[xField]); | ||
const gridy = Math.round((y - offset.y) / grid[yField]); | ||
result[xField] = Math.max(limits.left, Math.min(limits.right, gridx * grid[xField] + offset.x)); | ||
result[yField] = Math.max(limits.top, Math.min(limits.bottom, gridy * grid[yField] + offset.y)); | ||
} | ||
return result; | ||
const coordFields = [['x', 'y'], ['left', 'top'], ['right', 'bottom'], ['width', 'height']].filter(([xField, yField]) => xField in grid || yField in grid); | ||
const gridFunc = function snapGrid(x, y) { | ||
const { | ||
range, | ||
limits = { | ||
left: -Infinity, | ||
right: Infinity, | ||
top: -Infinity, | ||
bottom: Infinity | ||
}, | ||
offset = { | ||
x: 0, | ||
y: 0 | ||
} | ||
} = grid; | ||
const result = { | ||
range | ||
}; | ||
for (const [xField, yField] of coordFields) { | ||
const gridx = Math.round((x - offset.x) / grid[xField]); | ||
const gridy = Math.round((y - offset.y) / grid[yField]); | ||
result[xField] = Math.max(limits.left, Math.min(limits.right, gridx * grid[xField] + offset.x)); | ||
result[yField] = Math.max(limits.top, Math.min(limits.bottom, gridy * grid[yField] + offset.y)); | ||
} | ||
return result; | ||
}; | ||
gridFunc._isSnapGrid = true; | ||
gridFunc.grid = grid; | ||
gridFunc.coordFields = coordFields; | ||
return gridFunc; | ||
} | ||
export default createGrid; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImdyaWQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsU0FBUyxVQUFVLENBQUUsSUFBMEc7SUFDN0gsTUFBTSxXQUFXLEdBQUc7UUFDbEIsQ0FBQyxHQUFHLEVBQUUsR0FBRyxDQUFDO1FBQ1YsQ0FBQyxNQUFNLEVBQUUsS0FBSyxDQUFDO1FBQ2YsQ0FBQyxPQUFPLEVBQUUsUUFBUSxDQUFDO1FBQ25CLENBQUMsT0FBTyxFQUFFLFFBQVEsQ0FBQztLQUNwQixDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxFQUFFLEVBQUUsQ0FBQyxNQUFNLElBQUksSUFBSSxJQUFJLE1BQU0sSUFBSSxJQUFJLENBQUMsQ0FBQTtJQUVoRSxPQUFPLFVBQVUsQ0FBQyxFQUFFLENBQUM7UUFDbkIsTUFBTSxFQUNKLEtBQUssRUFDTCxNQUFNLEdBQUc7WUFDUCxJQUFJLEVBQUksQ0FBQyxRQUFRO1lBQ2pCLEtBQUssRUFBSSxRQUFRO1lBQ2pCLEdBQUcsRUFBSyxDQUFDLFFBQVE7WUFDakIsTUFBTSxFQUFHLFFBQVE7U0FDbEIsRUFDRCxNQUFNLEdBQUcsRUFBRSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsR0FDeEIsR0FBRyxJQUFJLENBQUE7UUFFUixNQUFNLE1BQU0sR0FBRyxFQUFFLEtBQUssRUFBRSxDQUFBO1FBRXhCLEtBQUssTUFBTSxDQUFDLE1BQU0sRUFBRSxNQUFNLENBQUMsSUFBSSxXQUFXLEV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Z3JpZHkgKiBncmlkW3lGaWVsZF0gKyBvZmZzZXQueSkpXG4gICAgfVxuXG4gICAgcmV0dXJuIHJlc3VsdFxuICB9XG59XG5cbmV4cG9ydCBkZWZhdWx0IGNyZWF0ZUdyaWRcbiJdfQ== | ||
//# sourceMappingURL=grid.js.map |
@@ -1,3 +0,3 @@ | ||
import grid from './grid'; | ||
import grid from "./grid.js"; | ||
export { grid }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLElBQUksTUFBTSxRQUFRLENBQUE7QUFFekIsT0FBTyxFQUFFLElBQUksRUFBRSxDQUFBIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGdyaWQgZnJvbSAnLi9ncmlkJ1xuXG5leHBvcnQgeyBncmlkIH1cbiJdfQ== | ||
//# sourceMappingURL=index.js.map |
@@ -1,38 +0,39 @@ | ||
import isWindow from './isWindow'; | ||
import isWindow from "./isWindow.js"; | ||
const win = { | ||
realWindow: undefined, | ||
window: undefined, | ||
getWindow, | ||
init, | ||
realWindow: undefined, | ||
window: undefined, | ||
getWindow, | ||
init | ||
}; | ||
export function init(window) { | ||
// get wrapped window if using Shadow DOM polyfill | ||
win.realWindow = window; | ||
// create a TextNode | ||
const el = window.document.createTextNode(''); | ||
// check if it's wrapped by a polyfill | ||
if (el.ownerDocument !== window.document && | ||
typeof window.wrap === 'function' && | ||
window.wrap(el) === el) { | ||
// use wrapped window | ||
window = window.wrap(window); | ||
} | ||
win.window = window; | ||
// get wrapped window if using Shadow DOM polyfill | ||
win.realWindow = window; // create a TextNode | ||
const el = window.document.createTextNode(''); // check if it's wrapped by a polyfill | ||
if (el.ownerDocument !== window.document && typeof window.wrap === 'function' && window.wrap(el) === el) { | ||
// use wrapped window | ||
window = window.wrap(window); | ||
} | ||
win.window = window; | ||
} | ||
if (typeof window === 'undefined') { | ||
win.window = undefined; | ||
win.realWindow = undefined; | ||
win.window = undefined; | ||
win.realWindow = undefined; | ||
} else { | ||
init(window); | ||
} | ||
else { | ||
init(window); | ||
} | ||
export function getWindow(node) { | ||
if (isWindow(node)) { | ||
return node; | ||
} | ||
const rootNode = (node.ownerDocument || node); | ||
return rootNode.defaultView || win.window; | ||
if (isWindow(node)) { | ||
return node; | ||
} | ||
const rootNode = node.ownerDocument || node; | ||
return rootNode.defaultView || win.window; | ||
} | ||
win.init = init; | ||
export default win; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2luZG93LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsid2luZG93LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sUUFBUSxNQUFNLFlBQVksQ0FBQTtBQUVqQyxNQUFNLEdBQUcsR0FBRztJQUNWLFVBQVUsRUFBRSxTQUFtQjtJQUMvQixNQUFNLEVBQUUsU0FBbUI7SUFDM0IsU0FBUztJQUNULElBQUk7Q0FDTCxDQUFBO0FBRUQsTUFBTSxVQUFVLElBQUksQ0FBRSxNQUE0QztJQUNoRSxrREFBa0Q7SUFFbEQsR0FBRyxDQUFDLFVBQVUsR0FBRyxNQUFNLENBQUE7SUFFdkIsb0JBQW9CO0lBQ3BCLE1BQU0sRUFBRSxHQUFHLE1BQU0sQ0FBQyxRQUFRLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQyxDQUFBO0lBRTdDLHNDQUFzQztJQUN0QyxJQUFJLEVBQUUsQ0FBQyxhQUFhLEtBQUssTUFBTSxDQUFDLFFBQVE7UUFDcEMsT0FBTyxNQUFNLENBQUMsSUFBSSxLQUFLLFVBQVU7UUFDbkMsTUFBTSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLEVBQUU7UUFDeEIscUJBQXFCO1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pbmcgU2hhZG93IERPTSBwb2x5ZmlsbFxuXG4gIHdpbi5yZWFsV2luZG93ID0gd2luZG93XG5cbiAgLy8gY3JlYXRlIGEgVGV4dE5vZGVcbiAgY29uc3QgZWwgPSB3aW5kb3cuZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUoJycpXG5cbiAgLy8gY2hlY2sgaWYgaXQncyB3cmFwcGVkIGJ5IGEgcG9seWZpbGxcbiAgaWYgKGVsLm93bmVyRG9jdW1lbnQgIT09IHdpbmRvdy5kb2N1bWVudCAmJlxuICAgICAgdHlwZW9mIHdpbmRvdy53cmFwID09PSAnZnVuY3Rpb24nICYmXG4gICAgd2luZG93LndyYXAoZWwpID09PSBlbCkge1xuICAgIC8vIHVzZSB3cmFwcGVkIHdpbmRvd1xuICAgIHdpbmRvdyA9IHdpbmRvdy53cmFwKHdpbmRvdylcbiAgfVxuXG4gIHdpbi53aW5kb3cgPSB3aW5kb3dcbn1cblxuaWYgKHR5cGVvZiB3aW5kb3cgPT09ICd1bmRlZmluZWQnKSB7XG4gIHdpbi53aW5kb3cgICAgID0gdW5kZWZpbmVkXG4gIHdpbi5yZWFsV2luZG93ID0gdW5kZWZpbmVkXG59XG5lbHNlIHtcbiAgaW5pdCh3aW5kb3cpXG59XG5cbmV4cG9ydCBmdW5jdGlvbiBnZXRXaW5kb3cgKG5vZGUpIHtcbiAgaWYgKGlzV2luZG93KG5vZGUpKSB7XG4gICAgcmV0dXJuIG5vZGVcbiAgfVxuXG4gIGNvbnN0IHJvb3ROb2RlID0gKG5vZGUub3duZXJEb2N1bWVudCB8fCBub2RlKVxuXG4gIHJldHVybiByb290Tm9kZS5kZWZhdWx0VmlldyB8fCB3aW4ud2luZG93XG59XG5cbndpbi5pbml0ID0gaW5pdFxuXG5leHBvcnQgZGVmYXVsdCB3aW5cbiJdfQ== | ||
//# sourceMappingURL=window.js.map |
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
66
141426
1563