diff --git a/resources/js/Components/MetroMap/MetroCanvas.vue b/resources/js/Components/MetroMap/MetroCanvas.vue index 9a5601b..2d4774d 100644 --- a/resources/js/Components/MetroMap/MetroCanvas.vue +++ b/resources/js/Components/MetroMap/MetroCanvas.vue @@ -266,12 +266,13 @@ const initCanvas = () => { // --------------------------------------------------------------------------- const handleZoom = (event) => { - if (isCommitting) return - const t = event.transform g.attr('transform', t) transform.value = t + // During commit animation, just apply the visual transform — skip threshold logic + if (isCommitting) return + emit('zoom-change', { scale: t.k, x: t.x, y: t.y }) const w = containerRef.value?.clientWidth ?? 800 @@ -385,6 +386,7 @@ const commitDimensionChange = (direction, node) => { /** * Smoothly animate to a fit-to-view transform for the current dimension. * Calculates bounding box of all nodes and zooms to fit them in the viewport. + * The zoom handler stays active but isCommitting guards against threshold logic. */ const animateZoomReset = () => { if (!svg || !zoom) { @@ -399,30 +401,14 @@ const animateZoomReset = () => { const targetDim = currentDimensionData.value const targetTransform = computeFitTransform(targetDim, w, h) - // Temporarily disable the zoom handler to prevent re-entry during animation - svg.on('.zoom', null) + // Render the new dimension immediately so the animation shows correct content + renderMap() svg.transition() .duration(400) .ease(d3.easeCubicOut) .call(zoom.transform, targetTransform) .on('end', () => { - // Re-enable zoom handler - svg.call(zoom) - svg.on('contextmenu', (event) => { - event.preventDefault() - const [x, y] = d3.pointer(event, g.node()) - const clickedNode = findNodeAt(x, y) - contextMenu.value = { - show: true, - x: event.clientX, - y: event.clientY, - type: clickedNode ? 'node' : 'canvas', - node: clickedNode, - canvasX: x, - canvasY: y, - } - }) isCommitting = false renderMap() }) @@ -528,8 +514,8 @@ const renderBranchHandles = (nodeGroup, node, allNodes) => { const targetX = snapToGrid(node.x + b.dx) const targetY = snapToGrid(node.y + b.dy) - // Skip if target position is occupied - if (allNodes.some(n => n.x === targetX && n.y === targetY)) return + // Allow branching to occupied positions — metro interchanges are valid + const occupied = allNodes.some(n => n.x === targetX && n.y === targetY) const rad = (b.deg * Math.PI) / 180 const hx = Math.cos(rad) * HANDLE_DIST @@ -596,7 +582,7 @@ const renderBranchHandles = (nodeGroup, node, allNodes) => { .attr('font-family', "'VT323', monospace") .attr('font-size', '12px') .attr('opacity', 0.5) - .text(b.deg === 0 ? 'extend' : 'fork') + .text(occupied ? 'interchange' : (b.deg === 0 ? 'extend' : 'fork')) }) .on('mouseleave', () => { handleGroup.selectAll('.ghost-preview').remove()