shadcn-ui/ui

[feat]: Carousel autoplay restart

kratess opened this issue · 2 comments

Feature description

By default on click on an autoplay carousel it stops but it never restarts.
I'd like to make it restart after a while

Affected component/components

Carousel

Additional Context

No response

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues and PRs

You can easily make it restart.

Embla Carousel's docs: https://www.embla-carousel.com/plugins/autoplay/#stoponmouseenter

When enabled, autoplay will stop when a mouse pointer enters the Embla Carousel container. If stopOnInteraction is also false, autoplay will resume when the mouse leaves the carousel container.

import Autoplay from "embla-carousel-autoplay"
 
export function Example() {
  return (
    <Carousel
      plugins={[
        Autoplay({
          delay: 2000,
          stopOnInteraction: false,
          stopOnMouseEnter: true
        }),
      ]}
    >
      // ...
    </Carousel>
  )
}