Jump to content
GreenSock

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

GSDevToolsPlugin

Description

GSDevTools gives you a visual UI for interacting with and debugging GSAP animations, complete with advanced playback controls, keyboard shortcuts, global synchronization and more. Jump to specific scenes, set in/out points, play in slow motion to reveal intricate details, and even switch to a “minimal” mode on small screens. GSDevTools makes building and reviewing GSAP animations simply delightful.

Get Started

  1. Load the JavaScript file

    1. //be sure to use a path that works in your dev environment
    2. <script src="js/gsap/GSDevTools.min.js"></script>
  2. Create a GSDevTools instance

    1. GSDevTools.create();

That’s it! The demo below shows GSDevTools running with its default settings. It automatically gives you control over every animation on the global timeline.

Select an animation by id

Any GSAP animation (tween or timeline) can be assigned an id (a string) which causes it to show up in the animation menu. That makes it easy to jump to any scene. Notice how the timeline and each tween below have an id assigned:

  1. //give the timeline and child tweens their own id.
  2. var tl = gsap.timeline({id: "timeline"})
  3. tl.to(".orange", {duration: 1, x: 700, id: "orange"})
  4. .to(".green", {duration: 2, x: 700, ease: "Bounce.easeOut", id: "green"});
  5. //give this tween an id
  6. gsap.to(".grey", {duration: 1, x: 700, rotation: 360, delay: 3, id:"grey"});
  7. //instantiate GSDevTools with default settings
  8. GSDevTools.create();

Now each id shows up in the animations menu (lower left).

Persistence between refreshes

For added convenience, when you manually set the in/out points, animation, timeScale, or looping state in the UI, they persist between refreshes! This means you can drag the in/out points to isolate a particular section and then tweak the code, hit refresh, and see the changes immediately within that cropped area. Any values set in the GSDevTools.create({...}) method will override manual selections. Set persist: false to disable persistence. If you encounter persistence contamination (e.g. setting timeScale in one affects another), simply assign a unique id to the GSDevTools instance (the recorded values are segregated by id, session, and domain).

Configuration options

GSDevTools can be configured extensively. Optionally define any of these properties in the config object:

  • animation: [string | animation] - If you define an animation, like animation: myTimeline, animation: myTween or animation: "id", that animation will be initially selected. By default, the global timeline is selected.

  • container : [string | element] - Specify the container element for GSDevTools, like: "#devTools" or document.getElementById ("devTools").

  • css : [object | string] - The CSS you want on the outer div, like {width: "50%", bottom: "30px"} or a string of CSS like "width: 50%; bottom: 30px".

  • globalSync : boolean - By default, animations are kept in context and synchronized with the root timeline (scrubbing one scrubs them all), but you can set globalSync: false to unhook it from the global timeline.

  • hideGlobalTimeline : boolean - If true, the Global Timeline will be removed from the animation menu.

  • id : string - A unique string to identify the GSDevTools instance.

  • inTime : []number | string] - Position of the in marker (time, in seconds, or label or animation id).

  • keyboard : boolean - If true (the default), keyboard shortcuts will work. Note: Only one GSDevTools instance can listen for keyboard shortcuts.

  • loop : boolean - Initial loop state.

  • minimal : boolean - If true, the UI will only show minimal controls (scrubber, play/pause, and timeScale). Note: When the screen is less than 600px it automatically switches to minimal mode anyway.

  • outTime : [time | label] - Position of the out marker (time, in seconds, or label, or animation id).

  • paused : boolean - Initial paused state.

  • persist : boolean - By default, GSDevTools remembers the in and out points, selected animation, timeScale, and looping state between refreshes in the same domain session, but you can disable that behavior by setting persist: false.

  • timeScale : number - Initial timeScale.

  • visibility : string - "auto" causes the controls to automatically hide when you roll off of them for about 1 second, and return when you move your mouse over the area again.

Keyboard Controls

  • SPACEBAR: play/pause

  • UP/DOWN ARROWS: increase/decrease timeScale

  • LEFT ARROW: rewind

  • RIGHT ARROW: jump to end

  • L: toggle loop

  • I: set the in point to current position of playhead

  • O: set the out point to current position of playhead

  • H: hide/show toggle

Tips and tricks

  • Clicking the GreenSock logo (bottom right) gets you right to the GreenSock docs!

  • Double-click on the in/out marker(s) to reset them both immediately.

  • If the playback UI is obscuring part of your animation, just tap the “H” key to hide it (and again to bring it back) - you can still use all the keyboard shortcuts even when it’s invisible.

Advanced demos

We purposefully chose very basic animations for the demos above, but here are a few that illustrate how easy GSDevTools makes it to control and debug even super-complex animation sequences.

How do I get it?

GSDevTools is available to Club GreenSock members (“Shockingly Green” and above). Just download GSAP with the bonus files zip from your Dashboard. Try GSDevTools for free on CodePen.

Included in GSAP core: No

FAQ

  • Why is my Global Timeline 1000 seconds long? That means you’ve probably got an infinitely repeating animation somewhere. GSDevTools caps its duration at 1000 seconds. Scrubbing to Infinity is awkward.

  • Does loading GSDevTools impact runtime performance? Since it must monitor and record the root timeline, yes, there is a slight performance hit but probably not noticeable. Keep in mind that usually you’ll only load GSDevTools while you’re developing/reviewing your animations and then remove it when you’re ready to launch, so ultimately it shouldn’t be much of a factor anyway.

  • Why isn’t GSDevTools in the CDN or Github repo? Because it’s a membership benefit of Club GreenSock. It’s a way for us to give back to those who support our ongoing development efforts. That’s why we’ve been able to continue innovating for over a decade. See our “Why License?” article for details about our philosophy.

  • Does GSDevTools work with other animation libraries? Nope, it depends on some unique capabilities baked into the GSAP architecture.

  • What will I do with all the time this tool saves me? Take up a new hobby, ponder deep philosophical questions, make cookies - it’s up to you.

GSDevToolsPlugin is a Club GreenSock membership benefit. You must have a valid membership to use this class without violating the terms of use. Visit the club page to sign up or get more details.

GSDevToolsPlugin and other bonus plugins are not hosted on a CDN. Checkout our CDN FAQs for more info.

Methods

create( config:Object ) : GSDevTools

Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×