framer-motion 11.17.0 → 11.18.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.
@@ -409,7 +409,7 @@ class MotionValue {
409
409
  * This will be replaced by the build step with the latest version number.
410
410
  * When MotionValues are provided to motion components, warn if versions are mixed.
411
411
  */
412
- this.version = "11.17.0";
412
+ this.version = "11.18.0";
413
413
  /**
414
414
  * Tracks whether this value can output a velocity. Currently this is only true
415
415
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -5201,7 +5201,7 @@ function updateMotionValuesFromProps(element, next, prev) {
5201
5201
  * and warn against mismatches.
5202
5202
  */
5203
5203
  if (process.env.NODE_ENV === "development") {
5204
- warnOnce(nextValue.version === "11.17.0", `Attempting to mix Motion versions ${nextValue.version} with 11.17.0 may not work as expected.`);
5204
+ warnOnce(nextValue.version === "11.18.0", `Attempting to mix Motion versions ${nextValue.version} with 11.18.0 may not work as expected.`);
5205
5205
  }
5206
5206
  }
5207
5207
  else if (isMotionValue(prevValue)) {
@@ -5334,7 +5334,8 @@ class VisualElement {
5334
5334
  frame.render(this.render, false, true);
5335
5335
  }
5336
5336
  };
5337
- const { latestValues, renderState } = visualState;
5337
+ const { latestValues, renderState, onUpdate } = visualState;
5338
+ this.onUpdate = onUpdate;
5338
5339
  this.latestValues = latestValues;
5339
5340
  this.baseTarget = { ...latestValues };
5340
5341
  this.initialValues = props.initial ? { ...latestValues } : {};
@@ -5534,6 +5535,7 @@ class VisualElement {
5534
5535
  if (this.handleChildMotionValue) {
5535
5536
  this.handleChildMotionValue();
5536
5537
  }
5538
+ this.onUpdate && this.onUpdate(this);
5537
5539
  }
5538
5540
  getProps() {
5539
5541
  return this.props;
@@ -8631,7 +8633,9 @@ const motionComponentSymbol = Symbol.for("motionComponentSymbol");
8631
8633
  */
8632
8634
  function useMotionRef(visualState, visualElement, externalRef) {
8633
8635
  return react.useCallback((instance) => {
8634
- instance && visualState.mount && visualState.mount(instance);
8636
+ if (instance) {
8637
+ visualState.onMount && visualState.onMount(instance);
8638
+ }
8635
8639
  if (visualElement) {
8636
8640
  if (instance) {
8637
8641
  visualElement.mount(instance);
@@ -8940,13 +8944,19 @@ function useConstant(init) {
8940
8944
  return ref.current;
8941
8945
  }
8942
8946
 
8943
- function makeState({ scrapeMotionValuesFromProps, createRenderState, onMount, }, props, context, presenceContext) {
8947
+ function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
8944
8948
  const state = {
8945
8949
  latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
8946
8950
  renderState: createRenderState(),
8947
8951
  };
8948
- if (onMount) {
8949
- state.mount = (instance) => onMount(props, instance, state);
8952
+ if (onUpdate) {
8953
+ /**
8954
+ * onMount works without the VisualElement because it could be
8955
+ * called before the VisualElement payload has been hydrated.
8956
+ * (e.g. if someone is using m components <m.circle />)
8957
+ */
8958
+ state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
8959
+ state.onUpdate = (visualElement) => onUpdate(visualElement);
8950
8960
  }
8951
8961
  return state;
8952
8962
  }
@@ -9024,32 +9034,62 @@ const createSvgRenderState = () => ({
9024
9034
  attrs: {},
9025
9035
  });
9026
9036
 
9037
+ function updateSVGDimensions(instance, renderState) {
9038
+ try {
9039
+ renderState.dimensions =
9040
+ typeof instance.getBBox === "function"
9041
+ ? instance.getBBox()
9042
+ : instance.getBoundingClientRect();
9043
+ }
9044
+ catch (e) {
9045
+ // Most likely trying to measure an unrendered element under Firefox
9046
+ renderState.dimensions = {
9047
+ x: 0,
9048
+ y: 0,
9049
+ width: 0,
9050
+ height: 0,
9051
+ };
9052
+ }
9053
+ }
9054
+ const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
9027
9055
  const svgMotionConfig = {
9028
9056
  useVisualState: makeUseVisualState({
9029
9057
  scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
9030
9058
  createRenderState: createSvgRenderState,
9031
- onMount: (props, instance, { renderState, latestValues }) => {
9032
- frame.read(() => {
9033
- try {
9034
- renderState.dimensions =
9035
- typeof instance.getBBox ===
9036
- "function"
9037
- ? instance.getBBox()
9038
- : instance.getBoundingClientRect();
9059
+ onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
9060
+ if (!current)
9061
+ return;
9062
+ let hasTransform = !!props.drag;
9063
+ if (!hasTransform) {
9064
+ for (const key in latestValues) {
9065
+ if (transformProps.has(key)) {
9066
+ hasTransform = true;
9067
+ break;
9068
+ }
9039
9069
  }
9040
- catch (e) {
9041
- // Most likely trying to measure an unrendered element under Firefox
9042
- renderState.dimensions = {
9043
- x: 0,
9044
- y: 0,
9045
- width: 0,
9046
- height: 0,
9047
- };
9070
+ }
9071
+ if (!hasTransform)
9072
+ return;
9073
+ let needsMeasure = !prevProps;
9074
+ if (prevProps) {
9075
+ /**
9076
+ * Check the layout props for changes, if any are found we need to
9077
+ * measure the element again.
9078
+ */
9079
+ for (let i = 0; i < layoutProps.length; i++) {
9080
+ const key = layoutProps[i];
9081
+ if (props[key] !==
9082
+ prevProps[key]) {
9083
+ needsMeasure = true;
9084
+ }
9048
9085
  }
9049
- });
9086
+ }
9087
+ if (!needsMeasure)
9088
+ return;
9089
+ frame.read(() => updateSVGDimensions(current, renderState));
9050
9090
  frame.render(() => {
9051
- buildSVGAttrs(renderState, latestValues, isSVGTag(instance.tagName), props.transformTemplate);
9052
- renderSVG(instance, renderState);
9091
+ buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
9092
+ renderSVG(current, renderState);
9053
9093
  });
9054
9094
  },
9055
9095
  }),
@@ -5,6 +5,399 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var motionDom = require('motion-dom');
6
6
  var motionUtils = require('motion-utils');
7
7
 
8
+ const wrap = (min, max, v) => {
9
+ const rangeSize = max - min;
10
+ return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
11
+ };
12
+
13
+ const isEasingArray = (ease) => {
14
+ return Array.isArray(ease) && typeof ease[0] !== "number";
15
+ };
16
+
17
+ function getEasingForSegment(easing, i) {
18
+ return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
19
+ }
20
+
21
+ /*
22
+ Value in range from progress
23
+
24
+ Given a lower limit and an upper limit, we return the value within
25
+ that range as expressed by progress (usually a number from 0 to 1)
26
+
27
+ So progress = 0.5 would change
28
+
29
+ from -------- to
30
+
31
+ to
32
+
33
+ from ---- to
34
+
35
+ E.g. from = 10, to = 20, progress = 0.5 => 15
36
+
37
+ @param [number]: Lower limit of range
38
+ @param [number]: Upper limit of range
39
+ @param [number]: The progress between lower and upper limits expressed 0-1
40
+ @return [number]: Value as calculated from progress within range (not limited within range)
41
+ */
42
+ const mixNumber = (from, to, progress) => {
43
+ return from + (to - from) * progress;
44
+ };
45
+
46
+ function fillOffset(offset, remaining) {
47
+ const min = offset[offset.length - 1];
48
+ for (let i = 1; i <= remaining; i++) {
49
+ const offsetProgress = motionUtils.progress(0, remaining, i);
50
+ offset.push(mixNumber(min, 1, offsetProgress));
51
+ }
52
+ }
53
+
54
+ function defaultOffset(arr) {
55
+ const offset = [0];
56
+ fillOffset(offset, arr.length - 1);
57
+ return offset;
58
+ }
59
+
60
+ const isMotionValue = (value) => Boolean(value && value.getVelocity);
61
+
62
+ function isDOMKeyframes(keyframes) {
63
+ return typeof keyframes === "object" && !Array.isArray(keyframes);
64
+ }
65
+
66
+ function resolveSubjects(subject, keyframes, scope, selectorCache) {
67
+ if (typeof subject === "string" && isDOMKeyframes(keyframes)) {
68
+ return motionDom.resolveElements(subject, scope, selectorCache);
69
+ }
70
+ else if (subject instanceof NodeList) {
71
+ return Array.from(subject);
72
+ }
73
+ else if (Array.isArray(subject)) {
74
+ return subject;
75
+ }
76
+ else {
77
+ return [subject];
78
+ }
79
+ }
80
+
81
+ function calculateRepeatDuration(duration, repeat, _repeatDelay) {
82
+ return duration * (repeat + 1);
83
+ }
84
+
85
+ /**
86
+ * Given a absolute or relative time definition and current/prev time state of the sequence,
87
+ * calculate an absolute time for the next keyframes.
88
+ */
89
+ function calcNextTime(current, next, prev, labels) {
90
+ var _a;
91
+ if (typeof next === "number") {
92
+ return next;
93
+ }
94
+ else if (next.startsWith("-") || next.startsWith("+")) {
95
+ return Math.max(0, current + parseFloat(next));
96
+ }
97
+ else if (next === "<") {
98
+ return prev;
99
+ }
100
+ else {
101
+ return (_a = labels.get(next)) !== null && _a !== void 0 ? _a : current;
102
+ }
103
+ }
104
+
105
+ function removeItem(arr, item) {
106
+ const index = arr.indexOf(item);
107
+ if (index > -1)
108
+ arr.splice(index, 1);
109
+ }
110
+
111
+ function eraseKeyframes(sequence, startTime, endTime) {
112
+ for (let i = 0; i < sequence.length; i++) {
113
+ const keyframe = sequence[i];
114
+ if (keyframe.at > startTime && keyframe.at < endTime) {
115
+ removeItem(sequence, keyframe);
116
+ // If we remove this item we have to push the pointer back one
117
+ i--;
118
+ }
119
+ }
120
+ }
121
+ function addKeyframes(sequence, keyframes, easing, offset, startTime, endTime) {
122
+ /**
123
+ * Erase every existing value between currentTime and targetTime,
124
+ * this will essentially splice this timeline into any currently
125
+ * defined ones.
126
+ */
127
+ eraseKeyframes(sequence, startTime, endTime);
128
+ for (let i = 0; i < keyframes.length; i++) {
129
+ sequence.push({
130
+ value: keyframes[i],
131
+ at: mixNumber(startTime, endTime, offset[i]),
132
+ easing: getEasingForSegment(easing, i),
133
+ });
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Take an array of times that represent repeated keyframes. For instance
139
+ * if we have original times of [0, 0.5, 1] then our repeated times will
140
+ * be [0, 0.5, 1, 1, 1.5, 2]. Loop over the times and scale them back
141
+ * down to a 0-1 scale.
142
+ */
143
+ function normalizeTimes(times, repeat) {
144
+ for (let i = 0; i < times.length; i++) {
145
+ times[i] = times[i] / (repeat + 1);
146
+ }
147
+ }
148
+
149
+ function compareByTime(a, b) {
150
+ if (a.at === b.at) {
151
+ if (a.value === null)
152
+ return 1;
153
+ if (b.value === null)
154
+ return -1;
155
+ return 0;
156
+ }
157
+ else {
158
+ return a.at - b.at;
159
+ }
160
+ }
161
+
162
+ const defaultSegmentEasing = "easeInOut";
163
+ const MAX_REPEAT = 20;
164
+ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...sequenceTransition } = {}, scope, generators) {
165
+ const defaultDuration = defaultTransition.duration || 0.3;
166
+ const animationDefinitions = new Map();
167
+ const sequences = new Map();
168
+ const elementCache = {};
169
+ const timeLabels = new Map();
170
+ let prevTime = 0;
171
+ let currentTime = 0;
172
+ let totalDuration = 0;
173
+ /**
174
+ * Build the timeline by mapping over the sequence array and converting
175
+ * the definitions into keyframes and offsets with absolute time values.
176
+ * These will later get converted into relative offsets in a second pass.
177
+ */
178
+ for (let i = 0; i < sequence.length; i++) {
179
+ const segment = sequence[i];
180
+ /**
181
+ * If this is a timeline label, mark it and skip the rest of this iteration.
182
+ */
183
+ if (typeof segment === "string") {
184
+ timeLabels.set(segment, currentTime);
185
+ continue;
186
+ }
187
+ else if (!Array.isArray(segment)) {
188
+ timeLabels.set(segment.name, calcNextTime(currentTime, segment.at, prevTime, timeLabels));
189
+ continue;
190
+ }
191
+ let [subject, keyframes, transition = {}] = segment;
192
+ /**
193
+ * If a relative or absolute time value has been specified we need to resolve
194
+ * it in relation to the currentTime.
195
+ */
196
+ if (transition.at !== undefined) {
197
+ currentTime = calcNextTime(currentTime, transition.at, prevTime, timeLabels);
198
+ }
199
+ /**
200
+ * Keep track of the maximum duration in this definition. This will be
201
+ * applied to currentTime once the definition has been parsed.
202
+ */
203
+ let maxDuration = 0;
204
+ const resolveValueSequence = (valueKeyframes, valueTransition, valueSequence, elementIndex = 0, numSubjects = 0) => {
205
+ const valueKeyframesAsList = keyframesAsList(valueKeyframes);
206
+ const { delay = 0, times = defaultOffset(valueKeyframesAsList), type = "keyframes", repeat, repeatType, repeatDelay = 0, ...remainingTransition } = valueTransition;
207
+ let { ease = defaultTransition.ease || "easeOut", duration } = valueTransition;
208
+ /**
209
+ * Resolve stagger() if defined.
210
+ */
211
+ const calculatedDelay = typeof delay === "function"
212
+ ? delay(elementIndex, numSubjects)
213
+ : delay;
214
+ /**
215
+ * If this animation should and can use a spring, generate a spring easing function.
216
+ */
217
+ const numKeyframes = valueKeyframesAsList.length;
218
+ const createGenerator = motionDom.isGenerator(type)
219
+ ? type
220
+ : generators === null || generators === void 0 ? void 0 : generators[type];
221
+ if (numKeyframes <= 2 && createGenerator) {
222
+ /**
223
+ * As we're creating an easing function from a spring,
224
+ * ideally we want to generate it using the real distance
225
+ * between the two keyframes. However this isn't always
226
+ * possible - in these situations we use 0-100.
227
+ */
228
+ let absoluteDelta = 100;
229
+ if (numKeyframes === 2 &&
230
+ isNumberKeyframesArray(valueKeyframesAsList)) {
231
+ const delta = valueKeyframesAsList[1] - valueKeyframesAsList[0];
232
+ absoluteDelta = Math.abs(delta);
233
+ }
234
+ const springTransition = { ...remainingTransition };
235
+ if (duration !== undefined) {
236
+ springTransition.duration = motionUtils.secondsToMilliseconds(duration);
237
+ }
238
+ const springEasing = motionDom.createGeneratorEasing(springTransition, absoluteDelta, createGenerator);
239
+ ease = springEasing.ease;
240
+ duration = springEasing.duration;
241
+ }
242
+ duration !== null && duration !== void 0 ? duration : (duration = defaultDuration);
243
+ const startTime = currentTime + calculatedDelay;
244
+ /**
245
+ * If there's only one time offset of 0, fill in a second with length 1
246
+ */
247
+ if (times.length === 1 && times[0] === 0) {
248
+ times[1] = 1;
249
+ }
250
+ /**
251
+ * Fill out if offset if fewer offsets than keyframes
252
+ */
253
+ const remainder = times.length - valueKeyframesAsList.length;
254
+ remainder > 0 && fillOffset(times, remainder);
255
+ /**
256
+ * If only one value has been set, ie [1], push a null to the start of
257
+ * the keyframe array. This will let us mark a keyframe at this point
258
+ * that will later be hydrated with the previous value.
259
+ */
260
+ valueKeyframesAsList.length === 1 &&
261
+ valueKeyframesAsList.unshift(null);
262
+ /**
263
+ * Handle repeat options
264
+ */
265
+ if (repeat) {
266
+ motionUtils.invariant(repeat < MAX_REPEAT, "Repeat count too high, must be less than 20");
267
+ duration = calculateRepeatDuration(duration, repeat);
268
+ const originalKeyframes = [...valueKeyframesAsList];
269
+ const originalTimes = [...times];
270
+ ease = Array.isArray(ease) ? [...ease] : [ease];
271
+ const originalEase = [...ease];
272
+ for (let repeatIndex = 0; repeatIndex < repeat; repeatIndex++) {
273
+ valueKeyframesAsList.push(...originalKeyframes);
274
+ for (let keyframeIndex = 0; keyframeIndex < originalKeyframes.length; keyframeIndex++) {
275
+ times.push(originalTimes[keyframeIndex] + (repeatIndex + 1));
276
+ ease.push(keyframeIndex === 0
277
+ ? "linear"
278
+ : getEasingForSegment(originalEase, keyframeIndex - 1));
279
+ }
280
+ }
281
+ normalizeTimes(times, repeat);
282
+ }
283
+ const targetTime = startTime + duration;
284
+ /**
285
+ * Add keyframes, mapping offsets to absolute time.
286
+ */
287
+ addKeyframes(valueSequence, valueKeyframesAsList, ease, times, startTime, targetTime);
288
+ maxDuration = Math.max(calculatedDelay + duration, maxDuration);
289
+ totalDuration = Math.max(targetTime, totalDuration);
290
+ };
291
+ if (isMotionValue(subject)) {
292
+ const subjectSequence = getSubjectSequence(subject, sequences);
293
+ resolveValueSequence(keyframes, transition, getValueSequence("default", subjectSequence));
294
+ }
295
+ else {
296
+ const subjects = resolveSubjects(subject, keyframes, scope, elementCache);
297
+ const numSubjects = subjects.length;
298
+ /**
299
+ * For every element in this segment, process the defined values.
300
+ */
301
+ for (let subjectIndex = 0; subjectIndex < numSubjects; subjectIndex++) {
302
+ /**
303
+ * Cast necessary, but we know these are of this type
304
+ */
305
+ keyframes = keyframes;
306
+ transition = transition;
307
+ const thisSubject = subjects[subjectIndex];
308
+ const subjectSequence = getSubjectSequence(thisSubject, sequences);
309
+ for (const key in keyframes) {
310
+ resolveValueSequence(keyframes[key], getValueTransition(transition, key), getValueSequence(key, subjectSequence), subjectIndex, numSubjects);
311
+ }
312
+ }
313
+ }
314
+ prevTime = currentTime;
315
+ currentTime += maxDuration;
316
+ }
317
+ /**
318
+ * For every element and value combination create a new animation.
319
+ */
320
+ sequences.forEach((valueSequences, element) => {
321
+ for (const key in valueSequences) {
322
+ const valueSequence = valueSequences[key];
323
+ /**
324
+ * Arrange all the keyframes in ascending time order.
325
+ */
326
+ valueSequence.sort(compareByTime);
327
+ const keyframes = [];
328
+ const valueOffset = [];
329
+ const valueEasing = [];
330
+ /**
331
+ * For each keyframe, translate absolute times into
332
+ * relative offsets based on the total duration of the timeline.
333
+ */
334
+ for (let i = 0; i < valueSequence.length; i++) {
335
+ const { at, value, easing } = valueSequence[i];
336
+ keyframes.push(value);
337
+ valueOffset.push(motionUtils.progress(0, totalDuration, at));
338
+ valueEasing.push(easing || "easeOut");
339
+ }
340
+ /**
341
+ * If the first keyframe doesn't land on offset: 0
342
+ * provide one by duplicating the initial keyframe. This ensures
343
+ * it snaps to the first keyframe when the animation starts.
344
+ */
345
+ if (valueOffset[0] !== 0) {
346
+ valueOffset.unshift(0);
347
+ keyframes.unshift(keyframes[0]);
348
+ valueEasing.unshift(defaultSegmentEasing);
349
+ }
350
+ /**
351
+ * If the last keyframe doesn't land on offset: 1
352
+ * provide one with a null wildcard value. This will ensure it
353
+ * stays static until the end of the animation.
354
+ */
355
+ if (valueOffset[valueOffset.length - 1] !== 1) {
356
+ valueOffset.push(1);
357
+ keyframes.push(null);
358
+ }
359
+ if (!animationDefinitions.has(element)) {
360
+ animationDefinitions.set(element, {
361
+ keyframes: {},
362
+ transition: {},
363
+ });
364
+ }
365
+ const definition = animationDefinitions.get(element);
366
+ definition.keyframes[key] = keyframes;
367
+ definition.transition[key] = {
368
+ ...defaultTransition,
369
+ duration: totalDuration,
370
+ ease: valueEasing,
371
+ times: valueOffset,
372
+ ...sequenceTransition,
373
+ };
374
+ }
375
+ });
376
+ return animationDefinitions;
377
+ }
378
+ function getSubjectSequence(subject, sequences) {
379
+ !sequences.has(subject) && sequences.set(subject, {});
380
+ return sequences.get(subject);
381
+ }
382
+ function getValueSequence(name, sequences) {
383
+ if (!sequences[name])
384
+ sequences[name] = [];
385
+ return sequences[name];
386
+ }
387
+ function keyframesAsList(keyframes) {
388
+ return Array.isArray(keyframes) ? keyframes : [keyframes];
389
+ }
390
+ function getValueTransition(transition, key) {
391
+ return transition && transition[key]
392
+ ? {
393
+ ...transition,
394
+ ...transition[key],
395
+ }
396
+ : { ...transition };
397
+ }
398
+ const isNumber = (keyframe) => typeof keyframe === "number";
399
+ const isNumberKeyframesArray = (keyframes) => keyframes.every(isNumber);
400
+
8
401
  function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
9
402
  const keyframeOptions = { [valueName]: keyframes };
10
403
  if (times)
@@ -228,6 +621,14 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
228
621
  return animations;
229
622
  }
230
623
 
624
+ function animateSequence(definition, options) {
625
+ const animations = [];
626
+ createAnimationsFromSequence(definition, options).forEach(({ keyframes, transition }, element) => {
627
+ animations.push(...animateElements(element, keyframes, transition));
628
+ });
629
+ return new motionDom.GroupPlaybackControls(animations);
630
+ }
631
+
231
632
  const createScopedWaapiAnimate = (scope) => {
232
633
  function scopedAnimate(elementOrSelector, keyframes, options) {
233
634
  return new motionDom.GroupPlaybackControls(animateElements(elementOrSelector, keyframes, options, scope));
@@ -237,3 +638,4 @@ const createScopedWaapiAnimate = (scope) => {
237
638
  const animateMini = /*@__PURE__*/ createScopedWaapiAnimate();
238
639
 
239
640
  exports.animate = animateMini;
641
+ exports.animateSequence = animateSequence;
package/dist/cjs/dom.js CHANGED
@@ -994,7 +994,7 @@ class MotionValue {
994
994
  * This will be replaced by the build step with the latest version number.
995
995
  * When MotionValues are provided to motion components, warn if versions are mixed.
996
996
  */
997
- this.version = "11.17.0";
997
+ this.version = "11.18.0";
998
998
  /**
999
999
  * Tracks whether this value can output a velocity. Currently this is only true
1000
1000
  * if the value is numerical, but we might be able to widen the scope here and support
@@ -3924,7 +3924,7 @@ function updateMotionValuesFromProps(element, next, prev) {
3924
3924
  * and warn against mismatches.
3925
3925
  */
3926
3926
  if (process.env.NODE_ENV === "development") {
3927
- warnOnce(nextValue.version === "11.17.0", `Attempting to mix Motion versions ${nextValue.version} with 11.17.0 may not work as expected.`);
3927
+ warnOnce(nextValue.version === "11.18.0", `Attempting to mix Motion versions ${nextValue.version} with 11.18.0 may not work as expected.`);
3928
3928
  }
3929
3929
  }
3930
3930
  else if (isMotionValue(prevValue)) {
@@ -4057,7 +4057,8 @@ class VisualElement {
4057
4057
  frame.render(this.render, false, true);
4058
4058
  }
4059
4059
  };
4060
- const { latestValues, renderState } = visualState;
4060
+ const { latestValues, renderState, onUpdate } = visualState;
4061
+ this.onUpdate = onUpdate;
4061
4062
  this.latestValues = latestValues;
4062
4063
  this.baseTarget = { ...latestValues };
4063
4064
  this.initialValues = props.initial ? { ...latestValues } : {};
@@ -4257,6 +4258,7 @@ class VisualElement {
4257
4258
  if (this.handleChildMotionValue) {
4258
4259
  this.handleChildMotionValue();
4259
4260
  }
4261
+ this.onUpdate && this.onUpdate(this);
4260
4262
  }
4261
4263
  getProps() {
4262
4264
  return this.props;