motion-on-native 1.1.4 → 1.2.1

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.
Files changed (2) hide show
  1. package/lib/index.js +26 -30
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -130,50 +130,46 @@ function createMotionComponent(Component) {
130
130
  // Animation helper
131
131
  const animateToValues = (targetValues, transitionConfig = transition) => {
132
132
  Object.entries(targetValues).forEach(([key, value]) => {
133
- var _a;
133
+ var _a, _b, _c, _d, _e, _f, _g, _h;
134
134
  if (value !== undefined) {
135
135
  const sharedValue = getSharedValue(key);
136
136
  if (sharedValue) {
137
- const animateWithRepeat = (currentValue, targetValue, repeatCount) => {
138
- var _a, _b, _c, _d, _e;
139
- const config = transitionConfig.type === 'spring'
140
- ? (0, react_native_reanimated_1.withSpring)(targetValue, {
137
+ let config;
138
+ if (transitionConfig.repeat && transitionConfig.repeat > 0) {
139
+ // Use withRepeat for repeated animations
140
+ const baseAnimation = transitionConfig.type === 'spring'
141
+ ? (0, react_native_reanimated_1.withSpring)(value, {
141
142
  damping: (_a = transitionConfig.damping) !== null && _a !== void 0 ? _a : DEFAULT_TRANSITION.damping,
142
143
  stiffness: (_b = transitionConfig.stiffness) !== null && _b !== void 0 ? _b : DEFAULT_TRANSITION.stiffness,
143
144
  mass: (_c = transitionConfig.mass) !== null && _c !== void 0 ? _c : 1,
144
145
  })
145
- : (0, react_native_reanimated_1.withTiming)(targetValue, {
146
+ : (0, react_native_reanimated_1.withTiming)(value, {
146
147
  duration: (_d = transitionConfig.duration) !== null && _d !== void 0 ? _d : DEFAULT_TRANSITION.duration,
148
+ easing: react_native_reanimated_1.Easing.linear,
147
149
  });
148
- sharedValue.value = config;
149
- // Handle repeat
150
- if (transitionConfig.repeat && repeatCount > 0) {
151
- const duration = (_e = transitionConfig.duration) !== null && _e !== void 0 ? _e : DEFAULT_TRANSITION.duration;
152
- setTimeout(() => {
153
- const nextTarget = transitionConfig.repeatType === 'reverse'
154
- ? (sharedValue.value === targetValue ? currentValue : targetValue)
155
- : targetValue;
156
- const nextCurrent = transitionConfig.repeatType === 'reverse'
157
- ? (sharedValue.value === targetValue ? targetValue : currentValue)
158
- : currentValue;
159
- if (transitionConfig.repeat === 'infinity') {
160
- animateWithRepeat(nextCurrent, nextTarget, Infinity);
161
- }
162
- else {
163
- animateWithRepeat(nextCurrent, nextTarget, repeatCount - 1);
164
- }
165
- }, duration);
166
- }
167
- };
168
- const currentValue = sharedValue.value;
169
- const repeatTimes = transitionConfig.repeat === 'infinity' ? Infinity : ((_a = transitionConfig.repeat) !== null && _a !== void 0 ? _a : 0);
150
+ const repeatCount = transitionConfig.repeat === 'infinity' ? -1 : transitionConfig.repeat;
151
+ const reverse = transitionConfig.repeatType === 'reverse';
152
+ config = (0, react_native_reanimated_1.withRepeat)(baseAnimation, repeatCount, reverse);
153
+ }
154
+ else {
155
+ // Single animation
156
+ config = transitionConfig.type === 'spring'
157
+ ? (0, react_native_reanimated_1.withSpring)(value, {
158
+ damping: (_e = transitionConfig.damping) !== null && _e !== void 0 ? _e : DEFAULT_TRANSITION.damping,
159
+ stiffness: (_f = transitionConfig.stiffness) !== null && _f !== void 0 ? _f : DEFAULT_TRANSITION.stiffness,
160
+ mass: (_g = transitionConfig.mass) !== null && _g !== void 0 ? _g : 1,
161
+ })
162
+ : (0, react_native_reanimated_1.withTiming)(value, {
163
+ duration: (_h = transitionConfig.duration) !== null && _h !== void 0 ? _h : DEFAULT_TRANSITION.duration,
164
+ });
165
+ }
170
166
  if (transitionConfig.delay) {
171
167
  setTimeout(() => {
172
- animateWithRepeat(currentValue, value, repeatTimes);
168
+ sharedValue.value = config;
173
169
  }, transitionConfig.delay);
174
170
  }
175
171
  else {
176
- animateWithRepeat(currentValue, value, repeatTimes);
172
+ sharedValue.value = config;
177
173
  }
178
174
  }
179
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-on-native",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
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",