Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <link href='https://fonts.googleapis.com/css?family=Asap:400,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Signika' rel='stylesheet' type='text/css'>
  <h2>TimelineMax.staggerTo() with callbacks</h2>
  <div id="demo">
    <p>View code comments in JS source tab for complete details.</p>
    <div class="box green">1</div>
    <div class="box grey">2</div>
    <div class="box orange">3</div>
    <div id="console"></div>
  </div>

              
            
!

CSS

              
                html, body {
  height: 100%;
}

body {
  background-color:#1d1d1d;
  font-family: "Asap", sans-serif;
  color:#989898;
  margin:0 10px;
  font-size:16px;
}

h1, h2, h3 {
  font-family: "Signika Negative", sans-serif;
  margin: 10px 0 10px 0;
  color:#f3f2ef;
}

h1 { 
  font-size:36px;
}

h2 {
  font-size:30px;
}

h3 {
  font-size:24px;
}

p{
  line-height:22px;
  margin-bottom:16px;
  
}

#demo {
  height:100%;
  position:relative;
}
.box {
  width:50px;
  height:50px;
  position:relative;
  border-radius:6px;
  margin-top:4px;
  display:inline-block;
  line-height:50px;
  text-align:center;
  color:#333;
  font-size:24px;
}

.green{
  background-color:#6fb936;
}

.orange {
  background-color:#f38630;
}
.grey {
  background-color:#989898;
}


#console {
  width:400px;
  min-height:150px;
  background:#f3f2ef;
  position:absolute;
  left:200px;
  display:inline-block;
  padding:10px;
  line-height:20px;
  font-size:16px;
  color:#333;
  border-radius:8px;
}

.done {
  color:#a00;
  font-weight:bold;
}
              
            
!

JS

              
                var $console = $("#console")

//each tween is given and onComplete callback and onCompleteParams property
//onCompleteParams takes an array of values (even if only 1 value is being passed)
//"{self}" passes a reference to the individual tween to the onComplete callback function
//myCompleteAll is the name of the function being used for the staggerTo()'s onCompleteAll parameter

var tl = new TimelineMax()
tl.from("h2, p", 0.5, {opacity:0, x:100})
tl.staggerTo(".box", 0.5, {rotation:360, y:120, onComplete:tweenComplete, onCompleteParams:["{self}"]}, 1.2, "+=0", myCompleteAll);


//the following function fires when each individual tween completes.
//the tween parameter is a reference to the tween that calls the function

function tweenComplete(tween) {
  $console.append("<p> tween complete / target text = " + tween.target.innerHTML + "</p>")
}

function myCompleteAll() {
  $console.append("<p class='done'> all tweens complete </p>");
}
              
            
!
999px

Console