motion 12.7.4 → 12.7.5-alpha.0
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/README.md +1 -1
- package/dist/cjs/debug.js +22 -14
- package/dist/cjs/index.js +4113 -3624
- package/dist/cjs/mini.js +403 -324
- package/dist/cjs/react-client.js +3151 -3245
- package/dist/cjs/react-m.js +169 -166
- package/dist/cjs/react-mini.js +330 -251
- package/dist/es/framer-motion/dist/es/animation/animate/sequence.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +81 -9
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +11 -30
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +3 -3
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/edit.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/utils/stagger.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/utils/check-reorder.mjs +1 -1
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -2
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +2 -2
- package/dist/es/framer-motion/dist/es/gestures/focus.mjs +1 -1
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -3
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-apply.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-calc.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-remove.mjs +2 -2
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +3 -5
- package/dist/es/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +1 -1
- package/dist/es/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +2 -2
- package/dist/es/framer-motion/dist/es/projection/styles/scale-correction.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +7 -7
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-animation.mjs +17 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-function.mjs +23 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +6 -82
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +3 -3
- package/dist/es/framer-motion/dist/es/render/dom/scroll/utils/get-timeline.mjs +29 -0
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +3 -3
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +4 -4
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +3 -3
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +2 -2
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/svg/utils/path.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/svg/utils/transform-origin.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/transform.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/use-cycle.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +4 -4
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +2 -2
- package/dist/es/framer-motion/dist/es/value/use-will-change/get-will-change-name.mjs +2 -2
- package/dist/es/motion/lib/index.mjs +109 -26
- package/dist/es/motion/lib/react.mjs +108 -32
- package/dist/es/motion-dom/dist/es/animation/AsyncMotionValueAnimation.mjs +179 -0
- package/dist/es/motion-dom/dist/es/animation/GroupAnimation.mjs +6 -15
- package/dist/es/{framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs → motion-dom/dist/es/animation/JSAnimation.mjs} +108 -156
- package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +64 -67
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationExtended.mjs +65 -0
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationWrapper.mjs +14 -0
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/drivers/driver-frameloop.mjs +2 -2
- package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/keyframes.mjs +5 -5
- package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/spring/find.mjs +1 -1
- package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/spring/index.mjs +5 -6
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation/keyframes}/DOMKeyframesResolver.mjs +9 -8
- package/dist/es/{framer-motion/dist/es/render/utils → motion-dom/dist/es/animation/keyframes}/KeyframesResolver.mjs +28 -35
- package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +3 -4
- package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/animation/keyframes}/offsets/fill.mjs +2 -2
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/apply-px-defaults.mjs +11 -0
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/fill-wildcards.mjs +7 -0
- package/dist/es/{framer-motion/dist/es/animation → motion-dom/dist/es/animation/keyframes}/utils/is-none.mjs +1 -1
- package/dist/es/{framer-motion/dist/es/render/html → motion-dom/dist/es/animation/keyframes}/utils/make-none-animatable.mjs +1 -1
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation/keyframes}/utils/unit-conversion.mjs +2 -2
- package/dist/es/motion-dom/dist/es/animation/utils/WithPromise.mjs +28 -0
- package/dist/es/motion-dom/dist/es/animation/utils/active-animations.mjs +9 -0
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/utils/can-animate.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation}/utils/css-variables-conversion.mjs +2 -2
- package/dist/es/motion-dom/dist/es/animation/utils/replace-transition-type.mjs +18 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +1 -1
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +5 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs +6 -4
- package/dist/es/motion-dom/dist/es/animation/waapi/supports/waapi.mjs +39 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +2 -1
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/unsupported-easing.mjs +20 -0
- package/dist/es/motion-dom/dist/es/frameloop/batcher.mjs +2 -1
- package/dist/es/motion-dom/dist/es/frameloop/order.mjs +1 -0
- package/dist/es/motion-dom/dist/es/render/dom/is-css-var.mjs +3 -0
- package/dist/es/motion-dom/dist/es/render/dom/style-computed.mjs +10 -0
- package/dist/es/motion-dom/dist/es/render/dom/style-set.mjs +9 -0
- package/dist/es/{framer-motion/dist/es/render/html → motion-dom/dist/es/render}/utils/keys-transform.mjs +1 -1
- package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es}/scroll/observe.mjs +1 -1
- package/dist/es/motion-dom/dist/es/stats/index.mjs +2 -0
- package/dist/es/{framer-motion → motion-dom}/dist/es/utils/interpolate.mjs +4 -3
- package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/color.mjs +3 -3
- package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/complex.mjs +5 -5
- package/dist/es/motion-dom/dist/es/value/index.mjs +3 -1
- package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/rgba.mjs +2 -2
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types}/dimensions.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/render/dom/value-types/type-int.mjs → motion-dom/dist/es/value/types/int.mjs} +1 -1
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/maps}/defaults.mjs +2 -2
- package/dist/es/{framer-motion/dist/es/render/dom/value-types/number-browser.mjs → motion-dom/dist/es/value/types/maps/number.mjs} +13 -3
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/maps}/transform.mjs +2 -2
- package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/numbers/index.mjs +1 -1
- package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/numbers/units.mjs +3 -2
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/utils}/animatable-none.mjs +4 -4
- package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/utils}/find.mjs +4 -4
- package/dist/es/motion-dom/dist/es/view/index.mjs +64 -0
- package/dist/es/motion-dom/dist/es/view/queue.mjs +52 -0
- package/dist/es/motion-dom/dist/es/view/start.mjs +155 -0
- package/dist/es/motion-dom/dist/es/view/utils/choose-layer-type.mjs +11 -0
- package/dist/es/motion-dom/dist/es/view/utils/css.mjs +32 -0
- package/dist/es/motion-dom/dist/es/view/utils/get-layer-name.mjs +8 -0
- package/dist/es/motion-dom/dist/es/view/utils/get-view-animations.mjs +12 -0
- package/dist/es/motion-dom/dist/es/view/utils/has-target.mjs +5 -0
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/cubic-bezier.mjs +1 -1
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/steps.mjs +1 -1
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/utils/get-easing-for-segment.mjs +1 -1
- package/dist/es/{framer-motion → motion-utils}/dist/es/easing/utils/map.mjs +7 -4
- package/dist/es/motion-utils/dist/es/global-config.mjs +1 -4
- package/dist/es/motion-utils/dist/es/warn-once.mjs +4 -1
- package/dist/motion.dev.js +4108 -3619
- package/dist/motion.js +1 -1
- package/package.json +3 -3
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +0 -324
- package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +0 -120
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +0 -5
- package/dist/es/framer-motion/dist/es/render/dom/value-types/number.mjs +0 -18
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition-state.mjs +0 -5
- package/dist/es/motion-dom/dist/es/animation/keyframes/hydrate.mjs +0 -26
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/attach-timeline.mjs +0 -6
- package/dist/es/motion-dom/dist/es/render/dom/style.mjs +0 -15
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/inertia.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/spring/defaults.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/velocity.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/animation/keyframes}/offsets/default.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/animation/keyframes}/offsets/time.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/utils/is-animatable.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom → motion-dom/dist/es/animation}/utils/is-css-variable.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation/waapi}/utils/accelerated-values.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/html/utils → motion-dom/dist/es/render/dom}/parse-transform.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/html → motion-dom/dist/es/render}/utils/keys-position.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/immediate.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/index.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/number.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/utils/mix/visibility.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom/value-types/type-auto.mjs → motion-dom/dist/es/value/types/auto.mjs} +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/hex.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-dom/dist/es/value/types/color}/hsla-to-rgba.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/hsla.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/index.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/color/utils.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/complex/filter.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/complex/index.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types}/test.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/color-regex.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/float-regex.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/render/dom/value-types → motion-dom/dist/es/value/types/utils}/get-as-type.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/is-nullish.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/sanitize.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/value/types/utils/single-color-regex.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/clamp.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/anticipate.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/back.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/circ.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/ease.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/modifiers/mirror.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/modifiers/reverse.mjs +0 -0
- /package/dist/es/{motion-dom/dist/es → motion-utils/dist/es/easing}/utils/is-bezier-definition.mjs +0 -0
- /package/dist/es/{framer-motion → motion-utils}/dist/es/easing/utils/is-easing-array.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/is-numerical-string.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/is-zero-value-string.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/pipe.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/wrap.mjs +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { GroupAnimation } from '../animation/GroupAnimation.mjs';
|
|
2
|
+
import { NativeAnimation } from '../animation/NativeAnimation.mjs';
|
|
3
|
+
import { NativeAnimationWrapper } from '../animation/NativeAnimationWrapper.mjs';
|
|
4
|
+
import { getValueTransition } from '../animation/utils/get-value-transition.mjs';
|
|
5
|
+
import { mapEasingToNativeEasing } from '../animation/waapi/easing/map-easing.mjs';
|
|
6
|
+
import { applyGeneratorOptions } from '../animation/waapi/utils/apply-generator.mjs';
|
|
7
|
+
import { chooseLayerType } from './utils/choose-layer-type.mjs';
|
|
8
|
+
import { css } from './utils/css.mjs';
|
|
9
|
+
import { getLayerName } from './utils/get-layer-name.mjs';
|
|
10
|
+
import { getViewAnimations } from './utils/get-view-animations.mjs';
|
|
11
|
+
import { hasTarget } from './utils/has-target.mjs';
|
|
12
|
+
import { secondsToMilliseconds } from '../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
13
|
+
|
|
14
|
+
const definitionNames = ["layout", "enter", "exit", "new", "old"];
|
|
15
|
+
function startViewAnimation(builder) {
|
|
16
|
+
const { update, targets, options: defaultOptions } = builder;
|
|
17
|
+
if (!document.startViewTransition) {
|
|
18
|
+
return new Promise(async (resolve) => {
|
|
19
|
+
await update();
|
|
20
|
+
resolve(new GroupAnimation([]));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// TODO: Go over existing targets and ensure they all have ids
|
|
24
|
+
/**
|
|
25
|
+
* If we don't have any animations defined for the root target,
|
|
26
|
+
* remove it from being captured.
|
|
27
|
+
*/
|
|
28
|
+
if (!hasTarget("root", targets)) {
|
|
29
|
+
css.set(":root", {
|
|
30
|
+
"view-transition-name": "none",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Set the timing curve to linear for all view transition layers.
|
|
35
|
+
* This gets baked into the keyframes, which can't be changed
|
|
36
|
+
* without breaking the generated animation.
|
|
37
|
+
*
|
|
38
|
+
* This allows us to set easing via updateTiming - which can be changed.
|
|
39
|
+
*/
|
|
40
|
+
css.set("::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*)", { "animation-timing-function": "linear !important" });
|
|
41
|
+
css.commit(); // Write
|
|
42
|
+
const transition = document.startViewTransition(async () => {
|
|
43
|
+
await update();
|
|
44
|
+
// TODO: Go over new targets and ensure they all have ids
|
|
45
|
+
});
|
|
46
|
+
transition.finished.finally(() => {
|
|
47
|
+
css.remove(); // Write
|
|
48
|
+
});
|
|
49
|
+
return new Promise((resolve) => {
|
|
50
|
+
transition.ready.then(() => {
|
|
51
|
+
const generatedViewAnimations = getViewAnimations();
|
|
52
|
+
const animations = [];
|
|
53
|
+
/**
|
|
54
|
+
* Create animations for each of our explicitly-defined subjects.
|
|
55
|
+
*/
|
|
56
|
+
targets.forEach((definition, target) => {
|
|
57
|
+
// TODO: If target is not "root", resolve elements
|
|
58
|
+
// and iterate over each
|
|
59
|
+
for (const key of definitionNames) {
|
|
60
|
+
if (!definition[key])
|
|
61
|
+
continue;
|
|
62
|
+
const { keyframes, options } = definition[key];
|
|
63
|
+
for (let [valueName, valueKeyframes] of Object.entries(keyframes)) {
|
|
64
|
+
if (!valueKeyframes)
|
|
65
|
+
continue;
|
|
66
|
+
const valueOptions = {
|
|
67
|
+
...getValueTransition(defaultOptions, valueName),
|
|
68
|
+
...getValueTransition(options, valueName),
|
|
69
|
+
};
|
|
70
|
+
const type = chooseLayerType(key);
|
|
71
|
+
/**
|
|
72
|
+
* If this is an opacity animation, and keyframes are not an array,
|
|
73
|
+
* we need to convert them into an array and set an initial value.
|
|
74
|
+
*/
|
|
75
|
+
if (valueName === "opacity" &&
|
|
76
|
+
!Array.isArray(valueKeyframes)) {
|
|
77
|
+
const initialValue = type === "new" ? 0 : 1;
|
|
78
|
+
valueKeyframes = [initialValue, valueKeyframes];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolve stagger function if provided.
|
|
82
|
+
*/
|
|
83
|
+
if (typeof valueOptions.delay === "function") {
|
|
84
|
+
valueOptions.delay = valueOptions.delay(0, 1);
|
|
85
|
+
}
|
|
86
|
+
valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
|
|
87
|
+
valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
|
|
88
|
+
const animation = new NativeAnimation({
|
|
89
|
+
...valueOptions,
|
|
90
|
+
element: document.documentElement,
|
|
91
|
+
name: valueName,
|
|
92
|
+
pseudoElement: `::view-transition-${type}(${target})`,
|
|
93
|
+
keyframes: valueKeyframes,
|
|
94
|
+
});
|
|
95
|
+
animations.push(animation);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Handle browser generated animations
|
|
101
|
+
*/
|
|
102
|
+
for (const animation of generatedViewAnimations) {
|
|
103
|
+
if (animation.playState === "finished")
|
|
104
|
+
continue;
|
|
105
|
+
const { effect } = animation;
|
|
106
|
+
if (!effect || !(effect instanceof KeyframeEffect))
|
|
107
|
+
continue;
|
|
108
|
+
const { pseudoElement } = effect;
|
|
109
|
+
if (!pseudoElement)
|
|
110
|
+
continue;
|
|
111
|
+
const name = getLayerName(pseudoElement);
|
|
112
|
+
if (!name)
|
|
113
|
+
continue;
|
|
114
|
+
const targetDefinition = targets.get(name.layer);
|
|
115
|
+
if (!targetDefinition) {
|
|
116
|
+
/**
|
|
117
|
+
* If transition name is group then update the timing of the animation
|
|
118
|
+
* whereas if it's old or new then we could possibly replace it using
|
|
119
|
+
* the above method.
|
|
120
|
+
*/
|
|
121
|
+
const transitionName = name.type === "group" ? "layout" : "";
|
|
122
|
+
let animationTransition = {
|
|
123
|
+
...getValueTransition(defaultOptions, transitionName),
|
|
124
|
+
};
|
|
125
|
+
animationTransition.duration && (animationTransition.duration = secondsToMilliseconds(animationTransition.duration));
|
|
126
|
+
animationTransition =
|
|
127
|
+
applyGeneratorOptions(animationTransition);
|
|
128
|
+
const easing = mapEasingToNativeEasing(animationTransition.ease, animationTransition.duration);
|
|
129
|
+
effect.updateTiming({
|
|
130
|
+
delay: secondsToMilliseconds(animationTransition.delay ?? 0),
|
|
131
|
+
duration: animationTransition.duration,
|
|
132
|
+
easing,
|
|
133
|
+
});
|
|
134
|
+
animations.push(new NativeAnimationWrapper(animation));
|
|
135
|
+
}
|
|
136
|
+
else if (hasOpacity(targetDefinition, "enter") &&
|
|
137
|
+
hasOpacity(targetDefinition, "exit") &&
|
|
138
|
+
effect
|
|
139
|
+
.getKeyframes()
|
|
140
|
+
.some((keyframe) => keyframe.mixBlendMode)) {
|
|
141
|
+
animations.push(new NativeAnimationWrapper(animation));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
animation.cancel();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
resolve(new GroupAnimation(animations));
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function hasOpacity(target, key) {
|
|
152
|
+
return target?.[key]?.keyframes.opacity;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export { startViewAnimation };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function chooseLayerType(valueName) {
|
|
2
|
+
if (valueName === "layout")
|
|
3
|
+
return "group";
|
|
4
|
+
if (valueName === "enter" || valueName === "new")
|
|
5
|
+
return "new";
|
|
6
|
+
if (valueName === "exit" || valueName === "old")
|
|
7
|
+
return "old";
|
|
8
|
+
return "group";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { chooseLayerType };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
let pendingRules = {};
|
|
2
|
+
let style = null;
|
|
3
|
+
const css = {
|
|
4
|
+
set: (selector, values) => {
|
|
5
|
+
pendingRules[selector] = values;
|
|
6
|
+
},
|
|
7
|
+
commit: () => {
|
|
8
|
+
if (!style) {
|
|
9
|
+
style = document.createElement("style");
|
|
10
|
+
style.id = "motion-view";
|
|
11
|
+
}
|
|
12
|
+
let cssText = "";
|
|
13
|
+
for (const selector in pendingRules) {
|
|
14
|
+
const rule = pendingRules[selector];
|
|
15
|
+
cssText += `${selector} {\n`;
|
|
16
|
+
for (const [property, value] of Object.entries(rule)) {
|
|
17
|
+
cssText += ` ${property}: ${value};\n`;
|
|
18
|
+
}
|
|
19
|
+
cssText += "}\n";
|
|
20
|
+
}
|
|
21
|
+
style.textContent = cssText;
|
|
22
|
+
document.head.appendChild(style);
|
|
23
|
+
pendingRules = {};
|
|
24
|
+
},
|
|
25
|
+
remove: () => {
|
|
26
|
+
if (style && style.parentElement) {
|
|
27
|
+
style.parentElement.removeChild(style);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { css };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function filterViewAnimations(animation) {
|
|
2
|
+
const { effect } = animation;
|
|
3
|
+
if (!effect)
|
|
4
|
+
return false;
|
|
5
|
+
return (effect.target === document.documentElement &&
|
|
6
|
+
effect.pseudoElement?.startsWith("::view-transition"));
|
|
7
|
+
}
|
|
8
|
+
function getViewAnimations() {
|
|
9
|
+
return document.getAnimations().filter(filterViewAnimations);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { getViewAnimations };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { invariant } from '../../errors.mjs';
|
|
2
|
+
import { noop } from '../../noop.mjs';
|
|
1
3
|
import { anticipate } from '../anticipate.mjs';
|
|
2
4
|
import { backIn, backInOut, backOut } from '../back.mjs';
|
|
3
5
|
import { circIn, circInOut, circOut } from '../circ.mjs';
|
|
4
6
|
import { cubicBezier } from '../cubic-bezier.mjs';
|
|
5
7
|
import { easeIn, easeInOut, easeOut } from '../ease.mjs';
|
|
6
|
-
import { isBezierDefinition } from '
|
|
7
|
-
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
8
|
-
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
8
|
+
import { isBezierDefinition } from './is-bezier-definition.mjs';
|
|
9
9
|
|
|
10
10
|
const easingLookup = {
|
|
11
11
|
linear: noop,
|
|
@@ -20,6 +20,9 @@ const easingLookup = {
|
|
|
20
20
|
backOut,
|
|
21
21
|
anticipate,
|
|
22
22
|
};
|
|
23
|
+
const isValidEasing = (easing) => {
|
|
24
|
+
return typeof easing === "string";
|
|
25
|
+
};
|
|
23
26
|
const easingDefinitionToFunction = (definition) => {
|
|
24
27
|
if (isBezierDefinition(definition)) {
|
|
25
28
|
// If cubic bezier definition, create bezier curve
|
|
@@ -27,7 +30,7 @@ const easingDefinitionToFunction = (definition) => {
|
|
|
27
30
|
const [x1, y1, x2, y2] = definition;
|
|
28
31
|
return cubicBezier(x1, y1, x2, y2);
|
|
29
32
|
}
|
|
30
|
-
else if (
|
|
33
|
+
else if (isValidEasing(definition)) {
|
|
31
34
|
// Else lookup from table
|
|
32
35
|
invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`);
|
|
33
36
|
return easingLookup[definition];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
const warned = new Set();
|
|
2
|
+
function hasWarned(message) {
|
|
3
|
+
return warned.has(message);
|
|
4
|
+
}
|
|
2
5
|
function warnOnce(condition, message, element) {
|
|
3
6
|
if (condition || warned.has(message))
|
|
4
7
|
return;
|
|
@@ -8,4 +11,4 @@ function warnOnce(condition, message, element) {
|
|
|
8
11
|
warned.add(message);
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
export { warnOnce };
|
|
14
|
+
export { hasWarned, warnOnce };
|