fix: prevent cutting off overlay

This commit is contained in:
Christoph Rohrer 2024-01-09 11:50:27 +01:00
parent 6261f17561
commit cca4cf3574
2 changed files with 11 additions and 3 deletions

View File

@ -198,7 +198,8 @@
}
#stylePreviewOverlay {
display: none;
opacity: 0;
pointer-events: none;
width: 128px;
height: 128px;
position: fixed;
@ -208,6 +209,12 @@
transform: translate(-140px, 20px);
background-size: cover;
background-position: center;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 5px;
z-index: 100;
transition: transform 0.1s ease, opacity 0.3s ease;
}
#stylePreviewOverlay.lower-half {
transform: translate(-140px, -140px);
}

View File

@ -158,7 +158,7 @@ function initStylePreviewOverlay() {
label.removeEventListener("mouseout", onMouseLeave);
label.addEventListener("mouseout", onMouseLeave);
overlayVisible = true;
overlay.style.display = "block";
overlay.style.opacity = "1";
const originalText = label.querySelector("span").getAttribute("data-original-text");
const name = originalText || label.querySelector("span").textContent;
overlay.style.backgroundImage = `url("${samplesPath.replace(
@ -167,7 +167,7 @@ function initStylePreviewOverlay() {
).replaceAll("\\", "\\\\")}")`;
function onMouseLeave() {
overlayVisible = false;
overlay.style.display = "none";
overlay.style.opacity = "0";
overlay.style.backgroundImage = "";
label.removeEventListener("mouseout", onMouseLeave);
}
@ -176,6 +176,7 @@ function initStylePreviewOverlay() {
if(!overlayVisible) return;
overlay.style.left = `${e.clientX}px`;
overlay.style.top = `${e.clientY}px`;
overlay.className = e.clientY > window.innerHeight / 2 ? "lower-half" : "upper-half";
});
}