Skip to content

Commit dbaf340

Browse files
committed
make user-select-none CSS class:
- use it in legend text - rm now useless user-select purge step in to-svg
1 parent 860e647 commit dbaf340

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

build/plotcss.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var rules = {
88
"X a": "text-decoration:none;",
99
"X a:hover": "text-decoration:none;",
1010
"X .crisp": "shape-rendering:crispEdges;",
11+
"X .user-select-none": "-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;",
1112
"X svg": "overflow:hidden;",
1213
"X svg a": "fill:#447adb;",
1314
"X svg a:hover": "fill:#3c6dc5;",

src/components/legend/draw.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,8 @@ function drawTexts(context, gd, d, i, traces) {
336336
y: 0,
337337
'data-unformatted': name
338338
})
339-
.style({
340-
'text-anchor': 'start',
341-
'-webkit-user-select': 'none',
342-
'-moz-user-select': 'none',
343-
'-ms-user-select': 'none',
344-
'user-select': 'none'
345-
})
339+
.style('text-anchor', 'start')
340+
.classed('user-select-none', true)
346341
.call(Drawing.font, fullLayout.legend.font)
347342
.text(name);
348343

src/css/_base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ a {
2222

2323
.crisp { shape-rendering: crispEdges; }
2424

25+
.user-select-none {
26+
@include vendor('user-select', none);
27+
}
28+
2529
//Required for IE11. Other browsers set this by default.
2630
svg { overflow: hidden; }
2731

src/snapshot/tosvg.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,7 @@ module.exports = function toSVG(gd, format) {
107107
svg.node().style.background = '';
108108

109109
svg.selectAll('text')
110-
.attr({'data-unformatted': null})
111-
.style({
112-
'-webkit-user-select': null,
113-
'-moz-user-select': null,
114-
'-ms-user-select': null
115-
})
110+
.attr('data-unformatted', null)
116111
.each(function() {
117112
// hidden text is pre-formatting mathjax, the browser ignores it but it can still confuse batik
118113
var txt = d3.select(this);

0 commit comments

Comments
 (0)