Skip to content

Commit

Permalink
fix(carousel): use direction provider
Browse files Browse the repository at this point in the history
  • Loading branch information
nahasco committed May 22, 2024
1 parent 415a5e7 commit eb920b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/www/registry/default/ui/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from "react"
import useEmblaCarousel, {
type UseEmblaCarouselType,
} from "embla-carousel-react"
import { useDirection } from "@radix-ui/react-direction"
import { ArrowLeft, ArrowRight } from "lucide-react"

import { cn } from "@/lib/utils"
Expand Down Expand Up @@ -59,11 +60,12 @@ const Carousel = React.forwardRef<
},
ref
) => {
const dir = useDirection()
const [carouselRef, api] = useEmblaCarousel(
{
...opts,
axis: orientation === "horizontal" ? "x" : "y",
direction: (document.dir as "ltr" | "rtl") ?? "ltr",
direction: dir,
},
plugins
)
Expand Down Expand Up @@ -134,7 +136,7 @@ const Carousel = React.forwardRef<
scrollNext,
canScrollPrev,
canScrollNext,
direction: (document.dir as "ltr" | "rtl") ?? "ltr",
direction: dir,
}}
>
<div
Expand Down

0 comments on commit eb920b2

Please sign in to comment.