Skip to content

Instantly share code, notes, and snippets.

@imakewebthings
Created March 27, 2014 19:27
Show Gist options
  • Save imakewebthings/9816070 to your computer and use it in GitHub Desktop.
Save imakewebthings/9816070 to your computer and use it in GitHub Desktop.
$(document).on('deck.beforeChange', function(event, from, to) {
var $slides = $.deck('getSlides');
var onLastSlide = from === $slides.length - 1;
var onFirstSlide = !from;
var goingForward = to > from;
var nextUrl = $('link[rel="next"]').attr('href');
var prevUrl = $('link[rel="prev"]').attr('href');
if (onLastSlide && goingForward && nextUrl) {
window.location = nextUrl;
}
else if (onFirstSlide && !goingForward && prevUrl) {
window.location = prevUrl;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment