motion 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.
- package/dist/cjs/debug.js +12 -12
- package/dist/cjs/index.js +402 -352
- package/dist/cjs/mini.js +339 -352
- package/dist/cjs/react-client.js +169 -181
- package/dist/cjs/react-m.js +18 -22
- package/dist/cjs/react-mini.js +275 -336
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +7 -4
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +8 -6
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +10 -8
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +11 -1
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +3 -3
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +1 -2
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +2 -4
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +4 -6
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +3 -3
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +1 -2
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -10
- package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +1 -2
- package/dist/es/framer-motion/dist/es/motion/index.mjs +2 -3
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +3 -5
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +19 -27
- package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +3 -4
- package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +1 -2
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +5 -6
- package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +1 -2
- package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +1 -2
- package/dist/es/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +2 -3
- package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +3 -5
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -2
- package/dist/es/framer-motion/dist/es/value/types/complex/index.mjs +2 -3
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +2 -2
- package/dist/es/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +0 -7
- package/dist/es/motion/lib/react.mjs +0 -1
- package/dist/es/motion-dom/dist/es/animation/{controls/BaseGroup.mjs → GroupAnimation.mjs} +4 -5
- package/dist/es/motion-dom/dist/es/animation/GroupAnimationWithThen.mjs +9 -0
- package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +161 -0
- package/dist/es/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +1 -1
- package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +12 -0
- package/dist/es/motion-dom/dist/es/animation/keyframes/hydrate.mjs +26 -0
- package/dist/es/motion-dom/dist/es/animation/utils/get-value-transition.mjs +3 -5
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.mjs +3 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +14 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +26 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/supported.mjs +15 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/index.mjs → motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs} +8 -6
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs → motion-dom/dist/es/animation/waapi/supports/partial-keyframes.mjs} +2 -2
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +14 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/linear.mjs +1 -4
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/px-values.mjs +39 -0
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +1 -1
- package/dist/es/motion-dom/dist/es/render/dom/style.mjs +15 -0
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +2 -7
- package/dist/es/motion-dom/dist/es/utils/supports/flags.mjs +1 -3
- package/dist/es/motion-dom/dist/es/utils/supports/memo.mjs +1 -1
- package/dist/es/motion-dom/dist/es/value/index.mjs +1 -1
- package/dist/es/motion-utils/dist/es/errors.mjs +2 -4
- package/dist/motion.dev.js +402 -352
- package/dist/motion.js +1 -1
- package/package.json +3 -3
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +0 -116
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +0 -8
- package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +0 -13
- package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +0 -85
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/easing.mjs +0 -44
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { invariant } from '../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
+
import { style } from '../render/dom/style.mjs';
|
|
5
|
+
import { getFinalKeyframe } from './keyframes/get-final.mjs';
|
|
6
|
+
import { hydrateKeyframes } from './keyframes/hydrate.mjs';
|
|
7
|
+
import { startWaapiAnimation } from './waapi/start-waapi-animation.mjs';
|
|
8
|
+
import { applyGeneratorOptions } from './waapi/utils/apply-generator.mjs';
|
|
9
|
+
|
|
10
|
+
const animationMaps = new WeakMap();
|
|
11
|
+
const animationMapKey = (name, pseudoElement) => `${name}:${pseudoElement}`;
|
|
12
|
+
function getAnimationMap(element) {
|
|
13
|
+
const map = animationMaps.get(element) || new Map();
|
|
14
|
+
animationMaps.set(element, map);
|
|
15
|
+
return map;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
|
|
19
|
+
*/
|
|
20
|
+
class NativeAnimation {
|
|
21
|
+
constructor(options) {
|
|
22
|
+
/**
|
|
23
|
+
* If we already have an animation, we don't need to instantiate one
|
|
24
|
+
* and can just use this as a controls interface.
|
|
25
|
+
*/
|
|
26
|
+
if ("animation" in options) {
|
|
27
|
+
this.animation = options.animation;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const { element, name, keyframes: unresolvedKeyframes, pseudoElement, allowFlatten = false, } = options;
|
|
31
|
+
let { transition } = options;
|
|
32
|
+
this.allowFlatten = allowFlatten;
|
|
33
|
+
/**
|
|
34
|
+
* Stop any existing animations on the element before reading existing keyframes.
|
|
35
|
+
*
|
|
36
|
+
* TODO: Check for VisualElement before using animation state. This is a fallback
|
|
37
|
+
* for mini animate(). Do this when implementing NativeAnimationExtended.
|
|
38
|
+
*/
|
|
39
|
+
const animationMap = getAnimationMap(element);
|
|
40
|
+
const key = animationMapKey(name, pseudoElement || "");
|
|
41
|
+
const currentAnimation = animationMap.get(key);
|
|
42
|
+
currentAnimation && currentAnimation.stop();
|
|
43
|
+
/**
|
|
44
|
+
* TODO: If these keyframes aren't correctly hydrated then we want to throw
|
|
45
|
+
* run an instant animation.
|
|
46
|
+
*/
|
|
47
|
+
const keyframes = hydrateKeyframes(element, name, unresolvedKeyframes, pseudoElement);
|
|
48
|
+
invariant(typeof transition.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "motion"?`);
|
|
49
|
+
transition = applyGeneratorOptions(transition);
|
|
50
|
+
this.animation = startWaapiAnimation(element, name, keyframes, transition, pseudoElement);
|
|
51
|
+
if (transition.autoplay === false) {
|
|
52
|
+
this.animation.pause();
|
|
53
|
+
}
|
|
54
|
+
this.removeAnimation = () => animationMap.delete(key);
|
|
55
|
+
this.animation.onfinish = () => {
|
|
56
|
+
if (!pseudoElement) {
|
|
57
|
+
style.set(element, name, getFinalKeyframe(keyframes, transition));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.commitStyles();
|
|
61
|
+
}
|
|
62
|
+
this.cancel();
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* TODO: Check for VisualElement before using animation state.
|
|
66
|
+
*/
|
|
67
|
+
animationMap.set(key, this);
|
|
68
|
+
}
|
|
69
|
+
play() {
|
|
70
|
+
this.animation.play();
|
|
71
|
+
}
|
|
72
|
+
pause() {
|
|
73
|
+
this.animation.pause();
|
|
74
|
+
}
|
|
75
|
+
complete() {
|
|
76
|
+
this.animation.finish();
|
|
77
|
+
}
|
|
78
|
+
cancel() {
|
|
79
|
+
try {
|
|
80
|
+
this.animation.cancel();
|
|
81
|
+
}
|
|
82
|
+
catch (e) { }
|
|
83
|
+
this.removeAnimation();
|
|
84
|
+
}
|
|
85
|
+
stop() {
|
|
86
|
+
const { state } = this;
|
|
87
|
+
if (state === "idle" || state === "finished") {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.commitStyles();
|
|
91
|
+
this.cancel();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* WAAPI doesn't natively have any interruption capabilities.
|
|
95
|
+
*
|
|
96
|
+
* In this method, we commit styles back to the DOM before cancelling
|
|
97
|
+
* the animation.
|
|
98
|
+
*
|
|
99
|
+
* This is designed to be overridden by NativeAnimationExtended, which
|
|
100
|
+
* will create a renderless JS animation and sample it twice to calculate
|
|
101
|
+
* its current value, "previous" value, and therefore allow
|
|
102
|
+
* Motion to also correctly calculate velocity for any subsequent animation
|
|
103
|
+
* while deferring the commit until the next animation frame.
|
|
104
|
+
*/
|
|
105
|
+
commitStyles() {
|
|
106
|
+
this.animation.commitStyles?.();
|
|
107
|
+
}
|
|
108
|
+
get duration() {
|
|
109
|
+
console.log(this.animation.effect?.getComputedTiming());
|
|
110
|
+
const duration = this.animation.effect?.getComputedTiming().duration || 0;
|
|
111
|
+
return millisecondsToSeconds(Number(duration));
|
|
112
|
+
}
|
|
113
|
+
get time() {
|
|
114
|
+
return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
|
|
115
|
+
}
|
|
116
|
+
set time(newTime) {
|
|
117
|
+
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The playback speed of the animation.
|
|
121
|
+
* 1 = normal speed, 2 = double speed, 0.5 = half speed.
|
|
122
|
+
*/
|
|
123
|
+
get speed() {
|
|
124
|
+
return this.animation.playbackRate;
|
|
125
|
+
}
|
|
126
|
+
set speed(newSpeed) {
|
|
127
|
+
this.animation.playbackRate = newSpeed;
|
|
128
|
+
}
|
|
129
|
+
get state() {
|
|
130
|
+
return this.animation.playState;
|
|
131
|
+
}
|
|
132
|
+
get startTime() {
|
|
133
|
+
return Number(this.animation.startTime);
|
|
134
|
+
}
|
|
135
|
+
get finished() {
|
|
136
|
+
return this.animation.finished;
|
|
137
|
+
}
|
|
138
|
+
flatten() {
|
|
139
|
+
if (this.allowFlatten) {
|
|
140
|
+
this.animation.effect?.updateTiming({ easing: "linear" });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Attaches a timeline to the animation, for instance the `ScrollTimeline`.
|
|
145
|
+
*/
|
|
146
|
+
attachTimeline(timeline) {
|
|
147
|
+
this.animation.timeline = timeline;
|
|
148
|
+
this.animation.onfinish = null;
|
|
149
|
+
return noop;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Allows the animation to be awaited.
|
|
153
|
+
*
|
|
154
|
+
* @deprecated Use `finished` instead.
|
|
155
|
+
*/
|
|
156
|
+
then(onResolve, onReject) {
|
|
157
|
+
return this.finished.then(onResolve).catch(onReject);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { NativeAnimation };
|
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
transition
|
|
6
|
-
: undefined;
|
|
2
|
+
return (transition?.[key] ??
|
|
3
|
+
transition?.["default"] ??
|
|
4
|
+
transition);
|
|
7
5
|
}
|
|
8
6
|
|
|
9
7
|
export { getValueTransition };
|
|
@@ -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 };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { activeAnimations } from '../../../../../../motion-dom/dist/es/stats/animation-count.mjs';
|
|
1
|
+
import { activeAnimations } from '../../stats/animation-count.mjs';
|
|
2
|
+
import { statsBuffer } from '../../stats/buffer.mjs';
|
|
3
|
+
import { mapEasingToNativeEasing } from './easing/map-easing.mjs';
|
|
5
4
|
|
|
6
|
-
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
7
|
-
const keyframeOptions = {
|
|
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
|
+
};
|
|
8
9
|
if (times)
|
|
9
10
|
keyframeOptions.offset = times;
|
|
10
11
|
const easing = mapEasingToNativeEasing(ease, duration);
|
|
@@ -23,6 +24,7 @@ function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duratio
|
|
|
23
24
|
fill: "both",
|
|
24
25
|
iterations: repeat + 1,
|
|
25
26
|
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
27
|
+
pseudoElement,
|
|
26
28
|
});
|
|
27
29
|
if (statsBuffer.value) {
|
|
28
30
|
animation.finished.finally(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import { memo } from '
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { memo } from '../../../../../../motion-utils/dist/es/memo.mjs';
|
|
3
3
|
|
|
4
4
|
const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
|
|
5
5
|
try {
|
|
@@ -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,13 +1,10 @@
|
|
|
1
|
-
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
-
import { progress } from '../../../../../../motion-utils/dist/es/progress.mjs';
|
|
3
|
-
|
|
4
1
|
const generateLinearEasing = (easing, duration, // as milliseconds
|
|
5
2
|
resolution = 10 // as milliseconds
|
|
6
3
|
) => {
|
|
7
4
|
let points = "";
|
|
8
5
|
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
9
6
|
for (let i = 0; i < numPoints; i++) {
|
|
10
|
-
points += easing(
|
|
7
|
+
points += easing(i / (numPoints - 1)) + ", ";
|
|
11
8
|
}
|
|
12
9
|
return `linear(${points.substring(0, points.length - 2)})`;
|
|
13
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.
|
|
72
|
+
!target.hasAttribute("tabindex")) {
|
|
73
73
|
target.tabIndex = 0;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -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 =
|
|
10
|
+
const elements = selectorCache?.[elementOrSelector] ??
|
|
11
|
+
root.querySelectorAll(elementOrSelector);
|
|
17
12
|
return elements ? Array.from(elements) : [];
|
|
18
13
|
}
|
|
19
14
|
return Array.from(elementOrSelector);
|
|
@@ -4,7 +4,7 @@ import { supportsFlags } from './flags.mjs';
|
|
|
4
4
|
|
|
5
5
|
function memoSupports(callback, supportsFlag) {
|
|
6
6
|
const memoized = memo(callback);
|
|
7
|
-
return () =>
|
|
7
|
+
return () => supportsFlags[supportsFlag] ?? memoized();
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export { memoSupports };
|
|
@@ -33,7 +33,7 @@ class MotionValue {
|
|
|
33
33
|
* This will be replaced by the build step with the latest version number.
|
|
34
34
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
35
35
|
*/
|
|
36
|
-
this.version = "12.6.3
|
|
36
|
+
this.version = "12.6.3";
|
|
37
37
|
/**
|
|
38
38
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
39
39
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let warning = noop;
|
|
4
|
-
let invariant = noop;
|
|
1
|
+
let warning = () => { };
|
|
2
|
+
let invariant = () => { };
|
|
5
3
|
if (process.env.NODE_ENV !== "production") {
|
|
6
4
|
warning = (check, message) => {
|
|
7
5
|
if (!check && typeof console !== "undefined") {
|