Skip to content

Commit

Permalink
Merge pull request #6528 from bmaranville/fix-drag-legend
Browse files Browse the repository at this point in the history
fix for incorrect final position when dragging legend
  • Loading branch information
archmoj committed Mar 17, 2023
2 parents a19f685 + 23263f2 commit 7a77f1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions draftlogs/6528_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix dragging of legend when xanchor is not 'left' or yanchor is not 'top' [[#6528](https://github.com/plotly/plotly.js/pull/6528)]
5 changes: 2 additions & 3 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ function _draw(gd, legendObj) {
var newY = y0 + dy;

Drawing.setTranslate(legend, newX, newY);

xf = dragElement.align(newX, 0, gs.l, gs.l + gs.w, legendObj.xanchor);
yf = dragElement.align(newY, 0, gs.t + gs.h, gs.t, legendObj.yanchor);
xf = dragElement.align(newX, legendObj._width, gs.l, gs.l + gs.w, legendObj.xanchor);
yf = dragElement.align(newY + legendObj._height, -legendObj._height, gs.t + gs.h, gs.t, legendObj.yanchor);
},
doneFn: function() {
if(xf !== undefined && yf !== undefined) {
Expand Down

0 comments on commit 7a77f1d

Please sign in to comment.