Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tengjingyao opened this issue Jan 24, 2022 · 21 comments
Closed

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

tengjingyao opened this issue Jan 24, 2022 · 21 comments
Assignees
Labels
bug Something isn't working

Comments

@tengjingyao
Copy link

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

@tengjingyao
Copy link
Author

<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
Copy link
Owner

dohooo commented Jan 24, 2022

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

@tengjingyao
Copy link
Author

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

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

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

@tengjingyao
Copy link
Author

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

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

@dohooo dohooo self-assigned this Jan 24, 2022
@dohooo dohooo added the bug Something isn't working label Jan 24, 2022
@tengjingyao
Copy link
Author

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

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

@dohooo dohooo closed this as completed in eb21293 Jan 24, 2022
@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

@tengjingyao v2.2.3

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

@tengjingyao
Copy link
Author

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

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

具体什么使用场景呢?

@tengjingyao
Copy link
Author

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

@tengjingyao
Copy link
Author

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

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

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

@tengjingyao
Copy link
Author

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

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

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

renderItem={()=>{
    return <View
            onTouchStart={...}
            onTouchEnd={...}
    >
         {...你的内容}
    </View>
}}

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

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

@tengjingyao
Copy link
Author

可以,感谢提示

@dohooo
Copy link
Owner

dohooo commented Jan 24, 2022

可以,感谢提示

没关系 谢谢你的bug issue!~

@Mr-YYe
Copy link

Mr-YYe commented Apr 27, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants