framer-motion 10.12.18 → 10.12.21

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/index.d.ts CHANGED
@@ -1180,6 +1180,9 @@ declare type VariableTransitions = {
1180
1180
  [key: `--${string}`]: Transition;
1181
1181
  };
1182
1182
  declare type AnimationOptionsWithValueOverrides<V = any> = StyleTransitions & SVGPathTransitions & SVGTransitions & VariableTransitions & ValueAnimationTransition<V>;
1183
+ interface DynamicAnimationOptions extends Omit<AnimationOptionsWithValueOverrides, "delay"> {
1184
+ delay?: number | DynamicOption<number>;
1185
+ }
1183
1186
  declare type ElementOrSelector = Element | Element[] | NodeListOf<Element> | string;
1184
1187
  /**
1185
1188
  * @public
@@ -2189,7 +2192,7 @@ declare abstract class VisualElement<Instance = unknown, RenderState = unknown,
2189
2192
  * we need to check for it in our state and as a last resort read it
2190
2193
  * directly from the instance (which might have performance implications).
2191
2194
  */
2192
- readValue(key: string): string | number | null | undefined;
2195
+ readValue(key: string): string | number | MotionValue<any> | null | undefined;
2193
2196
  /**
2194
2197
  * Set the base target to later animate back to. This is currently
2195
2198
  * only hydrated on creation and when we first read a value.
@@ -4007,10 +4010,25 @@ interface SequenceOptions extends AnimationPlaybackOptions {
4007
4010
  duration?: number;
4008
4011
  defaultTransition?: Transition;
4009
4012
  }
4010
-
4011
- interface DynamicAnimationOptions extends Omit<AnimationOptionsWithValueOverrides, "delay"> {
4012
- delay?: number | DynamicOption<number>;
4013
+ interface AbsoluteKeyframe {
4014
+ value: string | number | null;
4015
+ at: number;
4016
+ easing?: Easing;
4013
4017
  }
4018
+ declare type ValueSequence = AbsoluteKeyframe[];
4019
+ interface SequenceMap {
4020
+ [key: string]: ValueSequence;
4021
+ }
4022
+ declare type ResolvedAnimationDefinition = {
4023
+ keyframes: {
4024
+ [key: string]: UnresolvedValueKeyframe[];
4025
+ };
4026
+ transition: {
4027
+ [key: string]: Transition;
4028
+ };
4029
+ };
4030
+ declare type ResolvedAnimationDefinitions = Map<Element | MotionValue, ResolvedAnimationDefinition>;
4031
+
4014
4032
  declare const createScopedAnimate: (scope?: AnimationScope) => {
4015
4033
  <V>(from: V, to: V | GenericKeyframesTarget<V>, options?: ValueAnimationTransition<V> | undefined): AnimationPlaybackControls;
4016
4034
  <V_1>(value: MotionValue<V_1>, keyframes: V_1 | GenericKeyframesTarget<V_1>, options?: ValueAnimationTransition<V_1> | undefined): AnimationPlaybackControls;
@@ -4273,7 +4291,7 @@ interface MotionContextProps<Instance = unknown> {
4273
4291
  }
4274
4292
  declare const MotionContext: React$1.Context<MotionContextProps<unknown>>;
4275
4293
 
4276
- declare function checkTargetForNewValues(visualElement: VisualElement, target: TargetWithKeyframes, origin: ResolvedValues): void;
4294
+ declare function checkTargetForNewValues(visualElement: VisualElement, target: TargetWithKeyframes, origin: ResolvedValues): boolean;
4277
4295
 
4278
4296
  declare const createBox: () => Box;
4279
4297
 
@@ -4912,4 +4930,4 @@ declare function useInvertedScale(scale?: Partial<ScaleMotionValues>): ScaleMoti
4912
4930
 
4913
4931
  declare const AnimateSharedLayout: React$1.FunctionComponent<React$1.PropsWithChildren<unknown>>;
4914
4932
 
4915
- export { AnimatePresence, AnimatePresenceProps, AnimateSharedLayout, AnimationControls, AnimationDefinition, AnimationLifecycles, AnimationOptionsWithValueOverrides, AnimationPlaybackControls, AnimationPlaybackLifecycles, AnimationPlaybackOptions, AnimationProps, AnimationScope, AnimationType, Axis, AxisDelta, BezierDefinition, BoundingBox, Box, CSSStyleDeclarationWithTransform, CreateVisualElement, CustomDomComponent, CustomValueType, Cycle, CycleState, DOMKeyframesDefinition, DecayOptions, DelayedFunction, Delta, DeprecatedLayoutGroupContext, DevMessage, DragControls, DragElastic, DragHandlers, DraggableProps, DurationSpringOptions, DynamicOption, Easing, EasingDefinition, EasingFunction, EasingModifier, ElementOrSelector, EventInfo, FeatureBundle, FeatureDefinition, FeatureDefinitions, FeaturePackage, FeaturePackages, FlatTree, FocusHandlers, ForwardRefComponent, HTMLMotionProps, HoverHandlers, HydratedFeatureDefinition, HydratedFeatureDefinitions, IProjectionNode, Inertia, InertiaOptions$1 as InertiaOptions, InterpolateOptions, KeyframeOptions, Keyframes, KeyframesTarget, LayoutGroup, LayoutGroupContext, LayoutProps, LazyFeatureBundle$1 as LazyFeatureBundle, LazyMotion, LazyProps, MixerFactory, MotionAdvancedProps, MotionConfig, MotionConfigContext, MotionConfigProps, MotionContext, MotionProps, MotionStyle, MotionTransform, MotionValue, None, Orchestration, PanHandlers, PanInfo, PassiveEffect, Point, PresenceContext, RelayoutInfo, RenderComponent, Reorder, Repeat, ResolveLayoutTransition, ResolvedKeyframesTarget, ResolvedSingleTarget, ResolvedValueTarget, ResolvedValues, SVGAttributesAsMotionValues, SVGKeyframesDefinition, SVGMotionProps, SVGPathKeyframesDefinition, SVGPathTransitions, SVGTransitions, ScrapeMotionValuesFromProps, ScrollMotionValues, SingleTarget, Spring, SpringOptions, StyleKeyframesDefinition, StyleTransitions, Subscriber, SwitchLayoutGroupContext, TapHandlers, TapInfo, Target, TargetAndTransition, TransformPoint, Transition$1 as Transition, Tween, UnresolvedValueKeyframe, ValueAnimationOptions, ValueAnimationTransition, ValueKeyframe, ValueKeyframesDefinition, ValueTarget, ValueType, VariableKeyframesDefinition, VariableTransitions, Variant, VariantLabels, Variants, VelocityOptions, VisualElement, VisualState, addPointerEvent, addPointerInfo, addScaleCorrector, animate, animateValue, animateVisualElement, animationControls, animations, anticipate, backIn, backInOut, backOut, buildTransform, calcLength, cancelFrame, cancelSync, checkTargetForNewValues, circIn, circInOut, circOut, clamp, color, complex, createBox, createDomMotionComponent, createMotionComponent, createScopedAnimate, cubicBezier, delay, distance, distance2D, domAnimation, domMax, easeIn, easeInOut, easeOut, filterProps, frame, frameData, inView, interpolate, invariant, isBrowser, isDragActive, isMotionComponent, isMotionValue, isValidMotionProp, m, makeUseVisualState, mirrorEasing, mix, motion, motionValue, optimizedAppearDataAttribute, pipe, progress, px, resolveMotionValue, reverseEasing, scroll, spring, stagger, startOptimizedAppearAnimation, steps, stepsOrder, sync, transform, unwrapMotionComponent, useAnimate, useAnimation, useAnimationControls, useAnimationFrame, useCycle, useAnimatedState as useDeprecatedAnimatedState, useInvertedScale as useDeprecatedInvertedScale, useDomEvent, useDragControls, useElementScroll, useForceUpdate, useInView, useInstantLayoutTransition, useInstantTransition, useIsPresent, useIsomorphicLayoutEffect, useMotionTemplate, useMotionValue, useMotionValueEvent, usePresence, useReducedMotion, useReducedMotionConfig, useResetProjection, useScroll, useSpring, useTime, useTransform, useUnmountEffect, useVelocity, useViewportScroll, useWillChange, visualElementStore, warning, wrap };
4933
+ export { AbsoluteKeyframe, AnimatePresence, AnimatePresenceProps, AnimateSharedLayout, AnimationControls, AnimationDefinition, AnimationLifecycles, AnimationOptionsWithValueOverrides, AnimationPlaybackControls, AnimationPlaybackLifecycles, AnimationPlaybackOptions, AnimationProps, AnimationScope, AnimationSequence, AnimationType, At, Axis, AxisDelta, BezierDefinition, BoundingBox, Box, CSSStyleDeclarationWithTransform, CreateVisualElement, CustomDomComponent, CustomValueType, Cycle, CycleState, DOMKeyframesDefinition, DOMSegment, DOMSegmentWithTransition, DecayOptions, DelayedFunction, Delta, DeprecatedLayoutGroupContext, DevMessage, DragControls, DragElastic, DragHandlers, DraggableProps, DurationSpringOptions, DynamicAnimationOptions, DynamicOption, Easing, EasingDefinition, EasingFunction, EasingModifier, ElementOrSelector, EventInfo, FeatureBundle, FeatureDefinition, FeatureDefinitions, FeaturePackage, FeaturePackages, FlatTree, FocusHandlers, ForwardRefComponent, HTMLMotionProps, HoverHandlers, HydratedFeatureDefinition, HydratedFeatureDefinitions, IProjectionNode, Inertia, InertiaOptions$1 as InertiaOptions, InterpolateOptions, KeyframeOptions, Keyframes, KeyframesTarget, LayoutGroup, LayoutGroupContext, LayoutProps, LazyFeatureBundle$1 as LazyFeatureBundle, LazyMotion, LazyProps, MixerFactory, MotionAdvancedProps, MotionConfig, MotionConfigContext, MotionConfigProps, MotionContext, MotionProps, MotionStyle, MotionTransform, MotionValue, MotionValueSegment, MotionValueSegmentWithTransition, None, Orchestration, PanHandlers, PanInfo, PassiveEffect, Point, PresenceContext, RelayoutInfo, RenderComponent, Reorder, Repeat, ResolveLayoutTransition, ResolvedAnimationDefinition, ResolvedAnimationDefinitions, ResolvedKeyframesTarget, ResolvedSingleTarget, ResolvedValueTarget, ResolvedValues, SVGAttributesAsMotionValues, SVGKeyframesDefinition, SVGMotionProps, SVGPathKeyframesDefinition, SVGPathTransitions, SVGTransitions, ScrapeMotionValuesFromProps, ScrollMotionValues, Segment, SequenceLabel, SequenceLabelWithTime, SequenceMap, SequenceOptions, SequenceTime, SingleTarget, Spring, SpringOptions, StyleKeyframesDefinition, StyleTransitions, Subscriber, SwitchLayoutGroupContext, TapHandlers, TapInfo, Target, TargetAndTransition, TransformPoint, Transition$1 as Transition, Tween, UnresolvedValueKeyframe, ValueAnimationOptions, ValueAnimationTransition, ValueKeyframe, ValueKeyframesDefinition, ValueSequence, ValueTarget, ValueType, VariableKeyframesDefinition, VariableTransitions, Variant, VariantLabels, Variants, VelocityOptions, VisualElement, VisualState, addPointerEvent, addPointerInfo, addScaleCorrector, animate, animateValue, animateVisualElement, animationControls, animations, anticipate, backIn, backInOut, backOut, buildTransform, calcLength, cancelFrame, cancelSync, checkTargetForNewValues, circIn, circInOut, circOut, clamp, color, complex, createBox, createDomMotionComponent, createMotionComponent, createScopedAnimate, cubicBezier, delay, distance, distance2D, domAnimation, domMax, easeIn, easeInOut, easeOut, filterProps, frame, frameData, inView, interpolate, invariant, isBrowser, isDragActive, isMotionComponent, isMotionValue, isValidMotionProp, m, makeUseVisualState, mirrorEasing, mix, motion, motionValue, optimizedAppearDataAttribute, pipe, progress, px, resolveMotionValue, reverseEasing, scroll, spring, stagger, startOptimizedAppearAnimation, steps, stepsOrder, sync, transform, unwrapMotionComponent, useAnimate, useAnimation, useAnimationControls, useAnimationFrame, useCycle, useAnimatedState as useDeprecatedAnimatedState, useInvertedScale as useDeprecatedInvertedScale, useDomEvent, useDragControls, useElementScroll, useForceUpdate, useInView, useInstantLayoutTransition, useInstantTransition, useIsPresent, useIsomorphicLayoutEffect, useMotionTemplate, useMotionValue, useMotionValueEvent, usePresence, useReducedMotion, useReducedMotionConfig, useResetProjection, useScroll, useSpring, useTime, useTransform, useUnmountEffect, useVelocity, useViewportScroll, useWillChange, visualElementStore, warning, wrap };
@@ -938,7 +938,7 @@
938
938
  * This will be replaced by the build step with the latest version number.
939
939
  * When MotionValues are provided to motion components, warn if versions are mixed.
940
940
  */
941
- this.version = "10.12.18";
941
+ this.version = "10.12.21";
942
942
  /**
943
943
  * Duration, in milliseconds, since last updating frame.
944
944
  *
@@ -2307,12 +2307,10 @@
2307
2307
  let resolveFinishedPromise;
2308
2308
  let currentFinishedPromise;
2309
2309
  /**
2310
- * Create a new finished Promise every time we enter the
2311
- * finished state and resolve the old Promise. This is
2312
- * WAAPI-compatible behaviour.
2310
+ * Resolve the current Promise every time we enter the
2311
+ * finished state. This is WAAPI-compatible behaviour.
2313
2312
  */
2314
2313
  const updateFinishedPromise = () => {
2315
- resolveFinishedPromise && resolveFinishedPromise();
2316
2314
  currentFinishedPromise = new Promise((resolve) => {
2317
2315
  resolveFinishedPromise = resolve;
2318
2316
  });
@@ -2480,6 +2478,7 @@
2480
2478
  const cancel = () => {
2481
2479
  playState = "idle";
2482
2480
  stopAnimationDriver();
2481
+ resolveFinishedPromise();
2483
2482
  updateFinishedPromise();
2484
2483
  startTime = cancelTime = null;
2485
2484
  };
@@ -2487,7 +2486,7 @@
2487
2486
  playState = "finished";
2488
2487
  onComplete && onComplete();
2489
2488
  stopAnimationDriver();
2490
- updateFinishedPromise();
2489
+ resolveFinishedPromise();
2491
2490
  };
2492
2491
  const play = () => {
2493
2492
  if (hasStopped)
@@ -2502,6 +2501,9 @@
2502
2501
  else if (!startTime || playState === "finished") {
2503
2502
  startTime = now;
2504
2503
  }
2504
+ if (playState === "finished") {
2505
+ updateFinishedPromise();
2506
+ }
2505
2507
  cancelTime = startTime;
2506
2508
  holdTime = null;
2507
2509
  /**
@@ -2618,9 +2620,8 @@
2618
2620
  let resolveFinishedPromise;
2619
2621
  let currentFinishedPromise;
2620
2622
  /**
2621
- * Create a new finished Promise every time we enter the
2622
- * finished state and resolve the old Promise. This is
2623
- * WAAPI-compatible behaviour.
2623
+ * Resolve the current Promise every time we enter the
2624
+ * finished state. This is WAAPI-compatible behaviour.
2624
2625
  */
2625
2626
  const updateFinishedPromise = () => {
2626
2627
  currentFinishedPromise = new Promise((resolve) => {
@@ -3196,7 +3197,7 @@
3196
3197
  const newValueKeys = Object.keys(target).filter((key) => !visualElement.hasValue(key));
3197
3198
  const numNewValues = newValueKeys.length;
3198
3199
  if (!numNewValues)
3199
- return;
3200
+ return false;
3200
3201
  for (let i = 0; i < numNewValues; i++) {
3201
3202
  const key = newValueKeys[i];
3202
3203
  const targetValue = target[key];
@@ -3237,6 +3238,7 @@
3237
3238
  if (value !== null)
3238
3239
  visualElement.setBaseTarget(key, value);
3239
3240
  }
3241
+ return true;
3240
3242
  }
3241
3243
  function getOriginFromTransition(key, transition) {
3242
3244
  if (!transition)
@@ -3433,6 +3435,9 @@
3433
3435
  x: getTranslateFromMatrix(4, 13),
3434
3436
  y: getTranslateFromMatrix(5, 14),
3435
3437
  };
3438
+ // Alias translate longform names
3439
+ positionalValues.translateX = positionalValues.x;
3440
+ positionalValues.translateY = positionalValues.y;
3436
3441
  const convertChangedValueTypes = (target, visualElement, changedKeys) => {
3437
3442
  const originBbox = visualElement.measureViewportBox();
3438
3443
  const element = visualElement.current;
@@ -3672,7 +3677,7 @@
3672
3677
  * and warn against mismatches.
3673
3678
  */
3674
3679
  {
3675
- warnOnce(nextValue.version === "10.12.18", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.18 may not work as expected.`);
3680
+ warnOnce(nextValue.version === "10.12.21", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.21 may not work as expected.`);
3676
3681
  }
3677
3682
  }
3678
3683
  else if (isMotionValue(prevValue)) {
@@ -4165,9 +4170,10 @@
4165
4170
  * directly from the instance (which might have performance implications).
4166
4171
  */
4167
4172
  readValue(key) {
4173
+ var _a;
4168
4174
  return this.latestValues[key] !== undefined || !this.current
4169
4175
  ? this.latestValues[key]
4170
- : this.readValueFromInstance(this.current, key, this.options);
4176
+ : (_a = this.getBaseTargetFromProps(this.props, key)) !== null && _a !== void 0 ? _a : this.readValueFromInstance(this.current, key, this.options);
4171
4177
  }
4172
4178
  /**
4173
4179
  * Set the base target to later animate back to. This is currently
@@ -4251,7 +4257,11 @@
4251
4257
  origin = transformValues(origin);
4252
4258
  }
4253
4259
  if (isMounted) {
4254
- checkTargetForNewValues(this, target, origin);
4260
+ const newValues = checkTargetForNewValues(this, target, origin);
4261
+ // If new values have been added, for instance named color values, transform these
4262
+ if (transformValues && newValues) {
4263
+ origin = transformValues(origin);
4264
+ }
4255
4265
  const parsed = parseDomVariant(this, target, origin, transitionEnd);
4256
4266
  transitionEnd = parsed.transitionEnd;
4257
4267
  target = parsed.target;
@@ -1822,7 +1822,7 @@ declare abstract class VisualElement<Instance = unknown, RenderState = unknown,
1822
1822
  * we need to check for it in our state and as a last resort read it
1823
1823
  * directly from the instance (which might have performance implications).
1824
1824
  */
1825
- readValue(key: string): string | number | null | undefined;
1825
+ readValue(key: string): string | number | MotionValue<any> | null | undefined;
1826
1826
  /**
1827
1827
  * Set the base target to later animate back to. This is currently
1828
1828
  * only hydrated on creation and when we first read a value.
@@ -2865,7 +2865,7 @@ interface MotionContextProps<Instance = unknown> {
2865
2865
  }
2866
2866
  declare const MotionContext: react.Context<MotionContextProps<unknown>>;
2867
2867
 
2868
- declare function checkTargetForNewValues(visualElement: VisualElement, target: TargetWithKeyframes, origin: ResolvedValues): void;
2868
+ declare function checkTargetForNewValues(visualElement: VisualElement, target: TargetWithKeyframes, origin: ResolvedValues): boolean;
2869
2869
 
2870
2870
  declare const createBox: () => Box;
2871
2871
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framer-motion",
3
- "version": "10.12.18",
3
+ "version": "10.12.21",
4
4
  "description": "A simple and powerful React and JavaScript animation library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.mjs",
@@ -53,7 +53,7 @@
53
53
  "test-projection": "yarn run collect-projection-tests && start-server-and-test 'pushd ../../; python -m SimpleHTTPServer; popd' http://0.0.0.0:8000 'cypress run -s cypress/integration/projection.chrome.ts --config baseUrl=http://localhost:8000/'",
54
54
  "test-e2e-chrome": "start-server-and-test start-dev-server http://localhost:9990 'cypress run --headless --browser chrome --spec \"cypress/integration/layout-relative.chrome.ts\"'",
55
55
  "test-e2e-electron": "start-server-and-test start-dev-server http://localhost:9990 'cypress run --headless --config ignoreTestFiles=*.chrome.ts'",
56
- "test-e2e": "yarn test-appear && yarn test-projection",
56
+ "test-e2e": "yarn test-appear && yarn test-projection && yarn test-e2e-electron",
57
57
  "test-e2e-file": "start-server-and-test start-dev-server http://localhost:9990 'cypress run --headless --spec \"cypress/integration/while-in-view.ts\"'",
58
58
  "collect-appear-tests": "node ../../dev/optimized-appear/collect-appear-tests.js",
59
59
  "collect-projection-tests": "node ../../dev/projection/collect-projection-tests.js",
@@ -93,15 +93,15 @@
93
93
  },
94
94
  {
95
95
  "path": "./dist/size-rollup-dom-animation.js",
96
- "maxSize": "15.34 kB"
96
+ "maxSize": "15.36 kB"
97
97
  },
98
98
  {
99
99
  "path": "./dist/size-rollup-dom-max.js",
100
- "maxSize": "26.36 kB"
100
+ "maxSize": "26.38 kB"
101
101
  },
102
102
  {
103
103
  "path": "./dist/size-rollup-animate.js",
104
- "maxSize": "16.08 kB"
104
+ "maxSize": "16.1 kB"
105
105
  },
106
106
  {
107
107
  "path": "./dist/size-webpack-m.js",
@@ -109,12 +109,12 @@
109
109
  },
110
110
  {
111
111
  "path": "./dist/size-webpack-dom-animation.js",
112
- "maxSize": "19.37 kB"
112
+ "maxSize": "19.39 kB"
113
113
  },
114
114
  {
115
115
  "path": "./dist/size-webpack-dom-max.js",
116
- "maxSize": "31.14 kB"
116
+ "maxSize": "31.16 kB"
117
117
  }
118
118
  ],
119
- "gitHead": "f4d78094383ec0dfe17c02f1845d1d8f9aee902e"
119
+ "gitHead": "86b73dc837473d5645e580985753537849761cc1"
120
120
  }