|
1 |
| -/* @license C3.js v0.6.8 | (c) C3 Team and other contributors | http://c3js.org/ */ |
| 1 | +/* @license C3.js v0.6.9 | (c) C3 Team and other contributors | http://c3js.org/ */ |
2 | 2 | (function (global, factory) {
|
3 | 3 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
4 | 4 | typeof define === 'function' && define.amd ? define(factory) :
|
|
1147 | 1147 | };
|
1148 | 1148 |
|
1149 | 1149 | var c3 = {
|
1150 |
| - version: "0.6.8", |
| 1150 | + version: "0.6.9", |
1151 | 1151 | chart: {
|
1152 | 1152 | fn: Chart.prototype,
|
1153 | 1153 | internal: {
|
|
1449 | 1449 | withUpdateOrgXDomain: true,
|
1450 | 1450 | withTransitionForAxis: false
|
1451 | 1451 | });
|
1452 |
| - } // Bind resize event |
| 1452 | + } // Bind to resize event |
1453 | 1453 |
|
1454 | 1454 |
|
1455 |
| - $$.bindResize(); // export element of the chart |
| 1455 | + $$.bindResize(); // Bind to window focus event |
| 1456 | + |
| 1457 | + $$.bindWindowFocus(); // export element of the chart |
1456 | 1458 |
|
1457 | 1459 | $$.api.element = $$.selectChart.node();
|
1458 | 1460 | };
|
|
2095 | 2097 | characterData: true
|
2096 | 2098 | });
|
2097 | 2099 | };
|
| 2100 | + /** |
| 2101 | + * Binds handlers to the window resize event. |
| 2102 | + */ |
| 2103 | + |
2098 | 2104 |
|
2099 | 2105 | ChartInternal.prototype.bindResize = function () {
|
2100 | 2106 | var $$ = this,
|
|
2171 | 2177 | };
|
2172 | 2178 | }
|
2173 | 2179 | };
|
| 2180 | + /** |
| 2181 | + * Binds handlers to the window focus event. |
| 2182 | + */ |
| 2183 | + |
| 2184 | + |
| 2185 | + ChartInternal.prototype.bindWindowFocus = function () { |
| 2186 | + var _this = this; |
| 2187 | + |
| 2188 | + if (this.windowFocusHandler) { |
| 2189 | + // The handler is already set |
| 2190 | + return; |
| 2191 | + } |
| 2192 | + |
| 2193 | + this.windowFocusHandler = function () { |
| 2194 | + _this.redraw(); |
| 2195 | + }; |
| 2196 | + |
| 2197 | + window.addEventListener('focus', this.windowFocusHandler); |
| 2198 | + }; |
| 2199 | + /** |
| 2200 | + * Unbinds from the window focus event. |
| 2201 | + */ |
| 2202 | + |
| 2203 | + |
| 2204 | + ChartInternal.prototype.unbindWindowFocus = function () { |
| 2205 | + window.removeEventListener('focus', this.windowFocusHandler); |
| 2206 | + delete this.windowFocusHandler; |
| 2207 | + }; |
2174 | 2208 |
|
2175 | 2209 | ChartInternal.prototype.generateResize = function () {
|
2176 | 2210 | var resizeFunctions = [];
|
|
2265 | 2299 | };
|
2266 | 2300 |
|
2267 | 2301 | ChartInternal.prototype.isTabVisible = function () {
|
2268 |
| - var hidden; |
2269 |
| - |
2270 |
| - if (typeof document.hidden !== "undefined") { |
2271 |
| - // Opera 12.10 and Firefox 18 and later support |
2272 |
| - hidden = "hidden"; |
2273 |
| - } else if (typeof document.mozHidden !== "undefined") { |
2274 |
| - hidden = "mozHidden"; |
2275 |
| - } else if (typeof document.msHidden !== "undefined") { |
2276 |
| - hidden = "msHidden"; |
2277 |
| - } else if (typeof document.webkitHidden !== "undefined") { |
2278 |
| - hidden = "webkitHidden"; |
2279 |
| - } |
2280 |
| - |
2281 |
| - return document[hidden] ? false : true; |
| 2302 | + return !document.hidden; |
2282 | 2303 | };
|
2283 | 2304 |
|
2284 | 2305 | ChartInternal.prototype.getPathBox = getPathBox;
|
|
4258 | 4279 | if (wrapper && wrapper.add && wrapper.remove) {
|
4259 | 4280 | wrapper.remove($$.resizeFunction);
|
4260 | 4281 | }
|
4261 |
| - } // remove the inner resize functions |
| 4282 | + } // Removes the inner resize functions |
| 4283 | + |
4262 | 4284 |
|
| 4285 | + $$.resizeFunction.remove(); // Unbinds from the window focus event |
4263 | 4286 |
|
4264 |
| - $$.resizeFunction.remove(); |
| 4287 | + $$.unbindWindowFocus(); |
4265 | 4288 | $$.selectChart.classed('c3', false).html(""); // MEMO: this is needed because the reference of some elements will not be released, then memory leak will happen.
|
4266 | 4289 |
|
4267 | 4290 | Object.keys($$).forEach(function (key) {
|
|
4856 | 4879 | classes,
|
4857 | 4880 | regions;
|
4858 | 4881 | options = options || {};
|
4859 |
| - duration = $$.getOption(options, "duration", config.transition_duration); |
4860 |
| - classes = $$.getOption(options, "classes", [CLASS.region]); |
| 4882 | + duration = getOption(options, "duration", config.transition_duration); |
| 4883 | + classes = getOption(options, "classes", [CLASS.region]); |
4861 | 4884 | regions = $$.main.select('.' + CLASS.regions).selectAll(classes.map(function (c) {
|
4862 | 4885 | return '.' + c;
|
4863 | 4886 | }));
|
|
0 commit comments