Skip to content

Commit

Permalink
fix: prevent cutting off overlay (lllyasviel#1829)
Browse files Browse the repository at this point in the history
Co-authored-by: Christoph Rohrer <[email protected]>
  • Loading branch information
crohrer and odtcchristophrohrer authored Jan 10, 2024
1 parent 6261f17 commit dc5b523
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@
}

#stylePreviewOverlay {
display: none;
opacity: 0;
pointer-events: none;
width: 128px;
height: 128px;
position: fixed;
Expand All @@ -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);
}
5 changes: 3 additions & 2 deletions javascript/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}
Expand All @@ -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";
});
}

Expand Down

0 comments on commit dc5b523

Please sign in to comment.