Browse Source

Merge pull request #938 from aendrew/fixing_924

Adds c3_chart_internal_fn.isTabVisible to disable transitions on inactive tabs. Fixes #924.
pull/929/head
Masayuki Tanaka 10 years ago
parent
commit
8c8edf6d51
  1. 17
      src/core.js

17
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 = [];
@ -951,3 +951,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;
};

Loading…
Cancel
Save