Skip to content

Commit 913bb68

Browse files
committedJun 18, 2019
move isHidden into Lib
1 parent aed5e44 commit 913bb68

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed
 

‎src/lib/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -1171,3 +1171,8 @@ lib.formatPercent = function(ratio, n) {
11711171
}
11721172
return str;
11731173
};
1174+
1175+
lib.isHidden = function(gd) {
1176+
var display = window.getComputedStyle(gd).display;
1177+
return !display || display === 'none';
1178+
};

‎src/plot_api/plot_api.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,11 @@ function plot(gd, data, layout, config) {
178178
gd.calcdata[i][0].trace = gd._fullData[i];
179179
}
180180

181-
function isHidden(gd) {
182-
var display = window.getComputedStyle(gd).display;
183-
return !display || display === 'none';
184-
}
185181
// make the figure responsive
186182
if(gd._context.responsive) {
187183
if(!gd._responsiveChartHandler) {
188184
// Keep a reference to the resize handler to purge it down the road
189-
gd._responsiveChartHandler = function() { if(!isHidden(gd)) Plots.resize(gd).catch(Lib.noop); };
185+
gd._responsiveChartHandler = function() { if(!Lib.isHidden(gd)) Plots.resize(gd); };
190186

191187
// Listen to window resize
192188
window.addEventListener('resize', gd._responsiveChartHandler);

‎src/plots/plots.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,15 @@ plots.resize = function(gd) {
7575
gd = Lib.getGraphDiv(gd);
7676

7777
return new Promise(function(resolve, reject) {
78-
function isHidden(gd) {
79-
var display = window.getComputedStyle(gd).display;
80-
return !display || display === 'none';
81-
}
82-
83-
if(!gd || isHidden(gd)) {
78+
if(!gd || Lib.isHidden(gd)) {
8479
reject(new Error('Resize must be passed a displayed plot div element.'));
8580
}
8681

8782
if(gd._redrawTimer) clearTimeout(gd._redrawTimer);
8883

8984
gd._redrawTimer = setTimeout(function() {
9085
// return if there is nothing to resize or is hidden
91-
if(!gd.layout || (gd.layout.width && gd.layout.height) || isHidden(gd)) {
86+
if(!gd.layout || (gd.layout.width && gd.layout.height) || Lib.isHidden(gd)) {
9287
resolve(gd);
9388
return;
9489
}

‎tasks/test_syntax.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function assertSrcContents() {
210210
* - If you use conforms to these rules, you may update
211211
* KNOWN_GET_COMPUTED_STYLE_CALLS to count the new use.
212212
*/
213-
var KNOWN_GET_COMPUTED_STYLE_CALLS = 6;
213+
var KNOWN_GET_COMPUTED_STYLE_CALLS = 5;
214214
if(getComputedStyleCnt !== KNOWN_GET_COMPUTED_STYLE_CALLS) {
215215
logs.push('Expected ' + KNOWN_GET_COMPUTED_STYLE_CALLS +
216216
' window.getComputedStyle calls, found ' + getComputedStyleCnt +

0 commit comments

Comments
 (0)
Please sign in to comment.