Skip to content

Commit

Permalink
[FEATURE] Allow tab navigation in carousel (#369)
Browse files Browse the repository at this point in the history
Added a js snippet which brings the focused slide into view when its out out the carousels viewport
  • Loading branch information
hputzek authored and MattiasNilsson committed Dec 7, 2017
1 parent 010ef6a commit a1658f9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion felayout_t3kit/dev/js/main/contentElements/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
// Get json content from element LogoCarousel.html
var label = JSON.parse($('#js__aria-labels').html())

$(this).swiper({
var swiper = $(this).swiper({
nextButton: '.js__logo-carousel__btn-next',
prevButton: '.js__logo-carousel__btn-prev',
slidesPerView: 5,
preloadImages: false,
lazyLoading: true,
watchSlidesVisibility: true,
lazyLoadingInPrevNext: true,
slideVisibleClass: 'is-visible',
spaceBetween: 20,
autoplay: $(this).data('autoplay'),
a11y: true,
Expand Down Expand Up @@ -49,6 +50,15 @@
}
}
})
// if the selected swipe is not visible when focused
// put it into view
$(swiper.slides).each(function (index, element) {
$(element).on('focusin', function (e) {
if ($(e.target).not('.is-visible')) {
swiper.slideTo(index)
}
})
})
})
})
})(jQuery)

0 comments on commit a1658f9

Please sign in to comment.