Skip to content

Commit 65f0213

Browse files
committed
correct exit case of zoom out when maxdepth is set - avoid overlaps and flashing
1 parent 57dec38 commit 65f0213

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/traces/treemap/plot.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,23 @@ function plotOne(gd, cd, element, transitionOpts) {
105105
} else {
106106
var ref = clicked.zoomOut ? refRect : prevLookdown[clicked.id] || prevLookup[clicked.id];
107107

108-
var e = trace.tiling.pad;
109-
var isLeftOfRect = function(x) { return x - e <= ref.x0; };
110-
var isRightOfRect = function(x) { return x + e >= ref.x1; };
111-
var isBottomOfRect = function(y) { return y - e <= ref.y0; };
112-
var isTopOfRect = function(y) { return y + e >= ref.y1; };
113-
114-
x0 = isLeftOfRect(pt.x0 - e) ? 0 : isRightOfRect(pt.x0 - e) ? width : pt.x0;
115-
x1 = isLeftOfRect(pt.x1 + e) ? 0 : isRightOfRect(pt.x1 + e) ? width : pt.x1;
116-
y0 = isBottomOfRect(pt.y0 - e) ? 0 : isTopOfRect(pt.y0 - e) ? height : pt.y0;
117-
y1 = isBottomOfRect(pt.y1 + e) ? 0 : isTopOfRect(pt.y1 + e) ? height : pt.y1;
108+
if(Object.keys(ref).length === 0 && // case of an empty object - happens when maxdepth is set
109+
!helpers.isHierarchyRoot(pt)
110+
) {
111+
x0 = x1 = (pt.x0 + pt.x1) / 2;
112+
y0 = y1 = (pt.y0 + pt.y1) / 2;
113+
} else {
114+
var e = trace.tiling.pad;
115+
var isLeftOfRect = function(x) { return x - e <= ref.x0; };
116+
var isRightOfRect = function(x) { return x + e >= ref.x1; };
117+
var isBottomOfRect = function(y) { return y - e <= ref.y0; };
118+
var isTopOfRect = function(y) { return y + e >= ref.y1; };
119+
120+
x0 = isLeftOfRect(pt.x0 - e) ? 0 : isRightOfRect(pt.x0 - e) ? width : pt.x0;
121+
x1 = isLeftOfRect(pt.x1 + e) ? 0 : isRightOfRect(pt.x1 + e) ? width : pt.x1;
122+
y0 = isBottomOfRect(pt.y0 - e) ? 0 : isTopOfRect(pt.y0 - e) ? height : pt.y0;
123+
y1 = isBottomOfRect(pt.y1 + e) ? 0 : isTopOfRect(pt.y1 + e) ? height : pt.y1;
124+
}
118125
}
119126

120127
return {

0 commit comments

Comments
 (0)