framer-motion 12.20.3 → 12.20.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/README.md +1 -1
- package/dist/cjs/client.js +1 -1
- package/dist/cjs/{create-ByDLj_LU.js → create-BOq2yHIj.js} +47 -31
- package/dist/cjs/dom.js +13 -5
- package/dist/cjs/index.js +1 -1
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +1 -1
- package/dist/es/projection/node/DocumentProjectionNode.mjs +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +35 -27
- package/dist/es/render/html/utils/render.mjs +12 -4
- package/dist/es/utils/reduced-motion/index.mjs +1 -1
- package/dist/framer-motion.dev.js +47 -31
- package/dist/framer-motion.js +1 -1
- package/dist/m.d.ts +14 -5
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/types/client.d.ts +1 -1
- package/dist/types/index.d.ts +8 -8
- package/dist/{types.d-BSoEx4Ea.d.ts → types.d-D0HXPxHm.d.ts} +27 -18
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img width="
|
|
2
|
+
<img width="42" height="42" alt="Motion logo" src="https://github.com/user-attachments/assets/00d6d1c3-72c4-4c2f-a664-69da13182ffc" />
|
|
3
3
|
</p>
|
|
4
4
|
<h1 align="center">Motion for React</h1>
|
|
5
5
|
<h3 align="center">
|
package/dist/cjs/client.js
CHANGED
|
@@ -911,7 +911,6 @@ const metrics = {
|
|
|
911
911
|
calculatedProjections: 0,
|
|
912
912
|
};
|
|
913
913
|
const transformAxes = ["", "X", "Y", "Z"];
|
|
914
|
-
const hiddenVisibility = { visibility: "hidden" };
|
|
915
914
|
/**
|
|
916
915
|
* We use 1000 as the animation target as 0-1000 maps better to pixels than 0-1
|
|
917
916
|
* which has a noticeable difference in spring animations
|
|
@@ -1133,8 +1132,17 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
1133
1132
|
}
|
|
1134
1133
|
if (attachResizeListener) {
|
|
1135
1134
|
let cancelDelay;
|
|
1135
|
+
let innerWidth = 0;
|
|
1136
1136
|
const resizeUnblockUpdate = () => (this.root.updateBlockedByResize = false);
|
|
1137
|
+
// Set initial innerWidth in a frame.read callback to batch the read
|
|
1138
|
+
motionDom.frame.read(() => {
|
|
1139
|
+
innerWidth = window.innerWidth;
|
|
1140
|
+
});
|
|
1137
1141
|
attachResizeListener(instance, () => {
|
|
1142
|
+
const newInnerWidth = window.innerWidth;
|
|
1143
|
+
if (newInnerWidth === innerWidth)
|
|
1144
|
+
return;
|
|
1145
|
+
innerWidth = newInnerWidth;
|
|
1138
1146
|
this.root.updateBlockedByResize = true;
|
|
1139
1147
|
cancelDelay && cancelDelay();
|
|
1140
1148
|
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
@@ -2141,59 +2149,60 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
2141
2149
|
// see the element with the reset rotate value applied.
|
|
2142
2150
|
visualElement.scheduleRender();
|
|
2143
2151
|
}
|
|
2144
|
-
|
|
2152
|
+
applyProjectionStyles(targetStyle, // CSSStyleDeclaration - doesn't allow numbers to be assigned to properties
|
|
2153
|
+
styleProp) {
|
|
2145
2154
|
if (!this.instance || this.isSVG)
|
|
2146
|
-
return
|
|
2155
|
+
return;
|
|
2147
2156
|
if (!this.isVisible) {
|
|
2148
|
-
|
|
2157
|
+
targetStyle.visibility = "hidden";
|
|
2158
|
+
return;
|
|
2149
2159
|
}
|
|
2150
|
-
const styles = {
|
|
2151
|
-
visibility: "",
|
|
2152
|
-
};
|
|
2153
2160
|
const transformTemplate = this.getTransformTemplate();
|
|
2154
2161
|
if (this.needsReset) {
|
|
2155
2162
|
this.needsReset = false;
|
|
2156
|
-
|
|
2157
|
-
|
|
2163
|
+
targetStyle.visibility = "";
|
|
2164
|
+
targetStyle.opacity = "";
|
|
2165
|
+
targetStyle.pointerEvents =
|
|
2158
2166
|
resolveMotionValue(styleProp?.pointerEvents) || "";
|
|
2159
|
-
|
|
2167
|
+
targetStyle.transform = transformTemplate
|
|
2160
2168
|
? transformTemplate(this.latestValues, "")
|
|
2161
2169
|
: "none";
|
|
2162
|
-
return
|
|
2170
|
+
return;
|
|
2163
2171
|
}
|
|
2164
2172
|
const lead = this.getLead();
|
|
2165
2173
|
if (!this.projectionDelta || !this.layout || !lead.target) {
|
|
2166
|
-
const emptyStyles = {};
|
|
2167
2174
|
if (this.options.layoutId) {
|
|
2168
|
-
|
|
2175
|
+
targetStyle.opacity =
|
|
2169
2176
|
this.latestValues.opacity !== undefined
|
|
2170
2177
|
? this.latestValues.opacity
|
|
2171
2178
|
: 1;
|
|
2172
|
-
|
|
2179
|
+
targetStyle.pointerEvents =
|
|
2173
2180
|
resolveMotionValue(styleProp?.pointerEvents) || "";
|
|
2174
2181
|
}
|
|
2175
2182
|
if (this.hasProjected && !hasTransform(this.latestValues)) {
|
|
2176
|
-
|
|
2183
|
+
targetStyle.transform = transformTemplate
|
|
2177
2184
|
? transformTemplate({}, "")
|
|
2178
2185
|
: "none";
|
|
2179
2186
|
this.hasProjected = false;
|
|
2180
2187
|
}
|
|
2181
|
-
return
|
|
2188
|
+
return;
|
|
2182
2189
|
}
|
|
2190
|
+
targetStyle.visibility = "";
|
|
2183
2191
|
const valuesToRender = lead.animationValues || lead.latestValues;
|
|
2184
2192
|
this.applyTransformsToTarget();
|
|
2185
|
-
|
|
2193
|
+
let transform = buildProjectionTransform(this.projectionDeltaWithTransform, this.treeScale, valuesToRender);
|
|
2186
2194
|
if (transformTemplate) {
|
|
2187
|
-
|
|
2195
|
+
transform = transformTemplate(valuesToRender, transform);
|
|
2188
2196
|
}
|
|
2197
|
+
targetStyle.transform = transform;
|
|
2189
2198
|
const { x, y } = this.projectionDelta;
|
|
2190
|
-
|
|
2199
|
+
targetStyle.transformOrigin = `${x.origin * 100}% ${y.origin * 100}% 0`;
|
|
2191
2200
|
if (lead.animationValues) {
|
|
2192
2201
|
/**
|
|
2193
2202
|
* If the lead component is animating, assign this either the entering/leaving
|
|
2194
2203
|
* opacity
|
|
2195
2204
|
*/
|
|
2196
|
-
|
|
2205
|
+
targetStyle.opacity =
|
|
2197
2206
|
lead === this
|
|
2198
2207
|
? valuesToRender.opacity ??
|
|
2199
2208
|
this.latestValues.opacity ??
|
|
@@ -2207,7 +2216,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
2207
2216
|
* Or we're not animating at all, set the lead component to its layout
|
|
2208
2217
|
* opacity and other components to hidden.
|
|
2209
2218
|
*/
|
|
2210
|
-
|
|
2219
|
+
targetStyle.opacity =
|
|
2211
2220
|
lead === this
|
|
2212
2221
|
? valuesToRender.opacity !== undefined
|
|
2213
2222
|
? valuesToRender.opacity
|
|
@@ -2229,13 +2238,13 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
2229
2238
|
* vulnerable to distortion if the element changes size without
|
|
2230
2239
|
* a corresponding layout animation.
|
|
2231
2240
|
*/
|
|
2232
|
-
const corrected =
|
|
2241
|
+
const corrected = transform === "none"
|
|
2233
2242
|
? valuesToRender[key]
|
|
2234
2243
|
: correct(valuesToRender[key], lead);
|
|
2235
2244
|
if (applyTo) {
|
|
2236
2245
|
const num = applyTo.length;
|
|
2237
2246
|
for (let i = 0; i < num; i++) {
|
|
2238
|
-
|
|
2247
|
+
targetStyle[applyTo[i]] = corrected;
|
|
2239
2248
|
}
|
|
2240
2249
|
}
|
|
2241
2250
|
else {
|
|
@@ -2246,7 +2255,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
2246
2255
|
this.options.visualElement.renderState.vars[key] = corrected;
|
|
2247
2256
|
}
|
|
2248
2257
|
else {
|
|
2249
|
-
|
|
2258
|
+
targetStyle[key] = corrected;
|
|
2250
2259
|
}
|
|
2251
2260
|
}
|
|
2252
2261
|
}
|
|
@@ -2256,12 +2265,11 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
2256
2265
|
* pointer events on the lead.
|
|
2257
2266
|
*/
|
|
2258
2267
|
if (this.options.layoutId) {
|
|
2259
|
-
|
|
2268
|
+
targetStyle.pointerEvents =
|
|
2260
2269
|
lead === this
|
|
2261
2270
|
? resolveMotionValue(styleProp?.pointerEvents) || ""
|
|
2262
2271
|
: "none";
|
|
2263
2272
|
}
|
|
2264
|
-
return styles;
|
|
2265
2273
|
}
|
|
2266
2274
|
clearSnapshot() {
|
|
2267
2275
|
this.resumeFrom = this.snapshot = undefined;
|
|
@@ -2676,7 +2684,7 @@ function initPrefersReducedMotion() {
|
|
|
2676
2684
|
if (window.matchMedia) {
|
|
2677
2685
|
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
2678
2686
|
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
2679
|
-
motionMediaQuery.
|
|
2687
|
+
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
|
2680
2688
|
setReducedMotionPreferences();
|
|
2681
2689
|
}
|
|
2682
2690
|
else {
|
|
@@ -3409,10 +3417,18 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
|
3409
3417
|
}
|
|
3410
3418
|
|
|
3411
3419
|
function renderHTML(element, { style, vars }, styleProp, projection) {
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
for (
|
|
3415
|
-
|
|
3420
|
+
const elementStyle = element.style;
|
|
3421
|
+
let key;
|
|
3422
|
+
for (key in style) {
|
|
3423
|
+
// CSSStyleDeclaration has [index: number]: string; in the types, so we use that as key type.
|
|
3424
|
+
elementStyle[key] = style[key];
|
|
3425
|
+
}
|
|
3426
|
+
// Write projection styles directly to element style
|
|
3427
|
+
projection?.applyProjectionStyles(elementStyle, styleProp);
|
|
3428
|
+
for (key in vars) {
|
|
3429
|
+
// Loop over any CSS variables and assign those.
|
|
3430
|
+
// They can only be assigned using `setProperty`.
|
|
3431
|
+
elementStyle.setProperty(key, vars[key]);
|
|
3416
3432
|
}
|
|
3417
3433
|
}
|
|
3418
3434
|
|
package/dist/cjs/dom.js
CHANGED
|
@@ -747,7 +747,7 @@ function initPrefersReducedMotion() {
|
|
|
747
747
|
if (window.matchMedia) {
|
|
748
748
|
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
749
749
|
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
750
|
-
motionMediaQuery.
|
|
750
|
+
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
|
751
751
|
setReducedMotionPreferences();
|
|
752
752
|
}
|
|
753
753
|
else {
|
|
@@ -1443,10 +1443,18 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
|
1443
1443
|
}
|
|
1444
1444
|
|
|
1445
1445
|
function renderHTML(element, { style, vars }, styleProp, projection) {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
for (
|
|
1449
|
-
|
|
1446
|
+
const elementStyle = element.style;
|
|
1447
|
+
let key;
|
|
1448
|
+
for (key in style) {
|
|
1449
|
+
// CSSStyleDeclaration has [index: number]: string; in the types, so we use that as key type.
|
|
1450
|
+
elementStyle[key] = style[key];
|
|
1451
|
+
}
|
|
1452
|
+
// Write projection styles directly to element style
|
|
1453
|
+
projection?.applyProjectionStyles(elementStyle, styleProp);
|
|
1454
|
+
for (key in vars) {
|
|
1455
|
+
// Loop over any CSS variables and assign those.
|
|
1456
|
+
// They can only be assigned using `setProperty`.
|
|
1457
|
+
elementStyle.setProperty(key, vars[key]);
|
|
1450
1458
|
}
|
|
1451
1459
|
}
|
|
1452
1460
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var create = require('./create-
|
|
7
|
+
var create = require('./create-BOq2yHIj.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnresolvedValueKeyframe, MotionValue, Transition, ElementOrSelector, DOMKeyframesDefinition, AnimationOptions, AnimationPlaybackOptions, AnimationScope, AnimationPlaybackControlsWithThen, ValueAnimationTransition, AnimationPlaybackControls, DynamicOption } from 'motion-dom';
|
|
1
|
+
import { UnresolvedValueKeyframe, MotionValue, Transition, ElementOrSelector, DOMKeyframesDefinition, AnimationOptions, AnimationPlaybackOptions, AnyResolvedKeyframe, AnimationScope, AnimationPlaybackControlsWithThen, ValueAnimationTransition, AnimationPlaybackControls, DynamicOption } from 'motion-dom';
|
|
2
2
|
export * from 'motion-dom';
|
|
3
3
|
import { Easing, EasingFunction, Point } from 'motion-utils';
|
|
4
4
|
export * from 'motion-utils';
|
|
@@ -44,7 +44,7 @@ interface SequenceOptions extends AnimationPlaybackOptions {
|
|
|
44
44
|
defaultTransition?: Transition;
|
|
45
45
|
}
|
|
46
46
|
interface AbsoluteKeyframe {
|
|
47
|
-
value:
|
|
47
|
+
value: AnyResolvedKeyframe | null;
|
|
48
48
|
at: number;
|
|
49
49
|
easing?: Easing;
|
|
50
50
|
}
|