Skip to content

Commit

Permalink
[FIX] Use tab to navigate slider
Browse files Browse the repository at this point in the history
  • Loading branch information
dmh committed Jun 13, 2016
1 parent 8253f71 commit ad06db5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dev/js/main/contentElements/slider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global Swiper*/
(function($) {
'use strict';

Expand All @@ -6,7 +7,7 @@

// initialize swiper when document ready
// http://idangero.us/swiper/api/
$('.js__img-slider').swiper({
var swiper = new Swiper('.js__img-slider', {
nextButton: '.js__img-slider__btn-next',
prevButton: '.js__img-slider__btn-prev',
pagination: '.js__img-slider__pagination',
Expand All @@ -17,6 +18,15 @@
lazyLoadingInPrevNext: true,
speed: 600
});
// Makes it possible to skip between slider images if they have links, using the tab button
swiper.container.on('focus', 'a', function(e) {
//Index of focused slide
var focusIndex = $(e.target).parents('.swiper-slide').index();
//Reset scrollLeft set by browser on focus
swiper.container.scrollLeft(0);
//Slide to focused slide
swiper.slideTo(focusIndex);
});
});

})(jQuery);

0 comments on commit ad06db5

Please sign in to comment.