Jump to content

Search In
  • More options...
Find results that contain...
Find results in...
Dave Stewart

Animation Scene Manager?

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

Have just got a new client brief to build and animate a story-style site, very similar to this:

It's pretty clear this will need a significant amount of top-down organisation and control aside from the creative / pure animation side, namely:

  • asset management
  • interactivity
  • some kind of abstracted scene setup and animation control


I'm perfectly happy building all this myself, using the usual tools such as Flash Pro, GreenSock, EaselJS, jQuery plugins, Backbone/Angular/etc but is there anything out there at the moment that either:

  • solves the problem of managing scenes full of animation, or
  • provides a robust animation scene management platform to build on

I'm well-versed in animation and all kinds of JS frameworks, but before starting thought it prudent to ask how (or if) this particular cat may have been skinned before.


I would imagine the ultimate solution will be a mix of both workflow (Flash, JSON, spritesheets, etc) and technical (HTML, JS, JSON, Framework X/Y/Z) to set up and manage each scene in a way that abstracts-away brittle JavaScript coding practices.


Any input / experience welcome.



Link to comment
Share on other sites

  • 1 month later...

I thought I would post the results of my foray into a JS scene manager.


Here’s the final animation, which is entirely DOM based, which I’m pretty pleased with:




It uses an HTML/JS framework I developed over the course of a few weeks (and I’ll probably work on some more) and the majority of the animation is of course handled by GSAP, along with animated GIFs, animated in Flash, but exported as PNGs then re-exported from PhotoShop (as it does a better job with colors).

I had planned to build a spritesheet plugin for TweenMax to export animations directly from Flash, but in the end I didn't get time to do all the character idling animations.

So, the framework consists of various HTML elements with JS logic, which do a pretty good job of mirroring entities in Flash, with some added optimizations around the "story" concept:

+ story
    + scene / location
        +- layer
        |  +- group
        +- sprite
            +- tween
            +- animation

The interesting files to look at in animation/assets/js/ (you can use the Chrome debugger Source panel to look at them / set breakpoints) are:

  • story.js - manages the adding of all scenes, and handles overall playback, events, etc
  • scene.js - manages / animates elements within an HTML "scene" or "location" (a global type of scene) element
  • main.js - the main file that sets up ALL the animation with setup / animation functions that are injected into the main Story and Scene classes
  • application.js & layout.js - top level logic and layout classes, independent of any story-specific setup or animation

Scenes are the core JS classes that manage assets and animations, with Locations providing a slightly more specialized version, which serve as a base for "scene" animation to be layered over the top. That allows multiple "scene" animations to use a single "location", in the same was that a physical set in a theater can have multiple scenes. The hiding and showing of elements within each scene is managed by the framework as each Scene's animation is reached in the timeline. 



I created various helper functions such as sprite() and tween() to do the leg-work of building HTML and setting attributes, with some more specialized functions such as van() to set up complex sprites with animation, like this

See the Pen rwsBa by davestewart (@davestewart) on CodePen


function van()
    var van         = sprite('van', '/animation/assets/images/objects/van.png', 330, 129);
    var wheel1      = $(sprite('vanWheel1', '/animation/assets/images/objects/van-wheel.png', 46, 46)).css({left:37, top:83}).appendTo(van);
    var wheel2      = $(sprite('vanWheel2', '/animation/assets/images/objects/van-wheel.png', 46, 46)).css({left:252, top:83}).appendTo(van);
    return van;


That meant a van could easily be added to the scene with a line of code like this:

this.add('fg', van(), 200, 300); // scene.add(layer, element, x, y)

All setup and animation is dependency-injected from the main.js file, with all elements being referenced inside an elements hash from their HTML name attribute, as they are injected:



As the functions above are injected into an owning Scene instance, the this above refers to the actual Scene, and not the window object:

this          // the Scene instance
this.parent   // the Scene's location
this.elements // a hash of named HTML elements within the scene
this.tl       // the TimelineMax instance
this.name     // the name of the scene

The hierarchical nature of the framework also means you can reference any element and its animation from anywhere in the app:


For example:


You can also see the injected setup() and animate() functions, and back-references to story and parent (usually a Location, though Scenes can also be nested inside other Scenes).


TimelineMax manages all the animation at a global level, so the entire animation can be scrubbed or navigated around in the browser using a

See the Pen keJpE by davestewart (@davestewart) on CodePen

I developed for this purpose:


Animating this way felt very similar to code-only development in something like FlashDevelop, using both Photshop and Flash to wrangle assets.

I’m interested to know if anyone has any input on this so far, or how I could have done this differently, perhaps by animating in Flash, and exporting using some of the new HTML5 capability (I've posted this in the Flash CC Prerelease forum as well, so I hope to get some feedback there too)

If this turns out to be a good way to work, I’ll likely do some more work on the framework, for example allowing elements to be declared directly in the HTML, and will open source it.


  • Like 6
Link to comment
Share on other sites

Hey Dave,


Just wanted to thank you for posting this overview of your process here.

I haven't had time to get into it in detail, but I'm sure this is the type of thing folks will be interested in as they attempt more robust and scalable animations. 


It sounds like you are really onto something here.


Hoping all goes well with your project.





Link to comment
Share on other sites

Hi Carl,




But thanks even more for your's and Jack's (and everyone else's) help over the last month or so in getting me up to speed with GSAP, and the various peculiarities I seem to be so adept at finding!


Could seriously not have got this completed without all the fine input received.



  • Like 1
Link to comment
Share on other sites

This is good stuff, Dave.


I'm going to be digging into it later for sure!

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Hi Carl,




But thanks even more for your's and Jack's (and everyone else's) help over the members section of the wealthy affiliate last month or so in getting me up to speed with GSAP, and the various peculiarities I seem to be so adept at finding!


Could seriously not have got this completed without all the fine input received.




Excellent stuff, Dave. Maybe you could post and update of your project. One thing I've wondered about these sites is the page speed is obviously a lot slower than normal sites.


Is there a way to speed these sites up with so many animations and stuff going on?

Link to comment
Share on other sites

Hey Toppy,


I haven't looked at this since the last post in 2014! But thanks, I'm glad you found it interesting, I would like to release the code at some point, I should do that.


I don't have any hard and fast advice on how to speed things up actually. Hopefully someone else will be able to help you there, or start a new thread if this one doesn't garner any more interest.

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.