Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jan 26, 2015

Conversation

aendra-rininsland
Copy link
Member

This adds a new function, c3_chart_internal_fn.isTabVisible, which uses the Page Visibility API to return whether the page is inactive or not. I've then called it c3_chart_internal_fn.redraw() on line 614 of src/core.js, which short-circuits the conditional and renders the chart without using d3.transition (which uses the requestAnimationFrame API, which doesn't work on inactive tabs) if the chart's browser tab is inactive.

See #924.

masayuki0812 added a commit that referenced this pull request Jan 26, 2015
Adds c3_chart_internal_fn.isTabVisible to disable transitions on inactive tabs. Fixes #924.
@masayuki0812 masayuki0812 merged commit 8c8edf6 into c3js:master Jan 26, 2015
@masayuki0812
Copy link
Member

Looks nice. Thanks!

@aendra-rininsland
Copy link
Member Author

Yay! Thanks! 👍 :shipit:

@aendra-rininsland aendra-rininsland deleted the fixing_924 branch January 26, 2015 11:09
@ergo
Copy link

ergo commented Jan 26, 2015

I have serious doubts if this is a proper fix for the issue, after all it should not leak and GC correctly regardless of visibility?

@aendra-rininsland
Copy link
Member Author

@ergo The GC and memory leak issue is a separate one; I totally agree this is not the fix for that. This is merely to resolve the issue with requestAnimationFrame not firing in inactive tabs, resulting in the chart not rendering if c3.generate() is called in an inactive tab.

@masayuki0812
Copy link
Member

@ergo Yeah, this does not fix the #926 , but seems making the speed of leak slower like 0.4.8 as you reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants