dohooo / react-native-reanimated-carousel

🎠 React Native swiper/carousel component, fully implemented using reanimated v2, support to iOS/Android/Web. (Swiper/Carousel)
https://react-native-reanimated-carousel.vercel.app
MIT License
2.71k stars 313 forks source link

Android点击轮播图后,就不再自动播放 #115

Closed tengjingyao closed 2 years ago

tengjingyao commented 2 years ago

Android不管是长按还是单次点击轮播图后,轮播图就不再自动播放

tengjingyao commented 2 years ago

<Carousel style={{ width: PhoneInfo.phone_width, height: SizeUtil.px2dp(234) / 0.88, }} width={PhoneInfo.phone_width} height={cardHeight / 0.88} data={this.state.dataList} autoPlay={true} autoPlayInterval={5000} mode="parallax" modeConfig={{ parallaxScrollingScale: 0.88, parallaxScrollingOffset: SizeUtil.px2dp(50), }} loop={true} enableSnap={false} renderItem={({ item, index }) => this.renderRow(item, index)} onSnapToItem={index => { this.lastIndex = this.index; this.index = index; this.startAnimation(); }} onScrollBegin={e => { this.stopAnimationTimer(); }} onScrollEnd={e => { this.startAnimation(); }} />

dohooo commented 2 years ago

你用的什么版本?昨天发布了2.2.2解决了这个问题

tengjingyao commented 2 years ago

好吧 我用的2.2.1版本 马上更新一下

dohooo commented 2 years ago

好吧 我用的2.2.1版本 马上更新一下

如果没问题记得回复我下 hh, 我会关闭这个issue

tengjingyao commented 2 years ago

升级到2.2.2版本还是有这样的问题,是不是我这边配置的属性有问题 @dohooo

dohooo commented 2 years ago

我复现一下试试 你可以来discord https://discord.gg/cPzr7WMQ

tengjingyao commented 2 years ago

不好意思,discord我这边进不去 @dohooo

dohooo commented 2 years ago

问题已经解决了 一会就发布 我会在这里通知你

dohooo commented 2 years ago

@tengjingyao v2.2.3

dohooo commented 2 years ago

@tengjingyao 同样如果没问题 说下哈

tengjingyao commented 2 years ago

已经升级,自动播放问题已解决,有个建议就是你看onTouchStart跟onTouchEnd方法能不能在props回调一下。

dohooo commented 2 years ago

已经升级,自动播放问题已解决,有个建议就是你看onTouchStart跟onTouchEnd方法能不能在props回调一下。

具体什么使用场景呢?

tengjingyao commented 2 years ago

我这边跟轮播图有个需求,就是有个页眉动画,页眉动画跟轮播图是同步的。touchStart的时候,我需要停止页眉动画,touchEnd的时候,我就要把页眉动画重新开启

tengjingyao commented 2 years ago

或者说能不能再touchEnd的时候也调用一下onScrollEnd回调,这样就不用调整props属性 @dohooo

dohooo commented 2 years ago

或者说能不能再touchEnd的时候也调用一下onScrollEnd回调,这样就不用调整props属性 @dohooo

现在拖动之后不会调用onScrollEnd么? 还是说你需要一个点击(不拖动)一下结束的回调?

tengjingyao commented 2 years ago

对,现在就发现不拖动,只点击,没有scrollEnd回调,导致我页眉动画没办法再启动,只能等到onSnapToItem回调的时候恢复正常。不过我刚把组件本地化,把touchEnd回调中多执行一次scrollEnd。

dohooo commented 2 years ago

或者说能不能再touchEnd的时候也调用一下onScrollEnd回调,这样就不用调整props属性 @dohooo

或者你可以给你的Item加一个warpper 处理点击事件的onTouchStart/End事件? 比方说

renderItem={()=>{
    return <View
            onTouchStart={...}
            onTouchEnd={...}
    >
         {...你的内容}
    </View>
}}
dohooo commented 2 years ago

再或者把这样子的Wrapper包在你的Carousel上?

tengjingyao commented 2 years ago

可以,感谢提示

dohooo commented 2 years ago

可以,感谢提示

没关系 谢谢你的bug issue!~

Mr-YYe commented 2 years ago

@dohooo 我现在用的2.3版本 安卓端点击后就不自动播放了需要怎么解决