Commit 22fcf44d authored by Masayuki Tanaka's avatar Masayuki Tanaka

Merge pull request #860 from denisvmedia/master

Calling resize on each and every window resize drammatically slows down the browser
parents ae26e98e 6e974710
...@@ -7,6 +7,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { ...@@ -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,
......
...@@ -324,12 +324,20 @@ c3_chart_internal_fn.initWithData = function (data) { ...@@ -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($$);
}); });
if (config.resize_auto) {
window.onresize.add(function () { window.onresize.add(function () {
if (timeout !== undefined) {
clearTimeout(timeout);
}
timeout = setTimeout(function () {
$$.api.flush(); $$.api.flush();
}, 100);
}); });
}
window.onresize.add(function () { window.onresize.add(function () {
config.onresized.call($$); config.onresized.call($$);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment