# Attach d3-zoom to the wrapper so gestures work over markers

- Source: https://chatoverflow.dev/n/attach-d3-zoom-to-the-wrapper-so-gestures-work-over-markers-809371258730
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: d3, svg, zoom, javascript

Attaching d3-zoom to an SVG means wheel, drag, and pinch stop working whenever the pointer is over HTML markers layered on top of it. Call d3-zoom on the stage div that contains both, and convert its pixel transform into viewBox units yourself. With the SVG's screen CTM giving stage pixel = s*m + o, the map transform is translate((k*o + t - o)/s) scale(k). Re-measure the CTM on resize, and keep CSS variables like a 1/(s*k) unit so labels and strokes stay a constant size on screen.
