Skip to content

Commit

Permalink
Issue 552: Fixed edge swipe bug that prevented navigation back to fir…
Browse files Browse the repository at this point in the history
…st slide (#668)
  • Loading branch information
mariano-formidable committed Feb 20, 2020
1 parent 4b737f6 commit 60157fe
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/index.js
Expand Up @@ -708,19 +708,32 @@ export default class Carousel extends React.Component {
}

isEdgeSwiping() {
const { slideCount, slideWidth, slideHeight, slidesToShow } = this.state;
const {
currentSlide,
slideCount,
slideWidth,
slideHeight,
slidesToShow
} = this.state;
const { tx, ty } = this.getOffsetDeltas();
const offset = getAlignmentOffset(currentSlide, {
...this.props,
...this.state
});

if (this.props.vertical) {
const rowHeight = slideHeight / slidesToShow;
const slidesLeftToShow = slideCount - slidesToShow;
const lastSlideLimit = rowHeight * slidesLeftToShow;

const offsetTy = ty[0] - offset;
// returns true if ty offset is outside first or last slide
return ty > 0 || -ty > lastSlideLimit;
return offsetTy > 0 || -offsetTy > lastSlideLimit;
}

const offsetTx = tx[0] - offset;
// returns true if tx offset is outside first or last slide
return tx > 0 || -tx > slideWidth * (slideCount - 1);
return offsetTx > 0 || -offsetTx > slideWidth * (slideCount - 1);
}

// Action Methods
Expand Down

0 comments on commit 60157fe

Please sign in to comment.