Browse Source

Added c3_chart_internal_fn.isTabVisible to disable transitions on inactive tabs. Fixes #924.

pull/938/head
Ændrew Rininsland 10 years ago
parent
commit
a4c5b7abda
  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 // transition should be derived from one transition
d3.transition().duration(duration).each(function () { d3.transition().duration(duration).each(function () {
var transitionsToWait = []; var transitionsToWait = [];
@ -948,3 +948,18 @@ c3_chart_internal_fn.parseDate = function (date) {
} }
return parsedDate; 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