svgdotjs / svg.panzoom.js

A plugin for svg.js which enables panzoom for viewbox elements
MIT License
93 stars 54 forks source link

Select text and copy #102

Open pedrojfds opened 5 months ago

pedrojfds commented 5 months ago

After adding panZoom to the SVG, selecting and copying text within the SVG becomes disabled. Although the cursor appears as a text cursor upon hovering, clicking is captured, preventing text selection. Is it possible to disable pointer capture when hovering over text?

Fuzzyma commented 5 months ago

That would lead to weird behavior. You would zoom in and all of a sudden the zoom doesn't work anymore because you happen to hover text on accident.

If you want that anyway you can Try to prevent propagation on the text elements

pedrojfds commented 5 months ago

The idea would be to not allow the pan to start on top of those text elements (since the mouse would be used for the selection), but once the pan is initiated, it wouldn't matter where the pointer is. Regarding the zoom, it is performed with the wheel. It shouldn't interfere with the text selection since there is no mouse capture with the wheel, is there?

Fuzzyma commented 5 months ago

I think for that to work you could actually just go ahead and stop propagation for all text elements.

It could be worth to add this as an option. In that case we would need to filter out mousedown events that origin from a text, tspan or textPath. Feel free to implement that and send a PR :)