Skip to content

Commit 37228be

Browse files
Copilotvolta2030
andcommitted
Fix code review issues: improve animation and dragleave handling
Co-authored-by: volta2030 <65960990+volta2030@users.noreply.github.com>
1 parent 8835bdf commit 37228be

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

imgkit/features/image_layer_events.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,11 @@ class ImageLayerEvents {
239239
});
240240

241241
this.layer.canvas.addEventListener("dragleave", (e) => {
242-
// Remove rotating border animation class
243-
this.layer.panel.classList.remove("drag-border-active");
242+
// Only remove class if drag actually left the canvas (not moving to child element)
243+
// Also handle case where relatedTarget is null (e.g., drag left browser window)
244+
if (!e.relatedTarget || !this.layer.canvas.contains(e.relatedTarget)) {
245+
this.layer.panel.classList.remove("drag-border-active");
246+
}
244247
});
245248

246249
this.layer.canvas.addEventListener("drop", async (e) => {

imgkit/imgpanel.css

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,25 @@
105105

106106
/* Rotating dotted border animation during drag-over */
107107
@keyframes rotating-border {
108-
0% {
109-
background-position: 0 0, 100% 0, 100% 100%, 0 100%;
108+
from {
109+
background-position: 0 0, 100% 100%, 0 100%, 100% 0;
110110
}
111-
100% {
112-
background-position: 100% 0, 100% 100%, 0 100%, 0 0;
111+
to {
112+
background-position: 12px 0, calc(100% - 12px) 100%, 0 calc(100% - 12px),
113+
100% 12px;
113114
}
114115
}
115116

116-
.imgPanel.drag-border-active {
117+
.imgPanel.drag-border-active::before {
118+
content: "";
119+
position: absolute;
120+
top: 0;
121+
left: 0;
122+
right: 0;
123+
bottom: 0;
124+
border-radius: inherit;
125+
pointer-events: none;
126+
z-index: 10;
117127
background-image: linear-gradient(90deg, #666 50%, transparent 50%),
118128
linear-gradient(90deg, #666 50%, transparent 50%),
119129
linear-gradient(0deg, #666 50%, transparent 50%),

0 commit comments

Comments
 (0)