Skip to content

Commit 6f3626c

Browse files
authored
Merge pull request #110 from sag1v/rtl-swipe
fix rtl swipe
2 parents a74b418 + 22d6eff commit 6f3626c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/react-elastic-carousel/components/Carousel.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,18 @@ class Carousel extends React.Component {
390390
// bail out of state update
391391
return;
392392
}
393+
let swipedSliderPosition;
394+
if (horizontalSwipe) {
395+
if (isRTL) {
396+
swipedSliderPosition = sliderPosition + deltaX;
397+
} else {
398+
swipedSliderPosition = sliderPosition - deltaX;
399+
}
400+
} else {
401+
swipedSliderPosition = sliderPosition - deltaY;
402+
}
393403
return {
394-
swipedSliderPosition: horizontalSwipe
395-
? sliderPosition - deltaX
396-
: sliderPosition - deltaY,
404+
swipedSliderPosition,
397405
isSwiping: true,
398406
transitioning: true
399407
};

0 commit comments

Comments
 (0)