motion-dom 12.6.3-alpha.0 → 12.6.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.
Files changed (36) hide show
  1. package/dist/cjs/index.js +381 -236
  2. package/dist/es/animation/{controls/BaseGroup.mjs → GroupAnimation.mjs} +4 -5
  3. package/dist/es/animation/GroupAnimationWithThen.mjs +9 -0
  4. package/dist/es/animation/NativeAnimation.mjs +159 -0
  5. package/dist/es/animation/generators/utils/is-generator.mjs +1 -1
  6. package/dist/es/animation/keyframes/get-final.mjs +12 -0
  7. package/dist/es/animation/keyframes/hydrate.mjs +26 -0
  8. package/dist/es/animation/utils/get-value-transition.mjs +3 -5
  9. package/dist/es/animation/waapi/easing/cubic-bezier.mjs +3 -0
  10. package/dist/es/animation/waapi/easing/is-supported.mjs +14 -0
  11. package/dist/es/animation/waapi/easing/map-easing.mjs +26 -0
  12. package/dist/es/animation/waapi/easing/supported.mjs +15 -0
  13. package/dist/es/animation/waapi/start-waapi-animation.mjs +37 -0
  14. package/dist/es/animation/waapi/supports/partial-keyframes.mjs +13 -0
  15. package/dist/es/animation/waapi/utils/apply-generator.mjs +14 -0
  16. package/dist/es/animation/waapi/utils/linear.mjs +1 -3
  17. package/dist/es/animation/waapi/utils/px-values.mjs +39 -0
  18. package/dist/es/gestures/press/index.mjs +1 -1
  19. package/dist/es/index.mjs +8 -3
  20. package/dist/es/render/dom/style.mjs +15 -0
  21. package/dist/es/utils/resolve-elements.mjs +2 -7
  22. package/dist/es/utils/supports/flags.mjs +1 -3
  23. package/dist/es/utils/supports/memo.mjs +1 -1
  24. package/dist/es/value/index.mjs +1 -1
  25. package/dist/es/view/queue.mjs +1 -2
  26. package/dist/es/view/start.mjs +22 -17
  27. package/dist/es/view/utils/get-view-animations.mjs +1 -2
  28. package/dist/index.d.ts +90 -43
  29. package/dist/motion-dom.dev.js +381 -236
  30. package/dist/motion-dom.js +1 -1
  31. package/package.json +3 -3
  32. package/dist/es/animation/controls/Group.mjs +0 -13
  33. package/dist/es/animation/waapi/NativeAnimationControls.mjs +0 -83
  34. package/dist/es/animation/waapi/PseudoAnimation.mjs +0 -15
  35. package/dist/es/animation/waapi/utils/convert-options.mjs +0 -55
  36. package/dist/es/animation/waapi/utils/easing.mjs +0 -44
@@ -1,14 +1,13 @@
1
- import { supportsScrollTimeline } from '../../utils/supports/scroll-timeline.mjs';
1
+ import { supportsScrollTimeline } from '../utils/supports/scroll-timeline.mjs';
2
2
 
