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.


  <li>open real browser console when testing</li>
  <li>press m key once to start animation</li>
  <li>press m again while animation is running</li>
  <li>desired result is that box turns magenta AFTER green box stops moving</li>
  <li><strong>set fixed = true on line 2 to see "solution"</strong></li>
  <li>use the "run" button to replay</li>

<div id="box"></div>



                #box {
  position: absolute;
  width: 100px;
  height: 100px;
  background: green;


var fixed = false; // change to true to see "solution".

// callbacks queueing via gsap animation.
// 1. add array of objects holding callbacks
// 2. check if there is anything add to queue, if so take first object and add it to timeline
// 3. run the timeline
// 4. if timeline finishes, start next function to take another element from queue
// 5. do that until there is nothing in queue
var tl = new TimelineMax();

var obj = {
  // first move first element from arr.move to arr.playing (currently playing) and run function next 
	add: function (arr) {
	next: function () {
// check if there is anything to process
		if ( arrays.playing.length ) {
      console.log("is timeline active?", tl.isActive())
      console.log("what is the duration() of tl?", tl.duration())
      // and if timeline is playing
			if ( !tl.isActive() ) {
        // take first object from current queue 
				var callback = arrays.playing.shift();
				if ( callback ) {
          if(fixed === false){
            console.log("Look you are adding a function to a timeline, not any animations. see below");
            console.log("callback.fn", callback.fn);
            console.log("adding functions to a timeline does not make it active");
          if(fixed === true){
            console.log("Look you are adding the timeline that callback.fn() returns");
            console.log("callback.fn", callback.fn());
            console.log("the timeline now has a duration() of", tl.duration());
 //$("#box"), 3, { y: "+=100"})
         // add that object to timeline
  // move #box 100px to right if someone calls 
	red: function () {
		var tt = new TimelineMax;
			.to($("#box"), 3, { x: "+=100"})
		return tt

 // same with this.magenta
	magenta: function () {
		var tt = new TimelineMax;
		tt.set($("#box"), { "backgroundColor": "#ff00ff" })
		return tt


// array holding objects each one may be added to queue
var arrays = {
	playing: [],
	move:    [ { fn: } , { fn: obj.magenta }]

	if ( e.which == 77 ) {
    // by pressing "m" add array of callbacks to queue processing