Skip to content

Commit 7a77f1d

Browse files
authored
Merge pull request #6528 from bmaranville/fix-drag-legend
fix for incorrect final position when dragging legend
2 parents a19f685 + 23263f2 commit 7a77f1d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

draftlogs/6528_fix.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- fix dragging of legend when xanchor is not 'left' or yanchor is not 'top' [[#6528](https://github.com/plotly/plotly.js/pull/6528)]

src/components/legend/draw.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,8 @@ function _draw(gd, legendObj) {
325325
var newY = y0 + dy;
326326

327327
Drawing.setTranslate(legend, newX, newY);
328-
329-
xf = dragElement.align(newX, 0, gs.l, gs.l + gs.w, legendObj.xanchor);
330-
yf = dragElement.align(newY, 0, gs.t + gs.h, gs.t, legendObj.yanchor);
328+
xf = dragElement.align(newX, legendObj._width, gs.l, gs.l + gs.w, legendObj.xanchor);
329+
yf = dragElement.align(newY + legendObj._height, -legendObj._height, gs.t + gs.h, gs.t, legendObj.yanchor);
331330
},
332331
doneFn: function() {
333332
if(xf !== undefined && yf !== undefined) {

0 commit comments

Comments
 (0)