Skip to content

Commit

Permalink
Merge pull request #6997 from OpportunityLiu/fix/legend-scrollbar
Browse files Browse the repository at this point in the history
Fix drag on legend scrollbar while `edits.legendPosition` is `true`
  • Loading branch information
archmoj authored May 15, 2024
2 parents 8b09892 + c40b180 commit c503634
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions draftlogs/6997_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix drag on legend scrollbar while `edits.legendPosition` is `true` [[#6997](https://github.com/plotly/plotly.js/pull/6997)],
with thanks to @OpportunityLiu for the contribution!
17 changes: 11 additions & 6 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,23 @@ function drawOne(gd, opts) {
dragElement.init({
element: legend.node(),
gd: gd,
prepFn: function() {
prepFn: function(e) {
if(e.target === scrollBar.node()) {
return;
}
var transform = Drawing.getTranslate(legend);
x0 = transform.x;
y0 = transform.y;
},
moveFn: function(dx, dy) {
var newX = x0 + dx;
var newY = y0 + dy;
if(x0 !== undefined && y0 !== undefined) {
var newX = x0 + dx;
var newY = y0 + dy;

Drawing.setTranslate(legend, newX, newY);
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);
Drawing.setTranslate(legend, newX, newY);
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 c503634

Please sign in to comment.