Skip to content

Commit b1ff538

Browse files
committed
Use display: none to prevent background transitions
This caused images to load repeatedly when cache is off
1 parent d14cf8c commit b1ff538

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/ImageGallery.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,11 @@ class ImageGallery extends React.Component {
423423
translate = `translate3d(${translateX}%, 0, 0)`;
424424
}
425425

426+
// don't show some slides while transitioning to avoid background transitions
427+
const isVisible = this.isSlideVisible(index);
428+
426429
return {
430+
display: isVisible ? 'inherit' : 'none',
427431
WebkitTransform: translate,
428432
MozTransform: translate,
429433
msTransform: translate,
@@ -524,14 +528,7 @@ class ImageGallery extends React.Component {
524528
</div>
525529
);
526530

527-
if (infinite) {
528-
// don't add some slides while transitioning to avoid background transitions
529-
if (this.shouldPushSlideOnInfiniteMode(index)) {
530-
slides.push(slide);
531-
}
532-
} else {
533-
slides.push(slide);
534-
}
531+
slides.push(slide);
535532

536533
if (showThumbnails) {
537534
const igThumbnailClass = clsx(
@@ -631,9 +628,9 @@ class ImageGallery extends React.Component {
631628
return isTransitioning && indexIsNotPreviousOrNextSlide;
632629
}
633630

634-
shouldPushSlideOnInfiniteMode(index) {
631+
isSlideVisible(index) {
635632
/*
636-
Push (show) slide if slide is the current slide and the next slide
633+
Show slide if slide is the current slide and the next slide
637634
OR
638635
The slide is going more than one slide left or right, but not going from
639636
first to last and not going from last to first

0 commit comments

Comments
 (0)