Skip to content

@johnboxall /jquery.pop.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
;(function($) {
$.fn.pop = function(options) {
var defaults = {
distance: 10,
time: 250,
delay: 500,
// pop: selector or element to show when this is hovered over
};
var s = $.extend(defaults, options);
return this.each(function() {
var hideDelayTimer = false,
beingShown = false,
shown = false;
$(this).mouseover(function() {
if (hideDelayTimer)
clearTimeout(hideDelayTimer);
if (beingShown || shown) {
return;
} else {
beingShown = true;
var doneMouseOver = function() {
beingShown = false;
shown = true
};
var offset = $(this).offset();
$(s.pop)
.show()
.css({position: "absolute",
top: offset.top - $(this).height() - $(s.pop).height(),
left: offset.left})
.animate({top: '-='+s.distance+'px', opacity:1}, s.time, 'swing', doneMouseOver);
}
}).mouseout(function() {
if (hideDelayTimer)
clearTimeout(hideDelayTimer);
var doneMouseOut = function() {
shown = false;
$(s.pop).hide();
};
hideDelayTimer = setTimeout(function() {
hideDelayTimer = false;
$(s.pop).animate({top:'-='+s.distance+'px', opacity: 0}, s.time, 'swing', doneMouseOut)
}, s.delay);
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.