Skip to content

Instantly share code, notes, and snippets.

@komapa
Created July 12, 2010 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komapa/472418 to your computer and use it in GitHub Desktop.
Save komapa/472418 to your computer and use it in GitHub Desktop.
$.fn.autohop.imagePreview = function()
{
xOffset = 10;
yOffset = 30;
$("a.preview").hover(
function(e)
{
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='preview'><img src='"+ this.rel +"' alt='' />"+ c +"</p>");
$("#preview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").fadeIn("fast");
},
function()
{
this.title = this.t;
$("#preview").remove();
}
);
$("a.preview").mousemove(function(e)
{
$("#preview").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px");
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment