Skip to content

Commit 1262172

Browse files
committed
clear responsive handlers in Plotly.plot if needed
1 parent ec9ffa1 commit 1262172

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/plot_api/plot_api.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,16 @@ exports.plot = function(gd, data, layout, config) {
192192
}
193193

194194
// make the figure responsive
195-
if(gd._context.responsive && !gd._responsiveChartHandler) {
196-
// Keep a reference to the resize handler to purge it down the road
197-
gd._responsiveChartHandler = function() {Plots.resize(gd);};
195+
if(gd._context.responsive) {
196+
if(!gd._responsiveChartHandler) {
197+
// Keep a reference to the resize handler to purge it down the road
198+
gd._responsiveChartHandler = function() {Plots.resize(gd);};
198199

199-
// Listen to window resize
200-
window.addEventListener('resize', gd._responsiveChartHandler);
200+
// Listen to window resize
201+
window.addEventListener('resize', gd._responsiveChartHandler);
202+
}
203+
} else {
204+
Lib.clearResponsive(gd);
201205
}
202206

203207
/*
@@ -2243,9 +2247,6 @@ exports.react = function(gd, data, layout, config) {
22432247
gd._context = undefined;
22442248
setPlotContext(gd, config);
22452249
configChanged = diffConfig(oldConfig, gd._context);
2246-
2247-
// remove responsive handler
2248-
Lib.clearResponsive(gd);
22492250
}
22502251

22512252
gd.data = data || [];

0 commit comments

Comments
 (0)