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. 8
      src/core.js

1
src/config.js

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

8
src/core.js

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

Loading…
Cancel
Save