Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2edc9cd

Browse files
committed
handle placeholder case in scootTitle
1 parent 0be79e2 commit 2edc9cd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/components/titles/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,19 @@ Titles.draw = function(gd, titleClass, options) {
136136
shiftSign = (['left','top'].indexOf(avoid.side) !== -1) ?
137137
-1 : 1,
138138
pad = isNumeric(avoid.pad) ? avoid.pad : 2,
139-
titlebb = Drawing.bBox(titleGroup.node()),
140139
paperbb = {
141140
left: 0,
142141
top: 0,
143142
right: fullLayout.width,
144143
bottom: fullLayout.height
145-
},
146-
maxshift = avoid.maxShift || (
147-
(paperbb[avoid.side]-titlebb[avoid.side]) *
148-
((avoid.side === 'left' || avoid.side === 'top') ? -1 : 1));
144+
};
145+
146+
var titlebb = titleGroup.node() ? Drawing.bBox(titleGroup.node()) : {};
147+
148+
var maxshift = avoid.maxShift || (
149+
(paperbb[avoid.side]-titlebb[avoid.side]) *
150+
((avoid.side === 'left' || avoid.side === 'top') ? -1 : 1));
151+
149152
// Prevent the title going off the paper
150153
if(maxshift < 0) shift = maxshift;
151154
else {
@@ -224,5 +227,6 @@ Titles.draw = function(gd, titleClass, options) {
224227
else if(!txt || txt.match(/Click to enter .+ title/)) {
225228
el.remove();
226229
}
230+
227231
el.classed('js-placeholder', isplaceholder);
228232
};

0 commit comments

Comments
 (0)