3
- class BaseGroupPlaybackControls {
3
+ class GroupAnimation {
4
4
  constructor(animations) {
5
5
  // Bound to accomodate common `return animation.stop` pattern
6
6
  this.stop = () => this.runAll("stop");
7
7
  this.animations = animations.filter(Boolean);
8
8
  }
9
9
  get finished() {
10
- // Support for new finished Promise and legacy thennable API
11
- return Promise.all(this.animations.map((animation) => "finished" in animation ? animation.finished : animation));
10
+ return Promise.all(this.animations.map((animation) => animation.finished));
12
11
  }
13
12
  /**
14
13
  * TODO: Filter out cancelled or stopped animations before returning
@@ -79,4 +78,4 @@ class BaseGroupPlaybackControls {
79
78
  }
80
79
  }
81
80
 
82
- export { BaseGroupPlaybackControls };
81
+ export { GroupAnimation };
@@ -0,0 +1,9 @@
1
+ import { GroupAnimation } from './GroupAnimation.mjs';
2
+
3
+ class GroupAnimationWithThen extends GroupAnimation {
4
+ then(onResolve, _onReject) {
5
+ return this.finished.finally(onResolve).then(() => { });
6
+ }
7
+ }
8
+
9
+ export { GroupAnimationWithThen };
@@ -0,0 +1,159 @@
1
+ import { invariant, millisecondsToSeconds, secondsToMilliseconds, noop } from 'motion-utils';
2
+ import { style } from '../render/dom/style.mjs';
3
+ import { getFinalKeyframe } from './keyframes/get-final.mjs';
4
+ import { hydrateKeyframes } from './keyframes/hydrate.mjs';
5
+ import { startWaapiAnimation } from './waapi/start-waapi-animation.mjs';
6
+ import { applyGeneratorOptions } from './waapi/utils/apply-generator.mjs';
7
+
8
+ const animationMaps = new WeakMap();
9
+ const animationMapKey = (name, pseudoElement) => `${name}:${pseudoElement}`;
10
+ function getAnimationMap(element) {
11
+ const map = animationMaps.get(element) || new Map();
12
+ animationMaps.set(element, map);
13
+ return map;
14
+ }
15
+ /**
16
+ * NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
17
+ */
18
+ class NativeAnimation {
19
+ constructor(options) {
20
+ /**
21
+ * If we already have an animation, we don't need to instantiate one
22
+ * and can just use this as a controls interface.
23
+ */
24
+ if ("animation" in options) {
25
+ this.animation = options.animation;
26
+ return;
27
+ }
28
+ const { element, name, keyframes: unresolvedKeyframes, pseudoElement, allowFlatten = false, } = options;
29
+ let { transition } = options;
30
+ this.allowFlatten = allowFlatten;
31
+ /**
32
+ * Stop any existing animations on the element before reading existing keyframes.
33
+ *
34
+ * TODO: Check for VisualElement before using animation state. This is a fallback
35
+ * for mini animate(). Do this when implementing NativeAnimationExtended.
36
+ */
37
+ const animationMap = getAnimationMap(element);
38
+ const key = animationMapKey(name, pseudoElement || "");
39
+ const currentAnimation = animationMap.get(key);
40
+ currentAnimation && currentAnimation.stop();
41
+ /**
42
+ * TODO: If these keyframes aren't correctly hydrated then we want to throw
43
+ * run an instant animation.
44
+ */
45
+ const keyframes = hydrateKeyframes(element, name, unresolvedKeyframes, pseudoElement);
46
+ invariant(typeof transition.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "motion"?`);
47
+ transition = applyGeneratorOptions(transition);
48
+ this.animation = startWaapiAnimation(element, name, keyframes, transition, pseudoElement);
49
+ if (transition.autoplay === false) {
50
+ this.animation.pause();
51
+ }
52
+ this.removeAnimation = () => animationMap.delete(key);
53
+ this.animation.onfinish = () => {
54
+ if (!pseudoElement) {
55
+ style.set(element, name, getFinalKeyframe(keyframes, transition));
56
+ }
57
+ else {
58
+ this.commitStyles();
59
+ }
60
+ this.cancel();
61
+ };
62
+ /**
63
+ * TODO: Check for VisualElement before using animation state.
64
+ */
65
+ animationMap.set(key, this);
66
+ }
67
+ play() {
68
+ this.animation.play();
69
+ }
70
+ pause() {
71
+ this.animation.pause();
72
+ }
73
+ complete() {
74
+ this.animation.finish();
75
+ }
76
+ cancel() {
77
+ try {
78
+ this.animation.cancel();
79
+ }
80
+ catch (e) { }
81
+ this.removeAnimation();
82
+ }
83
+ stop() {
84
+ const { state } = this;
85
+ if (state === "idle" || state === "finished") {
86
+ return;
87
+ }
88
+ this.commitStyles();
89
+ this.cancel();
90
+ }
91
+ /**
92
+ * WAAPI doesn't natively have any interruption capabilities.
93
+ *
94
+ * In this method, we commit styles back to the DOM before cancelling
95
+ * the animation.
96
+ *
97
+ * This is designed to be overridden by NativeAnimationExtended, which
98
+ * will create a renderless JS animation and sample it twice to calculate
99
+ * its current value, "previous" value, and therefore allow
100
+ * Motion to also correctly calculate velocity for any subsequent animation
101
+ * while deferring the commit until the next animation frame.
102
+ */
103
+ commitStyles() {
104
+ this.animation.commitStyles?.();
105
+ }
106
+ get duration() {
107
+ console.log(this.animation.effect?.getComputedTiming());
108
+ const duration = this.animation.effect?.getComputedTiming().duration || 0;
109
+ return millisecondsToSeconds(Number(duration));
110
+ }
111
+ get time() {
112
+ return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
113
+ }
114
+ set time(newTime) {
115
+ this.animation.currentTime = secondsToMilliseconds(newTime);
116
+ }
117
+ /**
118
+ * The playback speed of the animation.
119
+ * 1 = normal speed, 2 = double speed, 0.5 = half speed.
120
+ */
121
+ get speed() {
122
+ return this.animation.playbackRate;
123
+ }
124
+ set speed(newSpeed) {
125
+ this.animation.playbackRate = newSpeed;
126
+ }
127
+ get state() {
128
+ return this.animation.playState;
129
+ }
130
+ get startTime() {
131
+ return Number(this.animation.startTime);
132
+ }
133
+ get finished() {
134
+ return this.animation.finished;
135
+ }
136
+ flatten() {
137
+ if (this.allowFlatten) {
138
+ this.animation.effect?.updateTiming({ easing: "linear" });
139
+ }
140
+ }
141
+ /**
142
+ * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
143
+ */
144
+ attachTimeline(timeline) {
145
+ this.animation.timeline = timeline;
146
+ this.animation.onfinish = null;
147
+ return noop;
148
+ }
149
+ /**
150
+ * Allows the animation to be awaited.
151
+ *
152
+ * @deprecated Use `finished` instead.
153
+ */
154
+ then(onResolve, onReject) {
155
+ return this.finished.then(onResolve).catch(onReject);
156
+ }
157
+ }
158
+
159
+ export { NativeAnimation };
@@ -1,5 +1,5 @@
1
1
  function isGenerator(type) {
2
- return typeof type === "function";
2
+ return typeof type === "function" && "applyToOptions" in type;
3
3
  }
4
4
 
5
5
  export { isGenerator };
@@ -0,0 +1,12 @@
1
+ const isNotNull = (value) => value !== null;
2
+ function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
3
+ const resolvedKeyframes = keyframes.filter(isNotNull);
4
+ const index = repeat && repeatType !== "loop" && repeat % 2 === 1
5
+ ? 0
6
+ : resolvedKeyframes.length - 1;
7
+ return !index || finalKeyframe === undefined
8
+ ? resolvedKeyframes[index]
9
+ : finalKeyframe;
10
+ }
11
+
12
+ export { getFinalKeyframe };
@@ -0,0 +1,26 @@
1
+ import { style } from '../../render/dom/style.mjs';
2
+ import { supportsPartialKeyframes } from '../waapi/supports/partial-keyframes.mjs';
3
+ import { pxValues } from '../waapi/utils/px-values.mjs';
4
+
5
+ function hydrateKeyframes(element, name, keyframes, pseudoElement) {
6
+ if (!Array.isArray(keyframes)) {
7
+ keyframes = [keyframes];
8
+ }
9
+ for (let i = 0; i < keyframes.length; i++) {
10
+ if (keyframes[i] === null) {
11
+ keyframes[i] =
12
+ i === 0 && !pseudoElement
13
+ ? style.get(element, name)
14
+ : keyframes[i - 1];
15
+ }
16
+ if (typeof keyframes[i] === "number" && pxValues.has(name)) {
17
+ keyframes[i] = keyframes[i] + "px";
18
+ }
19
+ }
20
+ if (!pseudoElement && !supportsPartialKeyframes() && keyframes.length < 2) {
21
+ keyframes.unshift(style.get(element, name));
22
+ }
23
+ return keyframes;
24
+ }
25
+
26
+ export { hydrateKeyframes };
@@ -1,9 +1,7 @@
1
1
  function getValueTransition(transition, key) {
2
- return transition
3
- ? transition[key] ||
4
- transition["default"] ||
5
- transition
6
- : undefined;
2
+ return (transition?.[key] ??
3
+ transition?.["default"] ??
4
+ transition);
7
5
  }
8
6
 
9
7
  export { getValueTransition };
@@ -0,0 +1,3 @@
1
+ const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
2
+
3
+ export { cubicBezierAsString };
@@ -0,0 +1,14 @@
1
+ import { isBezierDefinition } from '../../../utils/is-bezier-definition.mjs';
2
+ import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
3
+ import { supportedWaapiEasing } from './supported.mjs';
4
+
5
+ function isWaapiSupportedEasing(easing) {
6
+ return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
7
+ !easing ||
8
+ (typeof easing === "string" &&
9
+ (easing in supportedWaapiEasing || supportsLinearEasing())) ||
10
+ isBezierDefinition(easing) ||
11
+ (Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
12
+ }
13
+
14
+ export { isWaapiSupportedEasing };
@@ -0,0 +1,26 @@
1
+ import { isBezierDefinition } from '../../../utils/is-bezier-definition.mjs';
2
+ import { supportsLinearEasing } from '../../../utils/supports/linear-easing.mjs';
3
+ import { generateLinearEasing } from '../utils/linear.mjs';
4
+ import { cubicBezierAsString } from './cubic-bezier.mjs';
5
+ import { supportedWaapiEasing } from './supported.mjs';
6
+
7
+ function mapEasingToNativeEasing(easing, duration) {
8
+ if (!easing) {
9
+ return undefined;
10
+ }
11
+ else if (typeof easing === "function" && supportsLinearEasing()) {
12
+ return generateLinearEasing(easing, duration);
13
+ }
14
+ else if (isBezierDefinition(easing)) {
15
+ return cubicBezierAsString(easing);
16
+ }
17
+ else if (Array.isArray(easing)) {
18
+ return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) ||
19
+ supportedWaapiEasing.easeOut);
20
+ }
21
+ else {
22
+ return supportedWaapiEasing[easing];
23
+ }
24
+ }
25
+
26
+ export { mapEasingToNativeEasing };
@@ -0,0 +1,15 @@
1
+ import { cubicBezierAsString } from './cubic-bezier.mjs';
2
+
3
+ const supportedWaapiEasing = {
4
+ linear: "linear",
5
+ ease: "ease",
6
+ easeIn: "ease-in",
7
+ easeOut: "ease-out",
8
+ easeInOut: "ease-in-out",
9
+ circIn: /*@__PURE__*/ cubicBezierAsString([0, 0.65, 0.55, 1]),
10
+ circOut: /*@__PURE__*/ cubicBezierAsString([0.55, 0, 1, 0.45]),
11
+ backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
12
+ backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
13
+ };
14
+
15
+ export { supportedWaapiEasing };
@@ -0,0 +1,37 @@
1
+ import { activeAnimations } from '../../stats/animation-count.mjs';
2
+ import { statsBuffer } from '../../stats/buffer.mjs';
3
+ import { mapEasingToNativeEasing } from './easing/map-easing.mjs';
4
+
5
+ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}, pseudoElement = undefined) {
6
+ const keyframeOptions = {
7
+ [valueName]: keyframes,
8
+ };
9
+ if (times)
10
+ keyframeOptions.offset = times;
11
+ const easing = mapEasingToNativeEasing(ease, duration);
12
+ /**
13
+ * If this is an easing array, apply to keyframes, not animation as a whole
14
+ */
15
+ if (Array.isArray(easing))
16
+ keyframeOptions.easing = easing;
17
+ if (statsBuffer.value) {
18
+ activeAnimations.waapi++;
19
+ }
20
+ const animation = element.animate(keyframeOptions, {
21
+ delay,
22
+ duration,
23
+ easing: !Array.isArray(easing) ? easing : "linear",
24
+ fill: "both",
25
+ iterations: repeat + 1,
26
+ direction: repeatType === "reverse" ? "alternate" : "normal",
27
+ pseudoElement,
28
+ });
29
+ if (statsBuffer.value) {
30
+ animation.finished.finally(() => {
31
+ activeAnimations.waapi--;
32
+ });
33
+ }
34
+ return animation;
35
+ }
36
+
37
+ export { startWaapiAnimation };
@@ -0,0 +1,13 @@
1
+ import { memo } from 'motion-utils';
2
+
3
+ const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
4
+ try {
5
+ document.createElement("div").animate({ opacity: [1] });
6
+ }
7
+ catch (e) {
8
+ return false;
9
+ }
10
+ return true;
11
+ });
12
+
13
+ export { supportsPartialKeyframes };
@@ -0,0 +1,14 @@
1
+ import { isGenerator } from '../../generators/utils/is-generator.mjs';
2
+
3
+ function applyGeneratorOptions({ type, ...options }) {
4
+ if (isGenerator(type)) {
5
+ return type.applyToOptions(options);
6
+ }
7
+ else {
8
+ options.duration ?? (options.duration = 300);
9
+ options.ease ?? (options.ease = "easeOut");
10
+ }
11
+ return options;
12
+ }
13
+
14
+ export { applyGeneratorOptions };
@@ -1,12 +1,10 @@
1
- import { progress } from 'motion-utils';
2
-
3
1
  const generateLinearEasing = (easing, duration, // as milliseconds
4
2
  resolution = 10 // as milliseconds
5
3
  ) => {
6
4
  let points = "";
7
5
  const numPoints = Math.max(Math.round(duration / resolution), 2);
8
6
  for (let i = 0; i < numPoints; i++) {
9
- points += easing(progress(0, numPoints - 1, i)) + ", ";
7
+ points += easing(i / (numPoints - 1)) + ", ";
10
8
  }
11
9
  return `linear(${points.substring(0, points.length - 2)})`;
12
10
  };
@@ -0,0 +1,39 @@
1
+ const pxValues = new Set([
2
+ // Border props
3
+ "borderWidth",
4
+ "borderTopWidth",
5
+ "borderRightWidth",
6
+ "borderBottomWidth",
7
+ "borderLeftWidth",
8
+ "borderRadius",
9
+ "radius",
10
+ "borderTopLeftRadius",
11
+ "borderTopRightRadius",
12
+ "borderBottomRightRadius",
13
+ "borderBottomLeftRadius",
14
+ // Positioning props
15
+ "width",
16
+ "maxWidth",
17
+ "height",
18
+ "maxHeight",
19
+ "top",
20
+ "right",
21
+ "bottom",
22
+ "left",
23
+ // Spacing props
24
+ "padding",
25
+ "paddingTop",
26
+ "paddingRight",
27
+ "paddingBottom",
28
+ "paddingLeft",
29
+ "margin",
30
+ "marginTop",
31
+ "marginRight",
32
+ "marginBottom",
33
+ "marginLeft",
34
+ // Misc
35
+ "backgroundPositionX",
36
+ "backgroundPositionY",
37
+ ]);
38
+
39
+ export { pxValues };
@@ -69,7 +69,7 @@ function press(targetOrSelector, onPressStart, options = {}) {
69
69
  if (target instanceof HTMLElement) {
70
70
  target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
71
71
  if (!isElementKeyboardAccessible(target) &&
72
- target.tabIndex === null) {
72
+ !target.hasAttribute("tabindex")) {
73
73
  target.tabIndex = 0;
74
74
  }
75
75
  }
package/dist/es/index.mjs CHANGED
@@ -1,11 +1,16 @@
1
- export { GroupPlaybackControls } from './animation/controls/Group.mjs';
1
+ export { GroupAnimation } from './animation/GroupAnimation.mjs';
2
+ export { GroupAnimationWithThen } from './animation/GroupAnimationWithThen.mjs';
3
+ export { NativeAnimation } from './animation/NativeAnimation.mjs';
2
4
  export { getValueTransition } from './animation/utils/get-value-transition.mjs';
3
5
  export { calcGeneratorDuration, maxGeneratorDuration } from './animation/generators/utils/calc-duration.mjs';
4
6
  export { createGeneratorEasing } from './animation/generators/utils/create-generator-easing.mjs';
5
7
  export { isGenerator } from './animation/generators/utils/is-generator.mjs';
6
- export { NativeAnimationControls } from './animation/waapi/NativeAnimationControls.mjs';
8
+ export { cubicBezierAsString } from './animation/waapi/easing/cubic-bezier.mjs';
9
+ export { isWaapiSupportedEasing } from './animation/waapi/easing/is-supported.mjs';
10
+ export { mapEasingToNativeEasing } from './animation/waapi/easing/map-easing.mjs';
11
+ export { supportedWaapiEasing } from './animation/waapi/easing/supported.mjs';
12
+ export { startWaapiAnimation } from './animation/waapi/start-waapi-animation.mjs';
7
13
  export { attachTimeline } from './animation/waapi/utils/attach-timeline.mjs';
8
- export { cubicBezierAsString, isWaapiSupportedEasing, mapEasingToNativeEasing, supportedWaapiEasing } from './animation/waapi/utils/easing.mjs';
9
14
  export { generateLinearEasing } from './animation/waapi/utils/linear.mjs';
10
15
  export { cancelFrame, frame, frameData, frameSteps } from './frameloop/frame.mjs';
11
16
  export { createRenderBatcher } from './frameloop/batcher.mjs';
@@ -0,0 +1,15 @@
1
+ const isCSSVar = (name) => name.startsWith("--");
2
+ const style = {
3
+ set: (element, name, value) => {
4
+ isCSSVar(name)
5
+ ? element.style.setProperty(name, value)
6
+ : (element.style[name] = value);
7
+ },
8
+ get: (element, name) => {
9
+ return isCSSVar(name)
10
+ ? element.style.getPropertyValue(name)
11
+ : element.style[name];
12
+ },
13
+ };
14
+
15
+ export { style };
@@ -1,19 +1,14 @@
1
1
  function resolveElements(elementOrSelector, scope, selectorCache) {
2
- var _a;
3
2
  if (elementOrSelector instanceof EventTarget) {
4
3
  return [elementOrSelector];
5
4
  }
6
5
  else if (typeof elementOrSelector === "string") {
7
6
  let root = document;
8
7
  if (scope) {
9
- // TODO: Refactor to utils package
10
- // invariant(
11
- // Boolean(scope.current),
12
- // "Scope provided, but no element detected."
13
- // )
14
8
  root = scope.current;
15
9
  }
16
- const elements = (_a = selectorCache === null || selectorCache === void 0 ? void 0 : selectorCache[elementOrSelector]) !== null && _a !== void 0 ? _a : root.querySelectorAll(elementOrSelector);
10
+ const elements = selectorCache?.[elementOrSelector] ??
11
+ root.querySelectorAll(elementOrSelector);
17
12
  return elements ? Array.from(elements) : [];
18
13
  }
19
14
  return Array.from(elementOrSelector);
@@ -2,8 +2,6 @@
2
2
  * Add the ability for test suites to manually set support flags
3
3
  * to better test more environments.
4
4
  */
5
- const supportsFlags = {
6
- linearEasing: undefined,
7
- };
5
+ const supportsFlags = {};
8
6
 
9
7
  export { supportsFlags };
@@ -3,7 +3,7 @@ import { supportsFlags } from './flags.mjs';
3
3
 
4
4
  function memoSupports(callback, supportsFlag) {
5
5
  const memoized = memo(callback);
6
- return () => { var _a; return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized(); };
6
+ return () => supportsFlags[supportsFlag] ?? memoized();
7
7
  }
8
8
 
9
9
  export { memoSupports };
@@ -30,7 +30,7 @@ class MotionValue {
30
30
  * This will be replaced by the build step with the latest version number.
31
31
  * When MotionValues are provided to motion components, warn if versions are mixed.
32
32
  */
33
- this.version = "12.6.3-alpha.0";
33
+ this.version = "12.6.3";
34
34
  /**
35
35
  * Tracks whether this value can output a velocity. Currently this is only true
36
36
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -19,7 +19,6 @@ function start(builder) {
19
19
  });
20
20
  }
21
21
  function processQueue() {
22
- var _a;
23
22
  /**
24
23
  * Iterate backwards over the builders array. We can ignore the
25
24
  * "wait" animations. If we have an interrupting animation in the
@@ -41,7 +40,7 @@ function processQueue() {
41
40
  break;
42
41
  }
43
42
  }
44
- if (!current || ((_a = builders[0]) === null || _a === void 0 ? void 0 : _a.options.interrupt) === "immediate") {
43
+ if (!current || builders[0]?.options.interrupt === "immediate") {
45
44
  next();
46
45
  }
47
46
  }
@@ -1,10 +1,9 @@
1
1
  import { secondsToMilliseconds } from 'motion-utils';
2
- import { BaseGroupPlaybackControls } from '../animation/controls/BaseGroup.mjs';
2
+ import { GroupAnimation } from '../animation/GroupAnimation.mjs';
3
+ import { NativeAnimation } from '../animation/NativeAnimation.mjs';
3
4
  import { getValueTransition } from '../animation/utils/get-value-transition.mjs';
4
- import { NativeAnimationControls } from '../animation/waapi/NativeAnimationControls.mjs';
5
- import { PseudoAnimation } from '../animation/waapi/PseudoAnimation.mjs';
6
- import { applyGeneratorOptions } from '../animation/waapi/utils/convert-options.mjs';
7
- import { mapEasingToNativeEasing } from '../animation/waapi/utils/easing.mjs';
5
+ import { mapEasingToNativeEasing } from '../animation/waapi/easing/map-easing.mjs';
6
+ import { applyGeneratorOptions } from '../animation/waapi/utils/apply-generator.mjs';
8
7
  import { chooseLayerType } from './utils/choose-layer-type.mjs';
9
8
  import { css } from './utils/css.mjs';
10
9
  import { getLayerName } from './utils/get-layer-name.mjs';
@@ -17,7 +16,7 @@ function startViewAnimation(builder) {
17
16
  if (!document.startViewTransition) {
18
17
  return new Promise(async (resolve) => {
19
18
  await update();
20
- resolve(new BaseGroupPlaybackControls([]));
19
+ resolve(new GroupAnimation([]));
21
20
  });
22
21
  }
23
22
  // TODO: Go over existing targets and ensure they all have ids
@@ -48,11 +47,10 @@ function startViewAnimation(builder) {
48
47
  });
49
48
  return new Promise((resolve) => {
50
49
  transition.ready.then(() => {
51
- var _a;
52
50
  const generatedViewAnimations = getViewAnimations();
53
51
  const animations = [];
54
52
  /**
55
- * Create animations for our definitions
53
+ * Create animations for each of our explicitly-defined subjects.
56
54
  */
57
55
  targets.forEach((definition, target) => {
58
56
  // TODO: If target is not "root", resolve elements
@@ -84,7 +82,13 @@ function startViewAnimation(builder) {
84
82
  if (typeof valueOptions.delay === "function") {
85
83
  valueOptions.delay = valueOptions.delay(0, 1);
86
84
  }
87
- const animation = new PseudoAnimation(document.documentElement, `::view-transition-${type}(${target})`, valueName, valueKeyframes, valueOptions);
85
+ const animation = new NativeAnimation({
86
+ element: document.documentElement,
87
+ name: valueName,
88
+ pseudoElement: `::view-transition-${type}(${target})`,
89
+ keyframes: valueKeyframes,
90
+ transition: valueOptions,
91
+ });
88
92
  animations.push(animation);
89
93
  }
90
94
  }
@@ -112,36 +116,37 @@ function startViewAnimation(builder) {
112
116
  * the above method.
113
117
  */
114
118
  const transitionName = name.type === "group" ? "layout" : "";
115
- const animationTransition = {
119
+ let animationTransition = {
116
120
  ...getValueTransition(defaultOptions, transitionName),
117
121
  };
118
- applyGeneratorOptions(animationTransition);
122
+ animationTransition.duration && (animationTransition.duration = secondsToMilliseconds(animationTransition.duration));
123
+ animationTransition =
124
+ applyGeneratorOptions(animationTransition);
119
125
  const easing = mapEasingToNativeEasing(animationTransition.ease, animationTransition.duration);
120
126
  effect.updateTiming({
121
- delay: secondsToMilliseconds((_a = animationTransition.delay) !== null && _a !== void 0 ? _a : 0),
127
+ delay: secondsToMilliseconds(animationTransition.delay ?? 0),
122
128
  duration: animationTransition.duration,
123
129
  easing,
124
130
  });
125
- animations.push(new NativeAnimationControls(animation));
131
+ animations.push(new NativeAnimation({ animation }));
126
132
  }
127
133
  else if (hasOpacity(targetDefinition, "enter") &&
128
134
  hasOpacity(targetDefinition, "exit") &&
129
135
  effect
130
136
  .getKeyframes()
131
137
  .some((keyframe) => keyframe.mixBlendMode)) {
132
- animations.push(new NativeAnimationControls(animation));
138
+ animations.push(new NativeAnimation({ animation }));
133
139
  }
134
140
  else {
135
141
  animation.cancel();
136
142
  }
137
143
  }
138
- resolve(new BaseGroupPlaybackControls(animations));
144
+ resolve(new GroupAnimation(animations));
139
145
  });
140
146
  });
141
147
  }
142
148
  function hasOpacity(target, key) {
143
- var _a;
144
- return (_a = target === null || target === void 0 ? void 0 : target[key]) === null || _a === void 0 ? void 0 : _a.keyframes.opacity;
149
+ return target?.[key]?.keyframes.opacity;
145
150
  }
146
151
 
147
152
  export { startViewAnimation };