diff --git a/src/core.js b/src/core.js index 68ed6fa..234f3c8 100644 --- a/src/core.js +++ b/src/core.js @@ -611,7 +611,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) { }); } - if (duration) { + if (duration && $$.isTabVisible()) { // Only use transition if tab visible. See #938. // transition should be derived from one transition d3.transition().duration(duration).each(function () { var transitionsToWait = []; @@ -948,3 +948,18 @@ c3_chart_internal_fn.parseDate = function (date) { } return parsedDate; }; + +c3_chart_internal_fn.isTabVisible = function () { + var hidden; + if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support + hidden = "hidden"; + } else if (typeof document.mozHidden !== "undefined") { + hidden = "mozHidden"; + } else if (typeof document.msHidden !== "undefined") { + hidden = "msHidden"; + } else if (typeof document.webkitHidden !== "undefined") { + hidden = "webkitHidden"; + } + + return document[hidden] ? false : true; +};