react-native-ui-lib icon indicating copy to clipboard operation
react-native-ui-lib copied to clipboard

[ANDROID] Carousel loop doesn't behave correctly

Open baselshlewett opened this issue 2 years ago • 14 comments

Description

Auto play(loop) carousel on android jumps through indexes randomly and at most shows only 2-3 items, for example in an array of 18 items, it will only show indexes 0,1 and then jump to 17.

Expected behavior

Carousel should loop through all items as defined by items rendered

Actual behavior

Carousel jumps through items at random and at most shows only 2-3 items

Code snippet

<Carousel
    loop={true}
    autoplay={true}
    autoplayInterval={5000}
    showCounter={true}>
        {article?.multi_images?.map((item: string, index: number) => {
             return (
                 <Card.Image
                      key={index}
                      source={{uri: `${Config.ASSETS_URL}${item}`}}
                      cover={true} 
                      aspectRatio={1.34}
                      style={{
                          borderTopLeftRadius: 15,
                          borderTopRightRadius: 15,
                          borderBottomLeftRadius: article?.has_tickers ? 0 : 15,
                          borderBottomRightRadius: article?.has_tickers ? 0 : 15,
                      }}
                  />
              );
          })}
</Carousel>

Environment

  • React Native version: 0.72.6
  • React Native UI Lib version: 7.9.1

Affected platforms

  • [x] Android
  • [x] iOS
  • [ ] Web

baselshlewett avatar Oct 25 '23 15:10 baselshlewett

Hello all, Any updates regarding this? or any work-around? As we're preparing to go to production

baselshlewett avatar Nov 19 '23 13:11 baselshlewett

Hi, this was a bug when using android in rtl. It will be fixed in the next release.

nitzanyiz avatar Dec 05 '23 14:12 nitzanyiz

Hi, this was a bug when using android in rtl. It will be fixed in the next release.

Thank you @NitzanWix, let me know if I can help with anything

baselshlewett avatar Dec 06 '23 08:12 baselshlewett

@NitzanWix I just managed to update to the latest version, and while the original issue is solved on android, I'm now observing the same issue on iOS.

And as a side-effect to the fix, now text inside RTL carousel is mirrored:

Screenshot 2023-12-13 at 13 03 09 Screenshot 2023-12-13 at 13 03 24

baselshlewett avatar Dec 13 '23 11:12 baselshlewett

Hi, Thanks you're response. I see the inverted text bug. Can you elaborate on what you're now experiencing on ios? I don't see any jumps on my end.

nitzanyiz avatar Dec 13 '23 15:12 nitzanyiz

I observed the same behavior as in the original ticket, only this time was on [email protected].

For the time being I reverted to version [email protected] as I need to release to production.. I will do further tests after the release, and probably during the weekend and post the results here.

baselshlewett avatar Dec 13 '23 15:12 baselshlewett

Hey @NitzanWix, I can confirm I'm experiencing the same behaviour as the original ticket on iOS

Environment

  • React Native version: 0.73.0
  • React Native UI Lib version: 7.12.2

On android, in addition to text being mirrored, I can see the the carousel direction is also reversed on RTL..

Let me know if I can provide any more details Have a nice weekend

baselshlewett avatar Dec 15 '23 09:12 baselshlewett

Thanks for the reply. Could you show me how you use the carousel? (Code). Do you use autoplayInterval by any chance?

nitzanyiz avatar Dec 17 '23 08:12 nitzanyiz

Thanks for the reply. Could you show me how you use the carousel? (Code). Do you use autoplayInterval by any chance?

Yes, I am.

I'm also forcing RTL through native code if that helps.

here is my implementation: inside component/Card.tsx:

<Carousel
    key={article.multi_images.length ?? 0}
    autoplay={true}
    autoplayInterval={5000}
    itemSpacings={Spacings.s3}
    initialPage={0}
    showCounter={true}
    >
    {article?.multi_images?.map((item: string, index: number) => {
        return (
            <Card.Image
                key={index}
                source={{uri: `${IMAGE_URL}`}}
                cover={true}
                aspectRatio={1.34}
                style={{
                    borderTopLeftRadius: 15,
                    borderTopRightRadius: 15,
                    borderBottomLeftRadius: article?.has_tickers
                        ? 0
                        : 15,
                    borderBottomRightRadius: article?.has_tickers
                        ? 0
                        : 15,
                }}
            />
        );
    })}
</Carousel>

MainApplication.kt (previously MainApplication.java):

val sharedI18nUtilInstance: I18nUtil  = I18nUtil.getInstance()
sharedI18nUtilInstance.forceRTL(this,true)
sharedI18nUtilInstance.allowRTL(this, true);

AppDelegate.mm:

[[RCTI18nUtil sharedInstance] allowRTL:YES];
[[RCTI18nUtil sharedInstance] forceRTL:YES];

baselshlewett avatar Dec 17 '23 11:12 baselshlewett

Does this still occur with the new release? If so, could you attach a recording of it by any chance?

nitzanyiz avatar Jan 01 '24 11:01 nitzanyiz

Hey @NitzanWix, thanks for your efforts,

On android, autoplay and loop are working as expected.

However, the initial starting position is set to the last index of the carousel. (I tried settings the initialPage prop to 0, but it doesn't work unless it's through a hot-reload)

On iOS the only issue is that initial issue of this bug report, which is the jumping between indexes.

See attached: (left is iOS, right is Android) Video screen recording of jumping carousel: https://github.com/wix/react-native-ui-lib/assets/20260587/b2a2a5e5-ebea-46b8-9260-bb6b77642495

Screenshot of initial page wrong index on android: Screenshot 2024-01-02 at 11 38 00

baselshlewett avatar Jan 02 '24 09:01 baselshlewett

@NitzanWix any updates?

baselshlewett avatar Jan 22 '24 11:01 baselshlewett

This issue still exists on the Android platform, currently using React Native version: 0.73.0 and React Native UI Lib version: 7.21.2

fmtjava avatar May 07 '24 09:05 fmtjava

also experiencing strange carousel behaviour

mdecrocemovson avatar Nov 11 '24 19:11 mdecrocemovson