Skip to content

Commit

Permalink
fixed issue #767
Browse files Browse the repository at this point in the history
  • Loading branch information
hunxjunedo committed Feb 9, 2024
1 parent f8b9817 commit 5114dc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions example/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class App extends React.Component {
return (
<section className="app">
<ImageGallery
// renderLeftNav= {(onclick, disabled) => (<p onClick={onclick}>hello</p>)}
ref={(i) => (this._imageGallery = i)}
items={this.images}
onClick={this._onImageClick.bind(this)}
Expand Down
12 changes: 7 additions & 5 deletions src/components/ImageGallery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -762,14 +762,16 @@ class ImageGallery extends React.Component {
return items.length >= 2;
}

//SOLVED BY hunxjunedo : https://github.com/xiaolin/react-image-gallery/issues/767
canSlideLeft() {
const { infinite } = this.props;
return infinite || this.canSlidePrevious();
const { infinite, isRTL } = this.props;
//so basically is the list is right to left, the canSlideLeft depends on canSlideNext instead of canSlideRight
return infinite || (isRTL ? this.canSlideNext() : this.canSlidePrevious());
}

canSlideRight() {
const { infinite } = this.props;
return infinite || this.canSlideNext();
const { infinite, isRTL } = this.props;
return infinite || (isRTL ? this.canSlidePrevious() : this.canSlideNext() )
}

canSlidePrevious() {
Expand All @@ -779,7 +781,7 @@ class ImageGallery extends React.Component {

canSlideNext() {
const { currentIndex } = this.state;
const { items } = this.props;
const { items, isRTL } = this.props;
return currentIndex < items.length - 1;
}

Expand Down

0 comments on commit 5114dc6

Please sign in to comment.