framer-motion 9.0.2 → 9.0.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/index.js +3344 -3260
- package/dist/es/animation/hooks/use-animated-state.mjs +3 -3
- package/dist/es/animation/index.mjs +3 -5
- package/dist/es/animation/legacy-popmotion/index.mjs +6 -2
- package/dist/es/animation/legacy-popmotion/inertia.mjs +4 -5
- package/dist/es/components/AnimatePresence/use-presence.mjs +0 -1
- package/dist/es/events/add-dom-event.mjs +6 -0
- package/dist/es/events/add-pointer-event.mjs +8 -0
- package/dist/es/events/use-dom-event.mjs +2 -5
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +31 -30
- package/dist/es/gestures/drag/index.mjs +27 -0
- package/dist/es/gestures/focus.mjs +42 -0
- package/dist/es/gestures/hover.mjs +32 -0
- package/dist/es/gestures/{PanSession.mjs → pan/PanSession.mjs} +8 -8
- package/dist/es/gestures/pan/index.mjs +38 -0
- package/dist/es/gestures/press.mjs +109 -0
- package/dist/es/index.mjs +1 -1
- package/dist/es/motion/features/Feature.mjs +9 -0
- package/dist/es/motion/features/animation/exit.mjs +32 -0
- package/dist/es/motion/features/animation/index.mjs +38 -0
- package/dist/es/motion/features/animations.mjs +8 -37
- package/dist/es/motion/features/definitions.mjs +17 -23
- package/dist/es/motion/features/drag.mjs +12 -5
- package/dist/es/motion/features/gestures.mjs +16 -9
- package/dist/es/motion/features/layout/MeasureLayout.mjs +5 -5
- package/dist/es/motion/features/layout.mjs +11 -0
- package/dist/es/motion/features/load-features.mjs +4 -6
- package/dist/es/motion/features/viewport/index.mjs +96 -0
- package/dist/es/motion/index.mjs +12 -13
- package/dist/es/motion/utils/use-visual-element.mjs +8 -2
- package/dist/es/projection/geometry/delta-apply.mjs +9 -2
- package/dist/es/projection/geometry/delta-calc.mjs +2 -2
- package/dist/es/projection/geometry/delta-remove.mjs +2 -2
- package/dist/es/projection/node/DocumentProjectionNode.mjs +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +65 -57
- package/dist/es/projection/node/group.mjs +5 -3
- package/dist/es/projection/shared/stack.mjs +7 -5
- package/dist/es/render/VisualElement.mjs +68 -47
- package/dist/es/render/dom/DOMVisualElement.mjs +1 -2
- package/dist/es/render/dom/features-max.mjs +2 -4
- package/dist/es/render/dom/motion.mjs +5 -6
- package/dist/es/render/dom/utils/create-config.mjs +1 -2
- package/dist/es/render/dom/value-types/animatable-none.mjs +3 -2
- package/dist/es/render/svg/SVGVisualElement.mjs +2 -2
- package/dist/es/render/utils/animation-state.mjs +6 -2
- package/dist/es/render/utils/animation.mjs +4 -4
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/render/utils/setters.mjs +14 -9
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/utils/is-motion-value.mjs +1 -1
- package/dist/framer-motion.dev.js +3341 -3257
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +85 -77
- package/dist/projection.dev.js +217 -177
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- package/dist/size-rollup-dom-animation-m.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max-assets.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/size-webpack-m.js +1 -1
- package/dist/three-entry.d.ts +74 -38
- package/package.json +8 -8
- package/dist/es/events/use-pointer-event.mjs +0 -11
- package/dist/es/gestures/drag/use-drag.mjs +0 -20
- package/dist/es/gestures/use-focus-gesture.mjs +0 -37
- package/dist/es/gestures/use-hover-gesture.mjs +0 -32
- package/dist/es/gestures/use-pan-gesture.mjs +0 -46
- package/dist/es/gestures/use-tap-gesture.mjs +0 -115
- package/dist/es/motion/features/layout/index.mjs +0 -7
- package/dist/es/motion/features/viewport/use-viewport.mjs +0 -97
- package/dist/es/motion/utils/VisualElementHandler.mjs +0 -19
- package/dist/es/motion/utils/make-renderless-component.mjs +0 -6
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { sync, cancelSync } from '../frameloop/index.mjs';
|
|
2
2
|
import { warning, invariant } from 'hey-listen';
|
|
3
|
-
import { createElement } from 'react';
|
|
4
|
-
import { featureDefinitions } from '../motion/features/definitions.mjs';
|
|
5
3
|
import { createBox } from '../projection/geometry/models.mjs';
|
|
6
4
|
import { isRefObject } from '../utils/is-ref-object.mjs';
|
|
7
5
|
import { initPrefersReducedMotion } from '../utils/reduced-motion/index.mjs';
|
|
@@ -17,6 +15,7 @@ import { isVariantLabel } from './utils/is-variant-label.mjs';
|
|
|
17
15
|
import { updateMotionValuesFromProps } from './utils/motion-values.mjs';
|
|
18
16
|
import { resolveVariantFromProps } from './utils/resolve-variants.mjs';
|
|
19
17
|
import { warnOnce } from '../utils/warn-once.mjs';
|
|
18
|
+
import { featureDefinitions } from '../motion/features/definitions.mjs';
|
|
20
19
|
|
|
21
20
|
const featureNames = Object.keys(featureDefinitions);
|
|
22
21
|
const numFeatures = featureNames.length;
|
|
@@ -34,7 +33,7 @@ const propEventHandlers = [
|
|
|
34
33
|
* HTMLElement, SVGElement, Three.Object3D etc.
|
|
35
34
|
*/
|
|
36
35
|
class VisualElement {
|
|
37
|
-
constructor({ parent, props, reducedMotionConfig, visualState, }, options = {}) {
|
|
36
|
+
constructor({ parent, props, presenceContext, reducedMotionConfig, visualState, }, options = {}) {
|
|
38
37
|
/**
|
|
39
38
|
* A reference to the current underlying Instance, e.g. a HTMLElement
|
|
40
39
|
* or Three.Mesh etc.
|
|
@@ -64,10 +63,9 @@ class VisualElement {
|
|
|
64
63
|
*/
|
|
65
64
|
this.values = new Map();
|
|
66
65
|
/**
|
|
67
|
-
*
|
|
68
|
-
* within the defined React tree.
|
|
66
|
+
* Cleanup functions for active features (hover/tap/exit etc)
|
|
69
67
|
*/
|
|
70
|
-
this.
|
|
68
|
+
this.features = {};
|
|
71
69
|
/**
|
|
72
70
|
* A map of every subscription that binds the provided or generated
|
|
73
71
|
* motion values onChange listeners to this visual element.
|
|
@@ -104,6 +102,7 @@ class VisualElement {
|
|
|
104
102
|
this.renderState = renderState;
|
|
105
103
|
this.parent = parent;
|
|
106
104
|
this.props = props;
|
|
105
|
+
this.presenceContext = presenceContext;
|
|
107
106
|
this.depth = parent ? parent.depth + 1 : 0;
|
|
108
107
|
this.reducedMotionConfig = reducedMotionConfig;
|
|
109
108
|
this.options = options;
|
|
@@ -145,13 +144,12 @@ class VisualElement {
|
|
|
145
144
|
return {};
|
|
146
145
|
}
|
|
147
146
|
mount(instance) {
|
|
148
|
-
var _a;
|
|
149
147
|
this.current = instance;
|
|
150
148
|
if (this.projection) {
|
|
151
149
|
this.projection.mount(instance);
|
|
152
150
|
}
|
|
153
151
|
if (this.parent && this.isVariantNode && !this.isControllingVariants) {
|
|
154
|
-
this.removeFromVariantTree =
|
|
152
|
+
this.removeFromVariantTree = this.parent.addVariantChild(this);
|
|
155
153
|
}
|
|
156
154
|
this.values.forEach((value, key) => this.bindToMotionValue(key, value));
|
|
157
155
|
if (!hasReducedMotionListener.current) {
|
|
@@ -168,19 +166,21 @@ class VisualElement {
|
|
|
168
166
|
}
|
|
169
167
|
if (this.parent)
|
|
170
168
|
this.parent.children.add(this);
|
|
171
|
-
this.
|
|
169
|
+
this.update(this.props, this.presenceContext);
|
|
172
170
|
}
|
|
173
171
|
unmount() {
|
|
174
|
-
|
|
175
|
-
(_a = this.projection) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
172
|
+
this.projection && this.projection.unmount();
|
|
176
173
|
cancelSync.update(this.notifyUpdate);
|
|
177
174
|
cancelSync.render(this.render);
|
|
178
175
|
this.valueSubscriptions.forEach((remove) => remove());
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
this.removeFromVariantTree && this.removeFromVariantTree();
|
|
177
|
+
this.parent && this.parent.children.delete(this);
|
|
181
178
|
for (const key in this.events) {
|
|
182
179
|
this.events[key].clear();
|
|
183
180
|
}
|
|
181
|
+
for (const key in this.features) {
|
|
182
|
+
this.features[key].unmount();
|
|
183
|
+
}
|
|
184
184
|
this.current = null;
|
|
185
185
|
}
|
|
186
186
|
bindToMotionValue(key, value) {
|
|
@@ -205,12 +205,14 @@ class VisualElement {
|
|
|
205
205
|
*/
|
|
206
206
|
if (!this.current ||
|
|
207
207
|
!this.sortInstanceNodePosition ||
|
|
208
|
-
this.type !== other.type)
|
|
208
|
+
this.type !== other.type) {
|
|
209
209
|
return 0;
|
|
210
|
+
}
|
|
210
211
|
return this.sortInstanceNodePosition(this.current, other.current);
|
|
211
212
|
}
|
|
212
|
-
loadFeatures({ children, ...renderedProps }, isStrict, preloadedFeatures, projectionId,
|
|
213
|
-
|
|
213
|
+
loadFeatures({ children, ...renderedProps }, isStrict, preloadedFeatures, projectionId, initialLayoutGroupConfig) {
|
|
214
|
+
let ProjectionNodeConstructor;
|
|
215
|
+
let MeasureLayout;
|
|
214
216
|
/**
|
|
215
217
|
* If we're in development mode, check to make sure we're not rendering a motion component
|
|
216
218
|
* as a child of LazyMotion, as this will break the file-size benefits of using it.
|
|
@@ -225,18 +227,16 @@ class VisualElement {
|
|
|
225
227
|
}
|
|
226
228
|
for (let i = 0; i < numFeatures; i++) {
|
|
227
229
|
const name = featureNames[i];
|
|
228
|
-
const { isEnabled,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
visualElement: this,
|
|
239
|
-
}));
|
|
230
|
+
const { isEnabled, Feature: FeatureConstructor, ProjectionNode, MeasureLayout: MeasureLayoutComponent, } = featureDefinitions[name];
|
|
231
|
+
if (ProjectionNode)
|
|
232
|
+
ProjectionNodeConstructor = ProjectionNode;
|
|
233
|
+
if (isEnabled(renderedProps)) {
|
|
234
|
+
if (!this.features[name] && FeatureConstructor) {
|
|
235
|
+
this.features[name] = new FeatureConstructor(this);
|
|
236
|
+
}
|
|
237
|
+
if (MeasureLayoutComponent) {
|
|
238
|
+
MeasureLayout = MeasureLayoutComponent;
|
|
239
|
+
}
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
if (!this.projection && ProjectionNodeConstructor) {
|
|
@@ -262,7 +262,19 @@ class VisualElement {
|
|
|
262
262
|
layoutRoot,
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
|
-
return
|
|
265
|
+
return MeasureLayout;
|
|
266
|
+
}
|
|
267
|
+
updateFeatures() {
|
|
268
|
+
for (const key in this.features) {
|
|
269
|
+
const feature = this.features[key];
|
|
270
|
+
if (feature.isMounted) {
|
|
271
|
+
feature.update(this.props, this.prevProps);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
feature.mount();
|
|
275
|
+
feature.isMounted = true;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
266
278
|
}
|
|
267
279
|
triggerBuild() {
|
|
268
280
|
this.build(this.renderState, this.latestValues, this.options, this.props);
|
|
@@ -297,12 +309,14 @@ class VisualElement {
|
|
|
297
309
|
* Update the provided props. Ensure any newly-added motion values are
|
|
298
310
|
* added to our map, old ones removed, and listeners updated.
|
|
299
311
|
*/
|
|
300
|
-
|
|
312
|
+
update(props, presenceContext) {
|
|
301
313
|
if (props.transformTemplate || this.props.transformTemplate) {
|
|
302
314
|
this.scheduleRender();
|
|
303
315
|
}
|
|
304
|
-
|
|
316
|
+
this.prevProps = this.props;
|
|
305
317
|
this.props = props;
|
|
318
|
+
this.prevPresenceContext = this.presenceContext;
|
|
319
|
+
this.presenceContext = presenceContext;
|
|
306
320
|
/**
|
|
307
321
|
* Update prop event handlers ie onAnimationStart, onAnimationComplete
|
|
308
322
|
*/
|
|
@@ -317,7 +331,7 @@ class VisualElement {
|
|
|
317
331
|
this.propEventSubscriptions[key] = this.on(key, listener);
|
|
318
332
|
}
|
|
319
333
|
}
|
|
320
|
-
this.prevMotionValues = updateMotionValuesFromProps(this, this.scrapeMotionValuesFromProps(props, prevProps), this.prevMotionValues);
|
|
334
|
+
this.prevMotionValues = updateMotionValuesFromProps(this, this.scrapeMotionValuesFromProps(props, this.prevProps), this.prevMotionValues);
|
|
321
335
|
if (this.handleChildMotionValue) {
|
|
322
336
|
this.handleChildMotionValue();
|
|
323
337
|
}
|
|
@@ -329,8 +343,7 @@ class VisualElement {
|
|
|
329
343
|
* Returns the variant definition with a given name.
|
|
330
344
|
*/
|
|
331
345
|
getVariant(name) {
|
|
332
|
-
|
|
333
|
-
return (_a = this.props.variants) === null || _a === void 0 ? void 0 : _a[name];
|
|
346
|
+
return this.props.variants ? this.props.variants[name] : undefined;
|
|
334
347
|
}
|
|
335
348
|
/**
|
|
336
349
|
* Returns the defined default transition on this component.
|
|
@@ -342,15 +355,20 @@ class VisualElement {
|
|
|
342
355
|
return this.props.transformPagePoint;
|
|
343
356
|
}
|
|
344
357
|
getClosestVariantNode() {
|
|
345
|
-
|
|
346
|
-
|
|
358
|
+
return this.isVariantNode
|
|
359
|
+
? this
|
|
360
|
+
: this.parent
|
|
361
|
+
? this.parent.getClosestVariantNode()
|
|
362
|
+
: undefined;
|
|
347
363
|
}
|
|
348
364
|
getVariantContext(startAtParent = false) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
365
|
+
if (startAtParent) {
|
|
366
|
+
return this.parent ? this.parent.getVariantContext() : undefined;
|
|
367
|
+
}
|
|
352
368
|
if (!this.isControllingVariants) {
|
|
353
|
-
const context =
|
|
369
|
+
const context = this.parent
|
|
370
|
+
? this.parent.getVariantContext() || {}
|
|
371
|
+
: {};
|
|
354
372
|
if (this.props.initial !== undefined) {
|
|
355
373
|
context.initial = this.props.initial;
|
|
356
374
|
}
|
|
@@ -370,10 +388,10 @@ class VisualElement {
|
|
|
370
388
|
* Add a child visual element to our set of children.
|
|
371
389
|
*/
|
|
372
390
|
addVariantChild(child) {
|
|
373
|
-
var _a;
|
|
374
391
|
const closestVariantNode = this.getClosestVariantNode();
|
|
375
392
|
if (closestVariantNode) {
|
|
376
|
-
|
|
393
|
+
closestVariantNode.variantChildren &&
|
|
394
|
+
closestVariantNode.variantChildren.add(child);
|
|
377
395
|
return () => closestVariantNode.variantChildren.delete(child);
|
|
378
396
|
}
|
|
379
397
|
}
|
|
@@ -393,10 +411,12 @@ class VisualElement {
|
|
|
393
411
|
* Remove a motion value and unbind any active subscriptions.
|
|
394
412
|
*/
|
|
395
413
|
removeValue(key) {
|
|
396
|
-
var _a;
|
|
397
414
|
this.values.delete(key);
|
|
398
|
-
|
|
399
|
-
|
|
415
|
+
const unsubscribe = this.valueSubscriptions.get(key);
|
|
416
|
+
if (unsubscribe) {
|
|
417
|
+
unsubscribe();
|
|
418
|
+
this.valueSubscriptions.delete(key);
|
|
419
|
+
}
|
|
400
420
|
delete this.latestValues[key];
|
|
401
421
|
this.removeValueFromRenderState(key, this.renderState);
|
|
402
422
|
}
|
|
@@ -473,8 +493,9 @@ class VisualElement {
|
|
|
473
493
|
return this.events[eventName].add(callback);
|
|
474
494
|
}
|
|
475
495
|
notify(eventName, ...args) {
|
|
476
|
-
|
|
477
|
-
|
|
496
|
+
if (this.events[eventName]) {
|
|
497
|
+
this.events[eventName].notify(...args);
|
|
498
|
+
}
|
|
478
499
|
}
|
|
479
500
|
}
|
|
480
501
|
const variantProps = ["initial", ...variantPriorityOrder];
|
|
@@ -12,8 +12,7 @@ class DOMVisualElement extends VisualElement {
|
|
|
12
12
|
return a.compareDocumentPosition(b) & 2 ? 1 : -1;
|
|
13
13
|
}
|
|
14
14
|
getBaseTargetFromProps(props, key) {
|
|
15
|
-
|
|
16
|
-
return (_a = props.style) === null || _a === void 0 ? void 0 : _a[key];
|
|
15
|
+
return props.style ? props.style[key] : undefined;
|
|
17
16
|
}
|
|
18
17
|
removeValueFromRenderState(key, { vars, style }) {
|
|
19
18
|
delete vars[key];
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { drag } from '../../motion/features/drag.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { layout } from '../../motion/features/layout.mjs';
|
|
3
3
|
import { domAnimation } from './features-animation.mjs';
|
|
4
|
-
import { HTMLProjectionNode } from '../../projection/node/HTMLProjectionNode.mjs';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @public
|
|
@@ -9,8 +8,7 @@ import { HTMLProjectionNode } from '../../projection/node/HTMLProjectionNode.mjs
|
|
|
9
8
|
const domMax = {
|
|
10
9
|
...domAnimation,
|
|
11
10
|
...drag,
|
|
12
|
-
...
|
|
13
|
-
projectionNodeConstructor: HTMLProjectionNode,
|
|
11
|
+
...layout,
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
export { domMax };
|
|
@@ -5,14 +5,13 @@ import { gestureAnimations } from '../../motion/features/gestures.mjs';
|
|
|
5
5
|
import { animations } from '../../motion/features/animations.mjs';
|
|
6
6
|
import { drag } from '../../motion/features/drag.mjs';
|
|
7
7
|
import { createDomVisualElement } from './create-visual-element.mjs';
|
|
8
|
-
import {
|
|
9
|
-
import { HTMLProjectionNode } from '../../projection/node/HTMLProjectionNode.mjs';
|
|
8
|
+
import { layout } from '../../motion/features/layout.mjs';
|
|
10
9
|
|
|
11
|
-
const
|
|
10
|
+
const preloadedFeatures = {
|
|
12
11
|
...animations,
|
|
13
12
|
...gestureAnimations,
|
|
14
13
|
...drag,
|
|
15
|
-
...
|
|
14
|
+
...layout,
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
17
|
* HTML & SVG components, optimised for use with gestures and animation. These can be used as
|
|
@@ -20,7 +19,7 @@ const featureBundle = {
|
|
|
20
19
|
*
|
|
21
20
|
* @public
|
|
22
21
|
*/
|
|
23
|
-
const motion = /*@__PURE__*/ createMotionProxy((Component, config) => createDomMotionConfig(Component, config,
|
|
22
|
+
const motion = /*@__PURE__*/ createMotionProxy((Component, config) => createDomMotionConfig(Component, config, preloadedFeatures, createDomVisualElement));
|
|
24
23
|
/**
|
|
25
24
|
* Create a DOM `motion` component with the provided string. This is primarily intended
|
|
26
25
|
* as a full alternative to `motion` for consumers who have to support environments that don't
|
|
@@ -37,7 +36,7 @@ const motion = /*@__PURE__*/ createMotionProxy((Component, config) => createDomM
|
|
|
37
36
|
* @public
|
|
38
37
|
*/
|
|
39
38
|
function createDomMotionComponent(key) {
|
|
40
|
-
return createMotionComponent(createDomMotionConfig(key, { forwardMotionProps: false },
|
|
39
|
+
return createMotionComponent(createDomMotionConfig(key, { forwardMotionProps: false }, preloadedFeatures, createDomVisualElement));
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
export { createDomMotionComponent, motion };
|
|
@@ -3,7 +3,7 @@ import { createUseRender } from '../use-render.mjs';
|
|
|
3
3
|
import { svgMotionConfig } from '../../svg/config-motion.mjs';
|
|
4
4
|
import { htmlMotionConfig } from '../../html/config-motion.mjs';
|
|
5
5
|
|
|
6
|
-
function createDomMotionConfig(Component, { forwardMotionProps = false }, preloadedFeatures, createVisualElement
|
|
6
|
+
function createDomMotionConfig(Component, { forwardMotionProps = false }, preloadedFeatures, createVisualElement) {
|
|
7
7
|
const baseConfig = isSVGComponent(Component)
|
|
8
8
|
? svgMotionConfig
|
|
9
9
|
: htmlMotionConfig;
|
|
@@ -12,7 +12,6 @@ function createDomMotionConfig(Component, { forwardMotionProps = false }, preloa
|
|
|
12
12
|
preloadedFeatures,
|
|
13
13
|
useRender: createUseRender(forwardMotionProps),
|
|
14
14
|
createVisualElement,
|
|
15
|
-
projectionNodeConstructor,
|
|
16
15
|
Component,
|
|
17
16
|
};
|
|
18
17
|
}
|
|
@@ -3,12 +3,13 @@ import { filter } from '../../../value/types/complex/filter.mjs';
|
|
|
3
3
|
import { getDefaultValueType } from './defaults.mjs';
|
|
4
4
|
|
|
5
5
|
function getAnimatableNone(key, value) {
|
|
6
|
-
var _a;
|
|
7
6
|
let defaultValueType = getDefaultValueType(key);
|
|
8
7
|
if (defaultValueType !== filter)
|
|
9
8
|
defaultValueType = complex;
|
|
10
9
|
// If value is not recognised as animatable, ie "none", create an animatable version origin based on the target
|
|
11
|
-
return
|
|
10
|
+
return defaultValueType.getAnimatableNone
|
|
11
|
+
? defaultValueType.getAnimatableNone(value)
|
|
12
|
+
: undefined;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export { getAnimatableNone };
|
|
@@ -18,9 +18,9 @@ class SVGVisualElement extends DOMVisualElement {
|
|
|
18
18
|
return props[key];
|
|
19
19
|
}
|
|
20
20
|
readValueFromInstance(instance, key) {
|
|
21
|
-
var _a;
|
|
22
21
|
if (transformProps.has(key)) {
|
|
23
|
-
|
|
22
|
+
const defaultType = getDefaultValueType(key);
|
|
23
|
+
return defaultType ? defaultType.default || 0 : 0;
|
|
24
24
|
}
|
|
25
25
|
key = !camelCaseAttributes.has(key) ? camelToDash(key) : key;
|
|
26
26
|
return instance.getAttribute(key);
|
|
@@ -276,12 +276,16 @@ function createAnimationState(visualElement) {
|
|
|
276
276
|
* Change whether a certain animation type is active.
|
|
277
277
|
*/
|
|
278
278
|
function setActive(type, isActive, options) {
|
|
279
|
-
var _a;
|
|
280
279
|
// If the active state hasn't changed, we can safely do nothing here
|
|
281
280
|
if (state[type].isActive === isActive)
|
|
282
281
|
return Promise.resolve();
|
|
283
282
|
// Propagate active change to children
|
|
284
|
-
(
|
|
283
|
+
if (visualElement.variantChildren) {
|
|
284
|
+
visualElement.variantChildren.forEach((child) => {
|
|
285
|
+
child.animationState &&
|
|
286
|
+
child.animationState.setActive(type, isActive);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
285
289
|
state[type].isActive = isActive;
|
|
286
290
|
const animations = animateChanges(options, type);
|
|
287
291
|
for (const key in state) {
|
|
@@ -25,7 +25,6 @@ function animateVisualElement(visualElement, definition, options = {}) {
|
|
|
25
25
|
return animation.then(() => visualElement.notify("AnimationComplete", definition));
|
|
26
26
|
}
|
|
27
27
|
function animateVariant(visualElement, variant, options = {}) {
|
|
28
|
-
var _a;
|
|
29
28
|
const resolved = resolveVariant(visualElement, variant, options.custom);
|
|
30
29
|
let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
|
|
31
30
|
if (options.transitionOverride) {
|
|
@@ -42,7 +41,7 @@ function animateVariant(visualElement, variant, options = {}) {
|
|
|
42
41
|
* If we have children, create a callback that runs all their animations.
|
|
43
42
|
* Otherwise, we resolve a Promise immediately for a composable no-op.
|
|
44
43
|
*/
|
|
45
|
-
const getChildAnimations =
|
|
44
|
+
const getChildAnimations = visualElement.variantChildren && visualElement.variantChildren.size
|
|
46
45
|
? (forwardDelay = 0) => {
|
|
47
46
|
const { delayChildren = 0, staggerChildren, staggerDirection, } = transition;
|
|
48
47
|
return animateChildren(visualElement, variant, delayChildren + forwardDelay, staggerChildren, staggerDirection, options);
|
|
@@ -67,13 +66,14 @@ function animateVariant(visualElement, variant, options = {}) {
|
|
|
67
66
|
* @internal
|
|
68
67
|
*/
|
|
69
68
|
function animateTarget(visualElement, definition, { delay = 0, transitionOverride, type } = {}) {
|
|
70
|
-
var _a;
|
|
71
69
|
let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = visualElement.makeTargetAnimatable(definition);
|
|
72
70
|
const willChange = visualElement.getValue("willChange");
|
|
73
71
|
if (transitionOverride)
|
|
74
72
|
transition = transitionOverride;
|
|
75
73
|
const animations = [];
|
|
76
|
-
const animationTypeState = type &&
|
|
74
|
+
const animationTypeState = type &&
|
|
75
|
+
visualElement.animationState &&
|
|
76
|
+
visualElement.animationState.getState()[type];
|
|
77
77
|
for (const key in target) {
|
|
78
78
|
const value = visualElement.getValue(key);
|
|
79
79
|
const valueTarget = target[key];
|
|
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
22
22
|
* and warn against mismatches.
|
|
23
23
|
*/
|
|
24
24
|
if (process.env.NODE_ENV === "development") {
|
|
25
|
-
warnOnce(nextValue.version === "9.0.
|
|
25
|
+
warnOnce(nextValue.version === "9.0.3", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.0.3 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
|
@@ -31,12 +31,13 @@ function setTarget(visualElement, definition) {
|
|
|
31
31
|
function setVariants(visualElement, variantLabels) {
|
|
32
32
|
const reversedLabels = [...variantLabels].reverse();
|
|
33
33
|
reversedLabels.forEach((key) => {
|
|
34
|
-
var _a;
|
|
35
34
|
const variant = visualElement.getVariant(key);
|
|
36
35
|
variant && setTarget(visualElement, variant);
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
if (visualElement.variantChildren) {
|
|
37
|
+
visualElement.variantChildren.forEach((child) => {
|
|
38
|
+
setVariants(child, variantLabels);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
function setValues(visualElement, definition) {
|
|
@@ -104,14 +105,18 @@ function getOriginFromTransition(key, transition) {
|
|
|
104
105
|
return valueTransition.from;
|
|
105
106
|
}
|
|
106
107
|
function getOrigin(target, transition, visualElement) {
|
|
107
|
-
var _a;
|
|
108
108
|
const origin = {};
|
|
109
109
|
for (const key in target) {
|
|
110
110
|
const transitionOrigin = getOriginFromTransition(key, transition);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
if (transitionOrigin !== undefined) {
|
|
112
|
+
origin[key] = transitionOrigin;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const value = visualElement.getValue(key);
|
|
116
|
+
if (value) {
|
|
117
|
+
origin[key] = value.get();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
115
120
|
}
|
|
116
121
|
return origin;
|
|
117
122
|
}
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -25,7 +25,7 @@ class MotionValue {
|
|
|
25
25
|
* This will be replaced by the build step with the latest version number.
|
|
26
26
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
27
27
|
*/
|
|
28
|
-
this.version = "9.0.
|
|
28
|
+
this.version = "9.0.3";
|
|
29
29
|
/**
|
|
30
30
|
* Duration, in milliseconds, since last updating frame.
|
|
31
31
|
*
|