react-native-reanimated-carousel
Version:
Simple carousel component.fully implemented using Reanimated 2.Infinitely scrolling, very smooth.
18 lines (15 loc) • 576 B
text/typescript
import { withSpring, withTiming } from "react-native-reanimated";
import type { WithAnimation } from "../types";
export function dealWithAnimation(
withAnimation: WithAnimation
): (value: number, cb: (isFinished: boolean) => void) => number {
"worklet";
switch (withAnimation.type) {
case "spring":
return (value, cb) =>
withSpring(value, withAnimation.config, (isFinished) => cb(isFinished as boolean));
case "timing":
return (value, cb) =>
withTiming(value, withAnimation.config, (isFinished) => cb(isFinished as boolean));
}
}