Skip to content

Commit

Permalink
fix: Carousel compatible with vertical property (ant-design#35349)
Browse files Browse the repository at this point in the history
  • Loading branch information
haipeng committed May 5, 2022
1 parent 50d3d99 commit a217301
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions components/carousel/index.tsx
Expand Up @@ -30,7 +30,17 @@ export interface CarouselRef {
}

const Carousel = React.forwardRef<CarouselRef, CarouselProps>(
({ dots = true, arrows = false, draggable = false, dotPosition = 'bottom', ...props }, ref) => {
(
{
dots = true,
arrows = false,
draggable = false,
dotPosition = 'bottom',
vertical = dotPosition === 'left' || dotPosition === 'right',
...props
},
ref,
) => {
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const slickRef = React.useRef<any>();

Expand Down Expand Up @@ -60,6 +70,7 @@ const Carousel = React.forwardRef<CarouselRef, CarouselProps>(
}, [props.children]);

const newProps = {
vertical,
...props,
};

Expand All @@ -69,7 +80,6 @@ const Carousel = React.forwardRef<CarouselRef, CarouselProps>(

const prefixCls = getPrefixCls('carousel', newProps.prefixCls);
const dotsClass = 'slick-dots';
newProps.vertical = dotPosition === 'left' || dotPosition === 'right';

const enableDots = !!dots;
const dsClass = classNames(
Expand All @@ -80,7 +90,7 @@ const Carousel = React.forwardRef<CarouselRef, CarouselProps>(

const className = classNames(prefixCls, {
[`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-vertical`]: newProps.vertical,
[`${prefixCls}-vertical`]: dotPosition === 'left' || dotPosition === 'right',
});

return (
Expand Down

0 comments on commit a217301

Please sign in to comment.