Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
spiralstatic

GSAP in non-html framework

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

Is it possible to include the GSAP library into a Javascript project that doesn't use or run on a browser?

 

I'm developing software using a framework that has no need for a browser, and at first glance it doesn't look possible as the TweenLite/TweenMax source is referencing things like 'window' and 'createElement' etc...

Link to comment
Share on other sites

Frankly I've never tried, but I suspect it wouldn't be too difficult to do (except for CSSPlugin). The "window" references are primarily for the global scope which I assume you could easily alter. The core engine attempts to use the requestAnimationFrame functionality that's baked into almost every modern browser, but it falls back to setTimeout() if it can't find requestAnimationFrame, so that should work. The only place where createElement() is used is inside CSSPlugin and that's pretty important there, but I also assume that you wouldn't need/want CSSPlugin anyway if you're not in a browser (right?) so you could just not load that (or rip it out of TweenMax).

 

Let me know if you need help taking it out of TweenMax or something. And as for "window" references, try just changing the "window" reference at the VERY END of the TweenLite/TweenMax file to whatever your global scope is.

 

The core engine is intentionally written in plain-jane Javascript without any fancy stuff like getter/setters so that it can be compatible with almost any JS system. Again, the only exception has to do with some plugins like CSSPlugin and looking for requestAnimationFrame and setTimeout on the global scope.

 

Does that help at all?

Link to comment
Share on other sites

Thanks Jack... this is all really helpful. I will investigate today and get back to you.

Link to comment
Share on other sites

I've got it working but it turned out to be a bit tricky.

 

Changing the last reference from window to my global scope seemed to work although I started seeing issues around references to GreenSockGlobals. I can remove these errors if I include the the TweenLite library much later in the code (before I was trying to import at the start, but obviously something wasn't initialised at this point).

 

After this there were some problems with setTimeout but this was probably just due to the framework I'm using. I changed 'window.setTimeout' to 'setTimeout' to fix this.

 

I also had to change the window reference in EasePack.min.js to my global scope.

 

Thanks for your help!

Link to comment
Share on other sites

Glad you got it working. What if you just set a "window" variable first that's a generic object?

 

var window = {};
//then load the GSAP files

 

Wouldn't that solve all the problems?

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.
×