Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelhsmith/62e39463840aa91e7cc632b986f1e432 to your computer and use it in GitHub Desktop.
Save joelhsmith/62e39463840aa91e7cc632b986f1e432 to your computer and use it in GitHub Desktop.
Flexslider initialization that adds aria attributes and improves it's accessibility
$(document).ready(function() {
// NOTE: I suggest using this in addition to my Fork of the Flexslider library:
// https://github.com/jhc36-duke-edu/FlexSlider (This Fork fixes empty link problems that cannot be fixed through the api.)
$('.flexslider').flexslider({
slideshow: false,
prevText: "Previous slide",
nextText: "Next slide",
animation: "fade",
pausePlay: true,
pauseText: 'Pause Slideshow',
playText: 'Play Slideshow',
pauseInvisible: true,
animationLoop: false,
slideshowSpeed: 5000,
animationSpeed: 1000,
keyboard: false,
start: function(slider){
console.log('flex start');
current = slider.slides.eq(slider.currentSlide);
current.attr('aria-hidden', 'false');
current.siblings().attr('aria-hidden', 'true');
},
after: function(slider){
current = slider.slides.eq(slider.currentSlide);
current.attr('aria-hidden', 'false');
current.siblings().attr('aria-hidden', 'true');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment