swup 3.0.6 → 3.0.8
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/Swup.cjs +1 -1
- package/dist/Swup.cjs.map +1 -1
- package/dist/Swup.modern.js +2 -0
- package/dist/Swup.modern.js.map +1 -0
- package/dist/Swup.module.js +1 -1
- package/dist/Swup.module.js.map +1 -1
- package/dist/Swup.umd.js +1 -1
- package/dist/Swup.umd.js.map +1 -1
- package/dist/types/Swup.d.ts +4 -6
- package/dist/types/helpers/delegateEvent.d.ts +2 -4
- package/dist/types/modules/events.d.ts +5 -5
- package/dist/types/modules/getAnchorElement.d.ts +7 -0
- package/package.json +3 -3
- package/src/Swup.ts +3 -3
- package/src/__test__/index.test.ts +2 -2
- package/src/helpers/delegateEvent.ts +8 -7
- package/src/modules/events.ts +5 -5
- package/src/modules/getAnchorElement.ts +19 -9
- package/src/modules/getAnimationPromises.ts +18 -14
|
@@ -35,31 +35,35 @@ export function getAnimationPromises(
|
|
|
35
35
|
|
|
36
36
|
const animatedElements = queryAll(selector, document.body);
|
|
37
37
|
|
|
38
|
-
// Warn if no
|
|
38
|
+
// Warn if no elements match the animationSelector, but keep things going
|
|
39
39
|
if (!animatedElements.length) {
|
|
40
|
-
console.warn(`[swup] No
|
|
40
|
+
console.warn(`[swup] No elements found matching animationSelector \`${selector}\``);
|
|
41
41
|
return [Promise.resolve()];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
const animationPromises = animatedElements
|
|
45
|
+
.map((element) => getAnimationPromiseForElement(element))
|
|
46
|
+
.filter(Boolean) as Promise<void>[];
|
|
47
|
+
|
|
48
|
+
if (!animationPromises.length) {
|
|
49
|
+
console.warn(
|
|
50
|
+
`[swup] No CSS animation duration defined on elements matching \`${selector}\``
|
|
51
|
+
);
|
|
52
|
+
return [Promise.resolve()];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return animationPromises;
|
|
45
56
|
}
|
|
46
57
|
|
|
47
58
|
const isTransitionOrAnimationEvent = (event: any): event is TransitionEvent | AnimationEvent =>
|
|
48
|
-
|
|
59
|
+
[transitionEndEvent, animationEndEvent].includes(event.type);
|
|
49
60
|
|
|
50
|
-
function getAnimationPromiseForElement(
|
|
51
|
-
|
|
52
|
-
selector: string,
|
|
53
|
-
expectedType: 'animation' | 'transition' | null = null
|
|
54
|
-
): Promise<void> {
|
|
55
|
-
const { type, timeout, propCount } = getTransitionInfo(element, expectedType);
|
|
61
|
+
function getAnimationPromiseForElement(element: Element): Promise<void> | undefined {
|
|
62
|
+
const { type, timeout, propCount } = getTransitionInfo(element);
|
|
56
63
|
|
|
57
64
|
// Resolve immediately if no transition defined
|
|
58
65
|
if (!type || !timeout) {
|
|
59
|
-
|
|
60
|
-
`[swup] No CSS transition duration defined for element of selector ${selector}`
|
|
61
|
-
);
|
|
62
|
-
return Promise.resolve();
|
|
66
|
+
return undefined;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
return new Promise((resolve) => {
|