Is there a way to stop to text from being selected when the drag behavior is turned off in a force directed graph?
The drag behavior is turned off using these lines:
svg.selectAll('g.gnode')
.on('mousedown.drag', null);
The pointer remains a pointer, rather than a cursor (as per the answer to this question). But dragging still ends up changing the pointer to a cursor and starts to select text. Is there a way to avoid this so no text is selected when dragging?
Using the answer to this question seems to do the trick. This requires adding the following definition to the css file:
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
And adding the noselect
class to the gnodes:
var gnodes = svg.selectAll('g.gnode')
.data(graph.nodes)
.enter()
.append('g')
.classed('gnode', true)
.classed('noselect', true)
.call(force.drag);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments