Created
March 27, 2014 19:27
-
-
Save imakewebthings/9816070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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