Last active
December 14, 2015 15:29
-
-
Save courgette/5107904 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
/* | |
Use margin-top or left to the direction | |
Replace $containerItems and .slide | |
*/ | |
function gallerySlide(direction) { | |
var firstSlide = $containerItems.find('.slide:first-child'), | |
lastSlide = $containerItems.find('.slide:last-child'), | |
duration = 400; | |
// Prev Direction | |
if(direction == 'prev') { | |
$containerItems.find('.slide').css({'margin-top':0}); | |
lastSlide.prependTo($containerItems).css({ | |
'margin-top': '-'+heightSlide+'px' | |
}).animate({ | |
'margin-top': 0 | |
}, duration); | |
// Next Direction | |
} else if( direction == 'next') { | |
firstSlide | |
.animate({ | |
'margin-top': '-'+heightSlide+'px' | |
}, duration, function(){ | |
$(this).css({'margin-top':0}).appendTo($containerItems); | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment