This commit is contained in:
dekun
2026-05-27 15:02:34 +08:00
parent ebbb26b520
commit 62ed43cc5f
+23
View File
@@ -219,6 +219,20 @@
targetCtx.restore(); targetCtx.restore();
} }
function drawDragGuideLine(targetCtx, y, color) {
const w = targetCtx.canvas.width;
targetCtx.save();
targetCtx.strokeStyle = color;
targetCtx.lineWidth = 1.5;
targetCtx.setLineDash([10, 6]);
targetCtx.globalAlpha = 0.9;
targetCtx.beginPath();
targetCtx.moveTo(0, y);
targetCtx.lineTo(w, y);
targetCtx.stroke();
targetCtx.restore();
}
function redraw() { function redraw() {
if (!imageLoaded) return; if (!imageLoaded) return;
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
@@ -233,6 +247,11 @@
i === selectedIndex i === selectedIndex
); );
}); });
if (isDraggingMarker && dragIndex >= 0) {
const dragging = markers[dragIndex];
const p = ratioToXY(dragging);
drawDragGuideLine(ctx, p.y, dragging.color);
}
} }
function updateZoomLabel() { function updateZoomLabel() {
@@ -659,10 +678,14 @@
} }
function endPointer() { function endPointer() {
const wasDraggingMarker = isDraggingMarker;
endPan(); endPan();
isDraggingMarker = false; isDraggingMarker = false;
dragIndex = -1; dragIndex = -1;
canvas.classList.remove("can-drag", "can-pan"); canvas.classList.remove("can-drag", "can-pan");
if (wasDraggingMarker && imageLoaded) {
redraw();
}
} }
canvas.addEventListener("mouseup", function () { canvas.addEventListener("mouseup", function () {