Skip to content

Instantly share code, notes, and snippets.

@ericdfields
Created January 4, 2011 03:37
Show Gist options
  • Save ericdfields/764353 to your computer and use it in GitHub Desktop.
Save ericdfields/764353 to your computer and use it in GitHub Desktop.
$controls.find('a').each(function(index){
var $this = $(this)
$this.data('active',false)
$this.bind('click',function(e){
e.preventDefault()
if (!$this.data('active')) {
$this.data('active',true)
switch (index) {
case 0:
// up
if ($controlsListItems.data('current') < $controlsListItems.length-1) {
$controlsListItems.data('current',($controlsListItems.data('current') + 1))
$quotes.filter(':visible').fadeOut(function(){
$($quotes.eq($controlsListItems.data('current'))).fadeIn()
})
$firstListItem.animate({
marginTop: '-='+liHeight
},function(){
$this.data('active',false)
})
}
break
case 1:
// down
if (0 < $controlsListItems.data('current')) {
$controlsListItems.data('current',($controlsListItems.data('current') - 1))
$quotes.filter(':visible').fadeOut(function(){
$($quotes.get($controlsListItems.data('current'))).fadeIn()
})
$firstListItem.animate({
marginTop: '+='+liHeight
},function(){
$this.data('active',false)
})
}
break
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment