diff --git a/zh-cn/react-native-reanimated-carousel.md b/zh-cn/react-native-reanimated-carousel.md index 2606df6b146c1b10c6e0c1175cefe5891ef09ec4..cbcfb8c34f30070aff20794aae874402ad548fff 100644 --- a/zh-cn/react-native-reanimated-carousel.md +++ b/zh-cn/react-native-reanimated-carousel.md @@ -1,5 +1,4 @@ - -> 模板版本:v0.1.3 +> 模板版本:v0.2.2

react-native-reanimated-carousel

@@ -8,9 +7,12 @@ Supported platforms + + License +

-> [!tip] [Github 地址](https://github.com/dohooo/react-native-reanimated-carousel) +> [!TIP] [Github 地址](https://github.com/dohooo/react-native-reanimated-carousel) ## 安装与使用 @@ -34,258 +36,117 @@ npm install react-native-reanimated-carousel@^3.5.1 下面的代码展示了这个库的基本使用场景: +> [!WARNING] 使用时 import 的库名不变。 + ```js import * as React from "react"; -import { ScrollView } from "react-native-gesture-handler"; import type { ICarouselInstance } from "react-native-reanimated-carousel"; import Carousel from "react-native-reanimated-carousel"; -import { SafeAreaView } from "react-native-safe-area-context"; +import { View, Text, Button } from "react-native"; +import { useSharedValue } from "react-native-reanimated"; -import SButton from "./components/SButton"; -import { ElementsText, window } from "./constants"; -import { useWindowDimensions, View, Text, Button } from "react-native"; -import { useSharedValue } from "@react-native-oh-tpl/react-native-reanimated"; -const PAGE_WIDTH = window.width; - -function App() { - const windowWidth = useWindowDimensions().width; +export function ReanimaDemo() { const scrollOffsetValue = useSharedValue(1); const [data, setData] = React.useState([...new Array(4).keys()]); - const [isVertical, setIsVertical] = React.useState(false); - const [isFast, setIsFast] = React.useState(false); - const [isAutoPlay, setIsAutoPlay] = React.useState(true); - const [isPagingEnabled, setIsPagingEnabled] = React.useState(true); const [value, setValue] = React.useState(0); const ref = React.useRef(null); - const baseOptions = isVertical - ? ({ - vertical: true, - width: windowWidth, - height: PAGE_WIDTH / 2, - } as const) - : ({ - vertical: false, - width: windowWidth, - height: PAGE_WIDTH / 2, - } as const); - return ( - + {console.log('===1')}} - onScrollEnd={() => { console.log('===2') }} - - // onConfigurePanGesture={g => g.enabled(false)} - pagingEnabled={isPagingEnabled} onSnapToItem={index => setValue(index)} - renderItem={({ index }) => {return - - {`slide${value + 1}`} - - }} - /> - - - - - -