国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

React Native Reanimated Carousel ScrollTo 事件不起作用
P粉232793765
P粉232793765 2023-12-24 15:44:11
0
1
789

我正在使用反應(yīng)本機(jī)復(fù)活輪播。在輪播中,我正在渲染圖像,當(dāng)我點(diǎn)擊圖像時(shí),它不會(huì)滾動(dòng)到該圖像。這是程式碼:

<Carousel
        ref={carouselRef}
                loop
                width={Dimensions.get("window").width}
                height={300 / 2}
                data={carTypes}
                mode="parallax"
                defaultIndex={1}
                
                style={{ alignSelf: "center",justifyContent: "center", alignContent: "center"}}
                scrollAnimationDuration={1000}
                onSnapToItem={(index) => setActiveSlide(index)}
                renderItem={({ item, index }) => (
                    <TouchableOpacity
                    **onPress={() => carouselRef.current.scrollTo(index)}**
                    activeOpacity={0.1}
                        style={{
                            backgroundColor: activeSlide !== index ? carouselActiveSlide(index) : "#3887EF",
                            borderWidth: 1,
                            justifyContent: 'center',
                            transform: [{ rotate: "32deg" }],
                            borderRadius: 32,
                            width: 50
                        }}
                    />

我嘗試測(cè)試其他事件,如.next() 、 .prev() ,它們是否按預(yù)期工作,但.scrollTo(index)不起作用。你能告訴我我錯(cuò)過了什麼嗎?

P粉232793765
P粉232793765

全部回覆(1)
P粉748218846

如果您仔細(xì)查看文檔,您必須在scollTo 中傳遞一個(gè)帶有索引的物件:https://github.com/dohooo/react-native-reanimated-carousel/blob /main/docs/props。 md#ref

像這樣:

scrollTo({index: 1})

#
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板