Skip to content

Commit 0dc4692

Browse files
committed
Use realIndex on looping to fix URL hashes
1 parent e3c9d46 commit 0dc4692

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

projects/plugins/jetpack/modules/carousel/jetpack-carousel.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,19 +1532,7 @@
15321532
} );
15331533

15341534
swiper.on( 'slideChange', function ( swiper ) {
1535-
var index;
1536-
// Swiper indexes slides from 1, plus when looping to left last slide ends up
1537-
// as 0 and looping to right first slide as total slides + 1. These are adjusted
1538-
// here to match index of carousel.slides.
1539-
if ( swiper.activeIndex === 0 ) {
1540-
index = carousel.slides.length - 1;
1541-
} else if ( swiper.activeIndex === carousel.slides.length + 1 ) {
1542-
index = 0;
1543-
} else {
1544-
index = swiper.activeIndex - 1;
1545-
}
1546-
selectSlideAtIndex( index );
1547-
1535+
selectSlideAtIndex( swiper.realIndex );
15481536
carousel.overlay.classList.remove( 'jp-carousel-hide-controls' );
15491537
} );
15501538

0 commit comments

Comments
 (0)