first commit
This commit is contained in:
20
node_modules/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs
generated
vendored
Normal file
20
node_modules/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Recursively traverse up the tree to check whether the provided child node
|
||||
* is the parent or a descendant of it.
|
||||
*
|
||||
* @param parent - Element to find
|
||||
* @param child - Element to test against parent
|
||||
*/
|
||||
const isNodeOrChild = (parent, child) => {
|
||||
if (!child) {
|
||||
return false;
|
||||
}
|
||||
else if (parent === child) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return isNodeOrChild(parent, child.parentElement);
|
||||
}
|
||||
};
|
||||
|
||||
export { isNodeOrChild };
|
||||
18
node_modules/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs
generated
vendored
Normal file
18
node_modules/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
const isPrimaryPointer = (event) => {
|
||||
if (event.pointerType === "mouse") {
|
||||
return typeof event.button !== "number" || event.button <= 0;
|
||||
}
|
||||
else {
|
||||
/**
|
||||
* isPrimary is true for all mice buttons, whereas every touch point
|
||||
* is regarded as its own input. So subsequent concurrent touch points
|
||||
* will be false.
|
||||
*
|
||||
* Specifically match against false here as incomplete versions of
|
||||
* PointerEvents in very old browser might have it set as undefined.
|
||||
*/
|
||||
return event.isPrimary !== false;
|
||||
}
|
||||
};
|
||||
|
||||
export { isPrimaryPointer };
|
||||
15
node_modules/motion-dom/dist/es/gestures/utils/setup.mjs
generated
vendored
Normal file
15
node_modules/motion-dom/dist/es/gestures/utils/setup.mjs
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { resolveElements } from '../../utils/resolve-elements.mjs';
|
||||
|
||||
function setupGesture(elementOrSelector, options) {
|
||||
const elements = resolveElements(elementOrSelector);
|
||||
const gestureAbortController = new AbortController();
|
||||
const eventOptions = {
|
||||
passive: true,
|
||||
...options,
|
||||
signal: gestureAbortController.signal,
|
||||
};
|
||||
const cancel = () => gestureAbortController.abort();
|
||||
return [elements, eventOptions, cancel];
|
||||
}
|
||||
|
||||
export { setupGesture };
|
||||
Reference in New Issue
Block a user