diff --git a/draftlogs/6528_fix.md b/draftlogs/6528_fix.md new file mode 100644 index 00000000000..cbd5a6baab9 --- /dev/null +++ b/draftlogs/6528_fix.md @@ -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)] \ No newline at end of file diff --git a/src/components/legend/draw.js b/src/components/legend/draw.js index abbced80002..9f000a6c26c 100644 --- a/src/components/legend/draw.js +++ b/src/components/legend/draw.js @@ -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) {