Skip to content

Commit 8adb3ec

Browse files
committed
fix ts errors
1 parent c543f22 commit 8adb3ec

File tree

3 files changed

+258
-20
lines changed

3 files changed

+258
-20
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"peerDependencies": {
3838
"react-native": ">=0.64.0",
3939
"react-native-gesture-handler": ">=1.10.1",
40-
"react-native-reanimated": ">=2.2.0"
40+
"react-native-reanimated": ">=2.8.0"
4141
},
4242
"devDependencies": {
4343
"@types/react": "^17.0.5",
@@ -49,7 +49,7 @@
4949
"react-native": "^0.62.2",
5050
"react-native-builder-bob": "^0.18.1",
5151
"react-native-gesture-handler": "^1.10.3",
52-
"react-native-reanimated": "^2.2.0",
52+
"react-native-reanimated": "^2.8.0",
5353
"typescript": "^4.2.4"
5454
},
5555
"react-native-builder-bob": {

src/index.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Animated, {
2121
withSpring,
2222
interpolate,
2323
Extrapolate,
24+
WithSpringConfig,
2425
} from "react-native-reanimated";
2526

2627
export enum OpenDirection {
@@ -71,7 +72,7 @@ type Props<T> = {
7172
renderUnderlayRight?: RenderUnderlay<T>;
7273
onChange?: (params: { open: OpenDirection; snapPoint: number }) => void;
7374
overSwipe?: number;
74-
animationConfig?: Partial<Animated.WithSpringConfig>;
75+
animationConfig?: Partial<WithSpringConfig>;
7576
activationThreshold?: number;
7677
swipeEnabled?: boolean;
7778
snapPointsLeft?: number[];
@@ -104,7 +105,7 @@ function SwipeableItem<T>(
104105
animationConfig = {},
105106
} = props;
106107

107-
const springConfig: Animated.WithSpringConfig = {
108+
const springConfig: WithSpringConfig = {
108109
damping: 20,
109110
mass: 0.2,
110111
stiffness: 100,
@@ -186,7 +187,9 @@ function SwipeableItem<T>(
186187
snapPoint ?? maxSnapPointLeft,
187188
springConfig,
188189
(isFinished) => {
189-
runOnJS(resolvePromiseIfFinished)(isFinished);
190+
if (isFinished) {
191+
runOnJS(resolvePromiseIfFinished)(isFinished);
192+
}
190193
}
191194
);
192195
});
@@ -200,7 +203,9 @@ function SwipeableItem<T>(
200203
snapPoint ?? maxSnapPointRight,
201204
springConfig,
202205
(isFinished) => {
203-
runOnJS(resolvePromiseIfFinished)(isFinished);
206+
if (isFinished) {
207+
runOnJS(resolvePromiseIfFinished)(isFinished);
208+
}
204209
}
205210
);
206211
});
@@ -212,7 +217,9 @@ function SwipeableItem<T>(
212217
if (isFinished) resolve();
213218
}
214219
animStatePos.value = withSpring(0, springConfig, (isFinished) => {
215-
runOnJS(resolvePromiseIfFinished)(isFinished);
220+
if (isFinished) {
221+
runOnJS(resolvePromiseIfFinished)(isFinished);
222+
}
216223
});
217224
});
218225
}

0 commit comments

Comments
 (0)