From 290db600574f54e10a41d2bd97c96e4df4286ac5 Mon Sep 17 00:00:00 2001 From: ddwwwww <18829031738@163.com> Date: Fri, 9 Aug 2024 15:56:24 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20[Issues:=20#IAJ0AL]=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9react-native-reanimated-carousel=E6=8C=87=E5=AF=BC?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/react-native-reanimated-carousel.md | 344 +++++++--------------- 1 file changed, 100 insertions(+), 244 deletions(-) diff --git a/zh-cn/react-native-reanimated-carousel.md b/zh-cn/react-native-reanimated-carousel.md index 2606df6b..cbcfb8c3 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}`} - - }} - /> - - - - - -