Skip to content

Commit

Permalink
Add active class to infinite clones
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Boulongne authored and thomasboulongne committed Jan 16, 2020
1 parent 648fa7a commit fc0d514
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lory.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function lory (slider, opts) {
* set active class to element which is the current slide
*/
function setActiveElement (slides, currentIndex) {
const {classNameActiveSlide} = options;
const {classNameActiveSlide, infinite} = options;

slides.forEach((element, index) => {
if (element.classList.contains(classNameActiveSlide)) {
Expand All @@ -48,6 +48,12 @@ export function lory (slider, opts) {
});

slides[currentIndex].classList.add(classNameActiveSlide);

if (infinite && currentIndex === slides.length - infinite * 2) {
slides[infinite - 1].classList.add(classNameActiveSlide);
} else if (currentIndex === infinite) {
slides[slides.length - infinite].classList.add(classNameActiveSlide);
}
}

/**
Expand Down

0 comments on commit fc0d514

Please sign in to comment.