diff --git a/public/js/app.js b/public/js/app.js index f2ac6ee..36ba370 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -219,6 +219,20 @@ 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() { if (!imageLoaded) return; ctx.clearRect(0, 0, canvas.width, canvas.height); @@ -233,6 +247,11 @@ i === selectedIndex ); }); + if (isDraggingMarker && dragIndex >= 0) { + const dragging = markers[dragIndex]; + const p = ratioToXY(dragging); + drawDragGuideLine(ctx, p.y, dragging.color); + } } function updateZoomLabel() { @@ -659,10 +678,14 @@ } function endPointer() { + const wasDraggingMarker = isDraggingMarker; endPan(); isDraggingMarker = false; dragIndex = -1; canvas.classList.remove("can-drag", "can-pan"); + if (wasDraggingMarker && imageLoaded) { + redraw(); + } } canvas.addEventListener("mouseup", function () {