var maxHeight = 300;
$(function(){
$(".dropdowns > li").hover(function() {
var $container = $(this);
var $list = $container.find("ul");
var $anchor = $container.find("a");
var height = $list.height() * 1.1;
var multiplier = height / maxHeight;
$container.data("origHeight", multiplier);
$anchor.addClass("hover");
$list.show().css({
paddingTop: $container.data("origHeight")
});
if (multiplier > 1) {
$container.css({
height: maxHeight,
overflow: "hidden"
}).mousemove(function(e) {
var offset = $container.offset();
var relativeY = ((e.pageY - offset.top) * multiplier) - ($container.data("origHeight") * multiplier);
if (relativeY > $container.data("origHeight")) {
$list.css("top", -relativeY + $container.data("origHeight"));
}
});
}
}, function() {
var $el = $(this);
$el
.height($(this).data("origHeight"))
.find("ul")
.css({ top: 0 })
.hide()
.end()
.find("a")
.removeClass("hover");
});
});
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.