Created
January 8, 2018 02:20
-
-
Save rickhernandezio/80fc67e7e31293b9ead50568e20036b3 to your computer and use it in GitHub Desktop.
Animate.css Tutorial - Building a Image Slider with jQuery
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).ready(function() { | |
var lastImage = 1; | |
setInterval(() => { | |
$('.product .version-' + lastImage).removeClass('fadeIn'); | |
$('.product .version-' + lastImage).addClass('slideOutRight'); | |
setTimeout(() => { | |
$('.product .version-' + lastImage).addClass('hidden'); | |
$('.product .version-' + lastImage).removeClass('animated slideOutRight'); | |
var randomImage = RandomNumber(1, 5, lastImage); | |
$('.product .version-' + randomImage).removeClass('hidden'); | |
$('.product .version-' + randomImage).addClass('animated fadeIn'); | |
lastImage = randomImage; | |
}, 1000); | |
}, 10 * 1000); | |
function RandomNumber(min, max, last) { | |
var random = Math.floor(Math.random() * (max - min + 1) + min); | |
while (random === last) { | |
random = Math.floor(Math.random() * (max - min + 1) + min); | |
} | |
return random; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment