Merged in feat/SW-1790-mobile-city-map (pull request #1497)
Feat/SW-1790 : Mobile city destination map Approved-by: Christian Andolf Approved-by: Fredrik Thorsson
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { cx } from "class-variance-authority"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import { useCarousel } from "./CarouselContext"
|
||||
|
||||
@@ -11,11 +12,21 @@ export function CarouselContent({
|
||||
children,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||
const { carouselRef } = useCarousel()
|
||||
const { carouselRef, canScrollNext, canScrollPrev } = useCarousel()
|
||||
const [isOneItem, setIsOneItem] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setIsOneItem(!canScrollPrev() && !canScrollNext())
|
||||
}, [canScrollPrev, canScrollNext])
|
||||
|
||||
return (
|
||||
<div ref={carouselRef} className={styles.viewport}>
|
||||
<div className={cx(styles.container, className)} {...props}>
|
||||
<div
|
||||
className={cx(styles.container, className, {
|
||||
[styles.centerContent]: isOneItem,
|
||||
})}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user