8000 fix drag on legend scrollbar · plotly/plotly.js@263f96d · GitHub
[go: up one dir, main page]

Skip to content

Commit 263f96d

Browse files
fix drag on legend scrollbar
1 parent 8b09892 commit 263f96d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/components/legend/draw.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,18 +423,23 @@ function drawOne(gd, opts) {
423423
dragElement.init({
424424
element: legend.node(),
425425
gd: gd,
426-
prepFn: function() {
426+
prepFn: function(e) {
427+
if(e.target === scrollBar.node()) {
428+
return;
429+
}
427430
var transform = Drawing.getTranslate(legend);
428431
x0 = transform.x;
429432
y0 = transform.y;
430433
},
431434
moveFn: function(dx, dy) {
432-
var newX = x0 + dx;
433-
var newY = y0 + dy;
435+
if(x0 !== undefined && y0 !== undefined) {
436+
var newX = x0 + dx;
437+
var newY = y0 + dy;
434438

435-
Drawing.setTranslate(legend, newX, newY);
436-
xf = dragElement.align(newX, legendObj._width, gs.l, gs.l + gs.w, legendObj.xanchor);
437-
yf = dragElement.align(newY + legendObj._height, -legendObj._height, gs.t + gs.h, gs.t, legendObj.yanchor);
439+
Drawing.setTranslate(legend, newX, newY);
440+
xf = dragElement.align(newX, legendObj._width, gs.l, gs.l + gs.w, legendObj.xanchor);
441+
yf = dragElement.align(newY + legendObj._height, -legendObj._height, gs.t + gs.h, gs.t, legendObj.yanchor);
442+
}
438443
},
439444
doneFn: function() {
440445
if(xf !== undefined && yf !== undefined) {

0 commit comments

Comments
 (0)
0