ant-design / ant-design-mobile-rn

Ant Design for React Native
https://rn.mobile.ant.design/
MIT License
3k stars 610 forks source link

Carousel自动切换和手动切换冲突 #1259

Open forget1 opened 1 year ago

forget1 commented 1 year ago

Reproduction link

https://1uokun.github.io/ant-design-mobile-rn/index.html

Steps to reproduce

官网示例在移动端打开,打开自动切换。手动切换的时候在一轮结束到第一张的时候会卡一下,然后偶尔会从第三张图直接切到第5张

What is expected?

手动切换的时候,暂停自动切换逻辑

What is actually happening?

手动切换时,自动切换还在继续

Environment Info
antd 2.3.1
React 0.45.0
System 安卓12
Browser RN
forget1 commented 1 year ago
<Carousel
   autoplay={true}
   autoplayInterval={5000}
   infinite
>
  {categories.items.map((item, index) =>{
    return (
      <TouchableOpacity key={index} activeOpacity={1} style={{width: '100%', height: 150, position: 'relative', justifyContent: 'center', alignItems: 'center'}} onPress={() => Actions.bulletin({id: item.id, partnerCode: partners.currentPartner.code})}>
         <Image style={{width:'100%',height:'100%'}} source={IMAGES[item.banner.content_id - 1]} resizeMethod='resize'></Image>
         <Text style={{position: 'absolute', fontSize: 20, backgroundColor: 'transparent', color: `${item.banner.color}`, fontWeight: '500'}}>{item.title}</Text>
       </TouchableOpacity>
    )})}
</Carousel>

本地相关代码如上