Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
Clean up thumbnailhover.js
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Jul 3, 2016
1 parent ed71ae7 commit 296eba2
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions resources/assets/js/thumbnailhover.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@
// https://stackoverflow.com/questions/16289159/how-to-show-image-preview-on-thumbnail-hover

this.imagePreview = function () {
/* CONFIG */

xOffset = 15;
yOffset = 30;
var xOffset = 15;
var yOffset = 30;

// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
var Mx = $(document).width();
var My = $(document).height();

/* END CONFIG */
var callback = function (event) {
var $img = $("#preview");

// top-right corner coords' offset
var trc_x = xOffset + $img.width();
var trc_y = yOffset + $img.height();

Expand All @@ -38,25 +33,22 @@ this.imagePreview = function () {
};

$("a.preview").hover(function (e) {
Mx = $(document).width();
My = $(document).height();

this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='preview'><img src='" + this.href + "' alt='Preview' />" + c + "</p>");
callback(e);
$("#preview").fadeIn("fast");
},
function () {
this.title = this.t;
$("#preview").remove();
}
).mousemove(callback);
Mx = $(document).width();
My = $(document).height();

this.t = this.title;
this.title = "";
var c = (this.t != "") ? "<br/>" + this.t : "";
$("body").append("<p id='preview'><img src='" + this.href + "' alt='Preview' />" + c + "</p>");
callback(e);
$("#preview").fadeIn("fast");
},
function () {
this.title = this.t;
$("#preview").remove();
}).mousemove(callback);
};


// starting the script on page load
$(document).ready(function () {
imagePreview();
});

0 comments on commit 296eba2

Please sign in to comment.