Skip to content

Render index 0 when the carousel is visible #237

Open

Description

@SamehArmouche

Hello,
I have a carousel with autoplay = true and with 3 elements per slide, and i use ref to render the carousel when it is visible in window,
I need to reset the index to 0 every time the component is visible.

Any idea how ?

Activity

  1. confrodog commented on Apr 4, 2025

    @confrodog

    does a useEffect not solve this problem?

  2. SamehArmouche commented on Apr 7, 2025

    @SamehArmouche
    Author

    No, because i need reanimation the component when it visible in window

  3. confrodog commented on Apr 7, 2025

    @confrodog

    I would recommend controlling the index of the carousel yourself, with a useState to hold the index and you can pass it into the Carousel with its index prop.
    This way, you can set index to 0 and control it with the Navigation Button callback functions with something like setIndex(index++); on next and setIndex(index--); on prev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions