From a3f9e986b4e554c8b10c08b8cabf2aaec238ac7a Mon Sep 17 00:00:00 2001 From: Denis V Date: Sat, 3 Jan 2015 11:07:38 +0100 Subject: [PATCH 1/3] Calling resize on each and every window resize drammatically slows down the browser #857 --- src/config.js | 1 + src/core.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/config.js b/src/config.js index a53f879..2a01712 100644 --- a/src/config.js +++ b/src/config.js @@ -7,6 +7,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { padding_right: undefined, padding_top: undefined, padding_bottom: undefined, + auto_resize: true, zoom_enabled: false, zoom_extent: undefined, zoom_privileged: false, diff --git a/src/core.js b/src/core.js index 4f75449..a7a29a6 100644 --- a/src/core.js +++ b/src/core.js @@ -288,12 +288,20 @@ c3_chart_internal_fn.initWithData = function (data) { window.onresize = $$.generateResize(); } if (window.onresize.add) { + var timeout; window.onresize.add(function () { config.onresize.call($$); }); - window.onresize.add(function () { - $$.api.flush(); - }); + if (config.auto_resize) { + window.onresize.add(function () { + if (timeout !== undefined) { + clearTimeout(timeout); + } + timeout = setTimeout(function () { + $$.api.flush(); + }, 100); + }); + } window.onresize.add(function () { config.onresized.call($$); }); From 45b8dcc7d873b6d5ee91cbac34a86c5f95966c99 Mon Sep 17 00:00:00 2001 From: Denis Voytyuk Date: Wed, 14 Jan 2015 19:39:24 +0100 Subject: [PATCH 2/3] Rename resize_auto to auto_resize --- src/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index 2a01712..f373e67 100644 --- a/src/config.js +++ b/src/config.js @@ -7,7 +7,7 @@ c3_chart_internal_fn.getDefaultConfig = function () { padding_right: undefined, padding_top: undefined, padding_bottom: undefined, - auto_resize: true, + resize_auto: true, zoom_enabled: false, zoom_extent: undefined, zoom_privileged: false, From 6e9747101b74be8f001dff7aab053409a5b333ee Mon Sep 17 00:00:00 2001 From: Denis Voytyuk Date: Wed, 14 Jan 2015 19:40:16 +0100 Subject: [PATCH 3/3] Rename auto_resize to resize_auto --- src/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.js b/src/core.js index a7a29a6..8cb1c22 100644 --- a/src/core.js +++ b/src/core.js @@ -292,7 +292,7 @@ c3_chart_internal_fn.initWithData = function (data) { window.onresize.add(function () { config.onresize.call($$); }); - if (config.auto_resize) { + if (config.resize_auto) { window.onresize.add(function () { if (timeout !== undefined) { clearTimeout(timeout);