From 5114dc625f1b2bbfbf2649bb53449dc68baf1c43 Mon Sep 17 00:00:00 2001 From: hunx Date: Fri, 9 Feb 2024 19:02:21 +0500 Subject: [PATCH 1/8] fixed issue https://github.com/xiaolin/react-image-gallery/issues/767 --- example/App.jsx | 1 + src/components/ImageGallery.jsx | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/example/App.jsx b/example/App.jsx index 4b8c37ae..4c5347d1 100644 --- a/example/App.jsx +++ b/example/App.jsx @@ -175,6 +175,7 @@ class App extends React.Component { return (
(

hello

)} ref={(i) => (this._imageGallery = i)} items={this.images} onClick={this._onImageClick.bind(this)} diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index 8b11785a..06bce4c8 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -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() { @@ -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; } From 80744fe4706cd81364452a1b702ad6d5afc3809e Mon Sep 17 00:00:00 2001 From: hunx Date: Wed, 21 Feb 2024 13:08:39 +0500 Subject: [PATCH 2/8] removed semi-colons --- src/components/ImageGallery.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index 06bce4c8..6a8869f5 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -763,14 +763,15 @@ class ImageGallery extends React.Component { } //SOLVED BY hunxjunedo : https://github.com/xiaolin/react-image-gallery/issues/767 + //removed some minor errors, rmeove semi-colon canSlideLeft() { - const { infinite, isRTL } = this.props; + 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()); + return infinite || (isRTL ? this.canSlideNext() : this.canSlidePrevious()) } canSlideRight() { - const { infinite, isRTL } = this.props; + const { infinite, isRTL } = this.props return infinite || (isRTL ? this.canSlidePrevious() : this.canSlideNext() ) } @@ -781,7 +782,7 @@ class ImageGallery extends React.Component { canSlideNext() { const { currentIndex } = this.state; - const { items, isRTL } = this.props; + const { items } = this.props; return currentIndex < items.length - 1; } From c44289f07d924d80f7be859ba2183db3805cc537 Mon Sep 17 00:00:00 2001 From: hunx Date: Wed, 21 Feb 2024 13:11:21 +0500 Subject: [PATCH 3/8] add semi-colons --- src/components/ImageGallery.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index 6a8869f5..52f50a6c 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -765,14 +765,14 @@ class ImageGallery extends React.Component { //SOLVED BY hunxjunedo : https://github.com/xiaolin/react-image-gallery/issues/767 //removed some minor errors, rmeove semi-colon canSlideLeft() { - const { infinite, isRTL } = this.props + 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()) + return infinite || (isRTL ? this.canSlideNext() : this.canSlidePrevious()); } canSlideRight() { - const { infinite, isRTL } = this.props - return infinite || (isRTL ? this.canSlidePrevious() : this.canSlideNext() ) + const { infinite, isRTL } = this.props; + return infinite || isRTL ? this.canSlidePrevious() : this.canSlideNext(); } canSlidePrevious() { From 3d51b44104eea35270d635ee32f7e6c4645809e1 Mon Sep 17 00:00:00 2001 From: hunx Date: Wed, 21 Feb 2024 13:15:09 +0500 Subject: [PATCH 4/8] fixed all errors shown by eslint --- src/components/ImageGallery.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index 52f50a6c..0ea69fb4 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -772,7 +772,7 @@ class ImageGallery extends React.Component { canSlideRight() { const { infinite, isRTL } = this.props; - return infinite || isRTL ? this.canSlidePrevious() : this.canSlideNext(); + return infinite || isRTL ? this.canSlidePrevious() : this.canSlideNext(); } canSlidePrevious() { From 6a3f3a6660b52ef9b7258d71ff6629bbda955bfa Mon Sep 17 00:00:00 2001 From: hunx Date: Thu, 22 Feb 2024 15:50:22 +0500 Subject: [PATCH 5/8] applied changes according to review, fixed issue #767 --- example/App.jsx | 1 - src/components/ImageGallery.jsx | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/example/App.jsx b/example/App.jsx index 4c5347d1..4b8c37ae 100644 --- a/example/App.jsx +++ b/example/App.jsx @@ -175,7 +175,6 @@ class App extends React.Component { return (
(

hello

)} ref={(i) => (this._imageGallery = i)} items={this.images} onClick={this._onImageClick.bind(this)} diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index 0ea69fb4..1f92daad 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -762,11 +762,9 @@ class ImageGallery extends React.Component { return items.length >= 2; } - //SOLVED BY hunxjunedo : https://github.com/xiaolin/react-image-gallery/issues/767 - //removed some minor errors, rmeove semi-colon canSlideLeft() { const { infinite, isRTL } = this.props; - //so basically is the list is right to left, the canSlideLeft depends on canSlideNext instead of canSlideRight + //so basically is the list is right to left (isRTL), the logic is inversed return infinite || (isRTL ? this.canSlideNext() : this.canSlidePrevious()); } From a1c61d1d9bae5fc6c16c9245846305ffe4c26c23 Mon Sep 17 00:00:00 2001 From: hunx Date: Fri, 23 Feb 2024 23:45:26 +0500 Subject: [PATCH 6/8] fixed RTL slide issue. BTW why is grammar emphasized this much ? --- src/components/ImageGallery.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index 1f92daad..eaaae288 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -764,7 +764,7 @@ class ImageGallery extends React.Component { canSlideLeft() { const { infinite, isRTL } = this.props; - //so basically is the list is right to left (isRTL), the logic is inversed + //reverse the logic if the slider has isRTL enabled return infinite || (isRTL ? this.canSlideNext() : this.canSlidePrevious()); } From 78226da133ab47b73426590afd1a7dcbeccddbf1 Mon Sep 17 00:00:00 2001 From: Xiao Lin Date: Mon, 26 Feb 2024 16:43:03 -0800 Subject: [PATCH 7/8] Update src/components/ImageGallery.jsx --- src/components/ImageGallery.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index eaaae288..8ef0fb1a 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -764,7 +764,7 @@ class ImageGallery extends React.Component { canSlideLeft() { const { infinite, isRTL } = this.props; - //reverse the logic if the slider has isRTL enabled + // reverse the logic if the slider has isRTL enabled return infinite || (isRTL ? this.canSlideNext() : this.canSlidePrevious()); } From 1dcbf4d7052505d1d86683830ecd722b8ab260c1 Mon Sep 17 00:00:00 2001 From: Xiao Lin Date: Mon, 26 Feb 2024 16:43:08 -0800 Subject: [PATCH 8/8] Update src/components/ImageGallery.jsx --- src/components/ImageGallery.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ImageGallery.jsx b/src/components/ImageGallery.jsx index 8ef0fb1a..e4ab0792 100644 --- a/src/components/ImageGallery.jsx +++ b/src/components/ImageGallery.jsx @@ -770,7 +770,7 @@ class ImageGallery extends React.Component { canSlideRight() { const { infinite, isRTL } = this.props; - return infinite || isRTL ? this.canSlidePrevious() : this.canSlideNext(); + return infinite || (isRTL ? this.canSlidePrevious() : this.canSlideNext()); } canSlidePrevious() {