aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2022-01-02 08:55:21 +0000
committerr <r@freesoftwareextremist.com>2022-01-02 08:55:21 +0000
commit21ef7a66106958bd61534e5d0603b447e6fe306d (patch)
tree1f454c1294194a6fc41cde953542ced30f0ba852
parent556a87e8e81025559d6009293b1aa4fca4371677 (diff)
downloadbloat-21ef7a66106958bd61534e5d0603b447e6fe306d.tar.gz
bloat-21ef7a66106958bd61534e5d0603b447e6fe306d.zip
Fix image preview position on load event
-rw-r--r--static/fluoride.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/static/fluoride.js b/static/fluoride.js
index f44801b..917ffff 100644
--- a/static/fluoride.js
+++ b/static/fluoride.js
@@ -233,17 +233,21 @@ function setPos(el, cx, cy, mw, mh) {
}
var imgPrev = null;
+var imgX = 0;
+var imgY = 0;
function handleImgPreview(a) {
a.onmouseenter = function(e) {
var mw = document.documentElement.clientWidth;
var mh = document.documentElement.clientHeight - 24;
+ imgX = e.clientX;
+ imgY = e.clientY;
var img = document.createElement("img");
img.id = "img-preview";
img.src = e.target.getAttribute("href");
img.style["max-width"] = mw + "px";
img.style["max-height"] = mh + "px";
img.onload = function(e2) {
- setPos(e2.target, e.clientX, e.clientY, mw, mh);
+ setPos(imgPrev, imgX, imgY, mw, mh);
}
document.body.appendChild(img);
imgPrev = img;
@@ -259,7 +263,9 @@ function handleImgPreview(a) {
return;
var mw = document.documentElement.clientWidth;
var mh = document.documentElement.clientHeight - 24;
- setPos(imgPrev, e.clientX, e.clientY, mw, mh);
+ imgX = e.clientX;
+ imgY = e.clientY;
+ setPos(imgPrev, imgX, imgY, mw, mh);
}
}