Skip to content

Commit

Permalink
Refactor #1030
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Oct 15, 2019
1 parent a559615 commit 8bbf51c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/carousel/Carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@

.p-carousel-vertical .p-carousel-dots-container {
margin: .75em 0;
}

/* Keyboard Support */
.p-items-hidden .p-carousel-item {
visibility: hidden;
}

.p-items-hidden .p-carousel-item.p-carousel-item-active {
visibility: visible;
}
3 changes: 3 additions & 0 deletions src/components/carousel/Carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import UniqueComponentId from '../utils/UniqueComponentId';
import DomHandler from '../utils/DomHandler';

class CarouselItem extends Component {

Expand Down Expand Up @@ -153,6 +154,7 @@ export class Carousel extends Component {
}

if (this.itemsContainer) {
DomHandler.removeClass(this.itemsContainer, 'p-items-hidden');
this.itemsContainer.style.transform = this.isVertical() ? `translate3d(0, ${totalShiftedItems * (100/ this.state.numVisible)}%, 0)` : `translate3d(${totalShiftedItems * (100/ this.state.numVisible)}%, 0, 0)`;
this.itemsContainer.style.transition = 'transform 500ms ease 0s';
}
Expand Down Expand Up @@ -267,6 +269,7 @@ export class Carousel extends Component {

onTransitionEnd() {
if (this.itemsContainer) {
DomHandler.addClass(this.itemsContainer, 'p-items-hidden');
this.itemsContainer.style.transition = '';

if ((this.state.page === 0 || this.state.page === (this.totalDots - 1)) && this.isCircular()) {
Expand Down

0 comments on commit 8bbf51c

Please sign in to comment.