Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <link href='//,400' rel='stylesheet' type='text/css'>
<h1>Press the buttons</h1>
<h3>requestedAnimation will not play until currentAnimation is done reversing</h3>
<div class="nav">
  <button id="play">green</button>
  <button id="restart">orange</button>
  <button id="restart">grey</button>
<div class="box green"></div>
<div class="box orange"></div>
<div class="box grey"></div>



                /* Global styles come from external css*/



                var currentAnimation;
var requestedAnimation;

$("button").each(function(index, element){
    //give each button an animation
    //tell it to animate a box based on its text. green button animates element with class .green
    //each animation has an onReverseComplete that calls the playRequestedAnimation() function which checks if there is a requestedAnimation.
    var tl = new TimelineLite({paused:true, onReverseComplete:playRequestedAnimation})"." + $(this).text(), 4, {y:200, ease:Linear.easeNone})
    this.animation = tl;

  //every time you click a button update the requestedAnimaiton variable
  requestedAnimation = this.animation;
  console.log("requested animation for", $(this).text())
    //if there is a currentAnimation tell it to reverse
    console.log("currentAnimation needs to be reversed")
  } else {
  //if the requested animation is the currentAnimation, so imagine someone clicks a bunch of buttons like green, orange, green, you can skip over green reversing and orange playing forward entirely and just play green forward.
  if(requestedAnimation == currentAnimation){;

//when we are ready to play the requested animation tell it to play
//also update the currentAnimation to be the requestedAnimation
function playRequestedAnimation() {
  console.log("ready to play requested animation");
  currentAnimation = requestedAnimation;