Jump to content


_doc.visibilityState on node.js

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

i am using TimelineMax in node and occasionally getting this:




I am assuming this is because there is no doc with a visibilityState....


Anyone have any ideas how I could fix this? Ideally without having to modify the gsap source


Link to comment
Share on other sites

Hello @adamco and welcome to the GreenSock forum!


Can you please also give an example of your code, so we can see it in context. It will help others and the GreenSock Team in helping solve your problem to see what your trying to do with GSAP.


Creating a reduced codepen demo example is the best way for us to help you with this.




Happy Tweening :)

Link to comment
Share on other sites

Hi, thanks, a codepen wont replicate this issue because as I said, it is running in a node.js script, but the code is:


var gsap = require('gsap');

var timeline = new TimelineMax({
				//repeat: -1
				onStart: () => {
					console.log('timeline started');

timeline.add(() => { console.log ('test');}, 10 );
timeline.add(() => { console.log ('test');}, 20 );
timeline.add(() => { console.log ('test');}, 30 );
timeline.add(() => { console.log ('test');}, 40 );


It runs fine until the CPU gets under stress and then TweenMax seems to run into that issue where it is looking for a visibilityState on a _doc that doesnt exist.


Link to comment
Share on other sites

Thanks -  I notice the change you made from:

_doc.visibilityState !== "hidden"


((_doc || {}).visibilityState  !== "hidden" 


I suspect that will fix it.  Nice work!


Since I was  only using TimelineMax I ended up changing it so that I only required the TimelineMax module

// var gsap = require('gsap');

// don't need the entire suite, so I'll just require TimelineMax on its own

var TimelineMax = require('./node_modules/gsap/TimelineMax');


So that way there is no TweenMax initialized which I think was an easier fix in my case. 




By the way, first time poster, but long-time user of GreenSock (used to use AS version). I was delighted to discover it actually worked in node.js and was able to use it for orchestrating timelines of events on the server. Brilliant stuff! 


Link to comment
Share on other sites

Excellent! Thanks for letting us know. Nice to hear from such a long-time user :-)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.