motion-dom 11.16.0 → 11.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js
CHANGED
|
@@ -363,7 +363,7 @@ function hover(elementOrSelector, onHoverStart, options = {}) {
|
|
|
363
363
|
const onPointerEnter = filterEvents$1((enterEvent) => {
|
|
364
364
|
const { target } = enterEvent;
|
|
365
365
|
const onHoverEnd = onHoverStart(enterEvent);
|
|
366
|
-
if (
|
|
366
|
+
if (typeof onHoverEnd !== "function" || !target)
|
|
367
367
|
return;
|
|
368
368
|
const onPointerLeave = filterEvents$1((leaveEvent) => {
|
|
369
369
|
onHoverEnd(leaveEvent);
|
|
@@ -377,6 +377,25 @@ function hover(elementOrSelector, onHoverStart, options = {}) {
|
|
|
377
377
|
return cancel;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Recursively traverse up the tree to check whether the provided child node
|
|
382
|
+
* is the parent or a descendant of it.
|
|
383
|
+
*
|
|
384
|
+
* @param parent - Element to find
|
|
385
|
+
* @param child - Element to test against parent
|
|
386
|
+
*/
|
|
387
|
+
const isNodeOrChild = (parent, child) => {
|
|
388
|
+
if (!child) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
else if (parent === child) {
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
return isNodeOrChild(parent, child.parentElement);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
|
|
380
399
|
const isPrimaryPointer = (event) => {
|
|
381
400
|
if (event.pointerType === "mouse") {
|
|
382
401
|
return typeof event.button !== "number" || event.button <= 0;
|
|
@@ -394,6 +413,17 @@ const isPrimaryPointer = (event) => {
|
|
|
394
413
|
}
|
|
395
414
|
};
|
|
396
415
|
|
|
416
|
+
const focusableElements = new Set([
|
|
417
|
+
"BUTTON",
|
|
418
|
+
"INPUT",
|
|
419
|
+
"SELECT",
|
|
420
|
+
"TEXTAREA",
|
|
421
|
+
"A",
|
|
422
|
+
]);
|
|
423
|
+
function isElementKeyboardAccessible(element) {
|
|
424
|
+
return focusableElements.has(element.tagName) || element.tabIndex !== -1;
|
|
425
|
+
}
|
|
426
|
+
|
|
397
427
|
const isPressing = new WeakSet();
|
|
398
428
|
|
|
399
429
|
/**
|
|
@@ -431,36 +461,6 @@ const enableKeyboardPress = (focusEvent, eventOptions) => {
|
|
|
431
461
|
element.addEventListener("blur", () => element.removeEventListener("keydown", handleKeydown), eventOptions);
|
|
432
462
|
};
|
|
433
463
|
|
|
434
|
-
const focusableElements = new Set([
|
|
435
|
-
"BUTTON",
|
|
436
|
-
"INPUT",
|
|
437
|
-
"SELECT",
|
|
438
|
-
"TEXTAREA",
|
|
439
|
-
"A",
|
|
440
|
-
]);
|
|
441
|
-
function isElementKeyboardAccessible(element) {
|
|
442
|
-
return focusableElements.has(element.tagName) || element.tabIndex !== -1;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Recursively traverse up the tree to check whether the provided child node
|
|
447
|
-
* is the parent or a descendant of it.
|
|
448
|
-
*
|
|
449
|
-
* @param parent - Element to find
|
|
450
|
-
* @param child - Element to test against parent
|
|
451
|
-
*/
|
|
452
|
-
const isNodeOrChild = (parent, child) => {
|
|
453
|
-
if (!child) {
|
|
454
|
-
return false;
|
|
455
|
-
}
|
|
456
|
-
else if (parent === child) {
|
|
457
|
-
return true;
|
|
458
|
-
}
|
|
459
|
-
else {
|
|
460
|
-
return isNodeOrChild(parent, child.parentElement);
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
|
|
464
464
|
/**
|
|
465
465
|
* Filter out events that are not primary pointer events, or are triggering
|
|
466
466
|
* while a Motion gesture is active.
|
|
@@ -502,7 +502,7 @@ function press(elementOrSelector, onPressStart, options = {}) {
|
|
|
502
502
|
return;
|
|
503
503
|
}
|
|
504
504
|
isPressing.delete(element);
|
|
505
|
-
if (onPressEnd) {
|
|
505
|
+
if (typeof onPressEnd === "function") {
|
|
506
506
|
onPressEnd(endEvent, { success });
|
|
507
507
|
}
|
|
508
508
|
};
|
|
@@ -517,7 +517,8 @@ function press(elementOrSelector, onPressStart, options = {}) {
|
|
|
517
517
|
window.addEventListener("pointercancel", onPointerCancel, eventOptions);
|
|
518
518
|
};
|
|
519
519
|
elements.forEach((element) => {
|
|
520
|
-
if (!isElementKeyboardAccessible(element)
|
|
520
|
+
if (!isElementKeyboardAccessible(element) &&
|
|
521
|
+
element.getAttribute("tabindex") === null) {
|
|
521
522
|
element.tabIndex = 0;
|
|
522
523
|
}
|
|
523
524
|
const target = options.useGlobalTarget ? window : element;
|
|
@@ -24,7 +24,7 @@ function hover(elementOrSelector, onHoverStart, options = {}) {
|
|
|
24
24
|
const onPointerEnter = filterEvents((enterEvent) => {
|
|
25
25
|
const { target } = enterEvent;
|
|
26
26
|
const onHoverEnd = onHoverStart(enterEvent);
|
|
27
|
-
if (
|
|
27
|
+
if (typeof onHoverEnd !== "function" || !target)
|
|
28
28
|
return;
|
|
29
29
|
const onPointerLeave = filterEvents((leaveEvent) => {
|
|
30
30
|
onHoverEnd(leaveEvent);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isDragActive } from '../drag/state/is-active.mjs';
|
|
2
|
+
import { isNodeOrChild } from '../utils/is-node-or-child.mjs';
|
|
2
3
|
import { isPrimaryPointer } from '../utils/is-primary-pointer.mjs';
|
|
3
4
|
import { setupGesture } from '../utils/setup.mjs';
|
|
4
|
-
import { enableKeyboardPress } from './utils/keyboard.mjs';
|
|
5
5
|
import { isElementKeyboardAccessible } from './utils/is-keyboard-accessible.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { enableKeyboardPress } from './utils/keyboard.mjs';
|
|
7
7
|
import { isPressing } from './utils/state.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -47,7 +47,7 @@ function press(elementOrSelector, onPressStart, options = {}) {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
isPressing.delete(element);
|
|
50
|
-
if (onPressEnd) {
|
|
50
|
+
if (typeof onPressEnd === "function") {
|
|
51
51
|
onPressEnd(endEvent, { success });
|
|
52
52
|
}
|
|
53
53
|
};
|
|
@@ -62,7 +62,8 @@ function press(elementOrSelector, onPressStart, options = {}) {
|
|
|
62
62
|
window.addEventListener("pointercancel", onPointerCancel, eventOptions);
|
|
63
63
|
};
|
|
64
64
|
elements.forEach((element) => {
|
|
65
|
-
if (!isElementKeyboardAccessible(element)
|
|
65
|
+
if (!isElementKeyboardAccessible(element) &&
|
|
66
|
+
element.getAttribute("tabindex") === null) {
|
|
66
67
|
element.tabIndex = 0;
|
|
67
68
|
}
|
|
68
69
|
const target = options.useGlobalTarget ? window : element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motion-dom",
|
|
3
|
-
"version": "11.16.
|
|
3
|
+
"version": "11.16.3",
|
|
4
4
|
"author": "Matt Perry",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/motiondivision/motion",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"build": "yarn clean && tsc -p . && rollup -c",
|
|
24
24
|
"dev": "concurrently -c blue,red -n tsc,rollup --kill-others \"tsc --watch -p . --preserveWatchOutput\" \"rollup --config --watch --no-watch.clearScreen\""
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "e8c2bdf87d22ae5f036caefc19acc6c1ac192549"
|
|
27
27
|
}
|