Skip to content

Instantly share code, notes, and snippets.

@joelpittet
Created September 15, 2011 19:54
Show Gist options
  • Select an option

  • Save joelpittet/1220293 to your computer and use it in GitHub Desktop.

Select an option

Save joelpittet/1220293 to your computer and use it in GitHub Desktop.
Dropdown menu that animates
var lastOpenItem = null;
$(".nav li.HasSubMenu ul").each(function(i, el){
$(this).data('originalHeight', $(this).height());
$(this).css('width', $(this).width());
})
$(".nav li.HasSubMenu ul").css({height: '0px'});
$(".nav li.HasSubMenu").hover(
function () {
$(this).addClass("hover");
$(this).children('ul').eq(0)
.css({visibility: 'visible', zIndex: 1000})
.stop()
.animate({
height: $(this).children('ul').eq(0).data('originalHeight') + 'px'
}, {queue:false, duration:500, easing: 'easeOutSine'});
}, function() {
lastOpenItem = $(this);
$(this).delay(200)
.removeClass("hover")
.children('ul').eq(0)
.css({zIndex: 999})
.stop()
.animate({
height: '0px'
},{
queue:false,
duration:300,
easing: 'easeInSine',
complete: function() {
$(this).css({visibility: 'hidden'});
}
}
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment