motion-on-native 1.2.4 → 1.2.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/lib/index.js +10 -10
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -261,7 +261,7 @@ function createMotionComponent(Component) {
|
|
|
261
261
|
// Animate to target values
|
|
262
262
|
const timer = setTimeout(() => {
|
|
263
263
|
if (!isExitingRef.current) {
|
|
264
|
-
animateToValues(
|
|
264
|
+
animateToValues(memoizedAnimate);
|
|
265
265
|
setHasAnimated(true);
|
|
266
266
|
}
|
|
267
267
|
}, 16);
|
|
@@ -269,20 +269,20 @@ function createMotionComponent(Component) {
|
|
|
269
269
|
}
|
|
270
270
|
return undefined;
|
|
271
271
|
}, []);
|
|
272
|
+
// Memoize animate prop to prevent unnecessary re-animations
|
|
273
|
+
const memoizedAnimate = (0, react_1.useMemo)(() => animate, [JSON.stringify(animate)]);
|
|
272
274
|
// Handle animate prop changes (only animate if values actually changed)
|
|
273
|
-
const prevAnimateRef = (0, react_1.useRef)(
|
|
274
|
-
const animateStringRef = (0, react_1.useRef)(JSON.stringify(animate));
|
|
275
|
+
const prevAnimateRef = (0, react_1.useRef)(memoizedAnimate);
|
|
275
276
|
(0, react_1.useEffect)(() => {
|
|
276
277
|
if (hasAnimated && !isExitingRef.current) {
|
|
277
278
|
// Only animate if animate prop actually changed
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
280
|
-
animateToValues(
|
|
281
|
-
prevAnimateRef.current =
|
|
282
|
-
animateStringRef.current = currentAnimateString;
|
|
279
|
+
const hasChanged = JSON.stringify(prevAnimateRef.current) !== JSON.stringify(memoizedAnimate);
|
|
280
|
+
if (hasChanged) {
|
|
281
|
+
animateToValues(memoizedAnimate);
|
|
282
|
+
prevAnimateRef.current = memoizedAnimate;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
}, [
|
|
285
|
+
}, [memoizedAnimate]);
|
|
286
286
|
// Handle shouldExit
|
|
287
287
|
(0, react_1.useEffect)(() => {
|
|
288
288
|
var _a;
|
|
@@ -322,7 +322,7 @@ function createMotionComponent(Component) {
|
|
|
322
322
|
// Animate to target after a frame
|
|
323
323
|
setTimeout(() => {
|
|
324
324
|
if (!isExitingRef.current) {
|
|
325
|
-
animateToValues(
|
|
325
|
+
animateToValues(memoizedAnimate);
|
|
326
326
|
setHasAnimated(true);
|
|
327
327
|
}
|
|
328
328
|
}, 16);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motion-on-native",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Framer Motion-inspired animation library for React Native with Reanimated. Easy spring animations, gestures, and transitions for mobile apps.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|