Browse Source

Merge pull request #860 from denisvmedia/master

Calling resize on each and every window resize drammatically slows down the browser
pull/1207/head
Masayuki Tanaka 10 years ago
parent
commit
22fcf44d88
  1. 1
      src/config.js
  2. 14
      src/core.js

1
src/config.js

@ -7,6 +7,7 @@ c3_chart_internal_fn.getDefaultConfig = function () {
padding_right: undefined, padding_right: undefined,
padding_top: undefined, padding_top: undefined,
padding_bottom: undefined, padding_bottom: undefined,
resize_auto: true,
zoom_enabled: false, zoom_enabled: false,
zoom_extent: undefined, zoom_extent: undefined,
zoom_privileged: false, zoom_privileged: false,

14
src/core.js

@ -324,12 +324,20 @@ c3_chart_internal_fn.initWithData = function (data) {
window.onresize = $$.generateResize(); window.onresize = $$.generateResize();
} }
if (window.onresize.add) { if (window.onresize.add) {
var timeout;
window.onresize.add(function () { window.onresize.add(function () {
config.onresize.call($$); config.onresize.call($$);
}); });
window.onresize.add(function () { if (config.resize_auto) {
$$.api.flush(); window.onresize.add(function () {
}); if (timeout !== undefined) {
clearTimeout(timeout);
}
timeout = setTimeout(function () {
$$.api.flush();
}, 100);
});
}
window.onresize.add(function () { window.onresize.add(function () {
config.onresized.call($$); config.onresized.call($$);
}); });

Loading…
Cancel
Save