Created
July 26, 2011 17:12
-
-
Save Wilto/1107253 to your computer and use it in GitHub Desktop.
Example Fade-y Slideshow Thing
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
.faderotate { | |
height: 250px; | |
position: relative; | |
width: 100%; | |
} | |
.faderotate .slide { | |
left: 0; | |
position: absolute; | |
top: 0; | |
width: 100%; | |
} | |
.faderotate .hidden { | |
left: -9999px; | |
} | |
<a href="#" class="next">Next</a> | |
<a href="#" class="prev">Prev</a> | |
<ol class="faderotate"> | |
<li class="slide"> | |
Stuff | |
</li> | |
<li class="slide"> | |
Things | |
</li> | |
</ol> | |
$('.slide').not(':first').addClass('hidden'); | |
$('.next, .prev').click(function(e) { | |
var $vis = $('.slide:visible'), | |
$prev = $(e.target).hasClass('prev'); | |
$goto = $vis[ $prev ? "prev" : "next" ](); | |
$goto.length && $vis.addClass('hidden') | |
[ $prev ? "prev" : "next" ]() | |
.removeClass('hidden'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, sorry—the above is just gonna show/hide instantly without a transition of some sort, which you could do using opacity and transitions, or jQuery’s native fadeOut/fadeIn functionality.