问题
I've setup a drawing utility with Raphael.js. The user can draw shapes, paths and enter text. Once a user adds text -> Paper.text() to the svg the svg goes into a selectable state. Meaning, if I add text and switch to the pen tool, moving the pen around the svg will cause adjacent dom elements to go into their ::selection state.
So I'd like to convert the text to a path to prevent this from happening. I don't see anything like this in the documentation.
回答1:
if you use print() instead of text() for text printing, then the text will be a raphael path object. (print() use a cufon javascript font that renders to a raphael path).
回答2:
Try tweaking the pointer-events
property on the text elements with .attr()
. none
might fit your needs. There are some good background info links on MDN.
.attr({pointer-events: none})
来源:https://stackoverflow.com/questions/9702976/raphael-js-convert-text-to-path