@human-kit/ui 1.4.4 → 1.4.5
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/primitives/motion.js +20 -4
- package/package.json +1 -1
|
@@ -37,6 +37,22 @@ export function getMotionTime(element) {
|
|
|
37
37
|
const animationTime = getMaxTime(styles.animationDuration, styles.animationDelay);
|
|
38
38
|
return Math.max(transitionTime, animationTime);
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether the element still has a transition or an animation in progress, at one of its end events.
|
|
42
|
+
*
|
|
43
|
+
* It asks the element, not the clock. The clock starts in a frame callback, and the animation
|
|
44
|
+
* started at the time of that frame, before the callback: when the frame ran late, the time measured
|
|
45
|
+
* at the end event came out short of the duration, and the last end event was ignored. The motion
|
|
46
|
+
* then finished on the fallback timer, 50ms late — long enough to show an exit animation without a
|
|
47
|
+
* fill mode at full opacity again: an overlay that closes, opens and closes. The clock remains only
|
|
48
|
+
* where the browser cannot list the animations.
|
|
49
|
+
*/
|
|
50
|
+
function isStillMoving(element, startTime, total) {
|
|
51
|
+
if (typeof element.getAnimations !== 'function') {
|
|
52
|
+
return performance.now() - startTime < total - 5;
|
|
53
|
+
}
|
|
54
|
+
return element.getAnimations().some((animation) => animation.playState === 'running');
|
|
55
|
+
}
|
|
40
56
|
/**
|
|
41
57
|
* Call `onComplete` once the element's current transition/animation finishes. Resolves on the next
|
|
42
58
|
* frame when there is no motion (e.g. prefers-reduced-motion), listens for animation/transition end
|
|
@@ -73,10 +89,10 @@ export function trackMotionEnd(element, onComplete) {
|
|
|
73
89
|
return;
|
|
74
90
|
// A multi-property transition (e.g. `opacity 150ms, transform 300ms`)
|
|
75
91
|
// fires one end event per property; finishing on the first one cut the
|
|
76
|
-
// motion short (overlays unmounted mid-exit).
|
|
77
|
-
//
|
|
78
|
-
// still covers the case where the final event never fires.
|
|
79
|
-
if (
|
|
92
|
+
// motion short (overlays unmounted mid-exit). So an end event only
|
|
93
|
+
// finishes once nothing else on the element still moves — the timeout
|
|
94
|
+
// below still covers the case where the final event never fires.
|
|
95
|
+
if (isStillMoving(element, startTime, total))
|
|
80
96
|
return;
|
|
81
97
|
finish();
|
|
82
98
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-kit/ui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "Accessible, typed UI components for Svelte 5 — shipped as native ESM with per-component subpath exports so bundlers only include what you import.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Agustin Delgado <agustindariodelgado@gmail.com>",
|