Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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='//fonts.googleapis.com/css?family=Signika+Negative:300,400,700' rel='stylesheet' type='text/css'/>
<div id="demo">  
  <div class="product" id="timeline_txt">Timeline</div><div class="suffix" id="lite_txt">Lite</div><div class="tagline">Who&rsquo;s the boss of your tweens?</div>
  <ul style="text-align:left; width:780px; margin:auto">
    <li>// play</li>
    <li>// pause</li>
    <li>// reverse</li>
    <li>// adjust timeScale</li>
    <li>// add callbacks</li>
    <li>// add labels</li>
    <li>// stagger</li>
  </ul>
  <div id="controls">
    <div class="sliderValues">time: <span id="time"></span>s / progress: <span id="progress"></span></span>
    <div class="slider" id="progressSlider"></div>
    <button id="playBtn">play()</button>
    <button id="pauseBtn">pause()</button>
    <button id="resumeBtn">resume()</button>
    <button id="reverseBtn">reverse()</button>
    <button id="restartBtn">restart()</button>

    <div style="text-align:left; width:420px; margin:auto">
      <div class="slider" id="timeScaleSlider" style="display:inline-block"></div>
      <div class="sliderValues" style="display:inline-block">timeScale: <span id="timeScale" >1</span></div>
    </div>  
  </div>
  <a class="link" href="https://codepen.io/GreenSock/pen/LbezE?editors=001" target="_blank">Edit on CodePen</a>
</div>
      

              
            
!

CSS

              
                body {
  background-color:#1d1d1d;
  color:#989898;
  margin:0 10px;
  font-size:16px;
  margin-top:40px;
  font-family: 'Signika Negative', sans-serif;
  
}

.product {
  display:inline-block;
  color:white;
  font-size:60px;
  font-weight:300;
}

.suffix {
  display:inline-block;
  font-size:60px;
  font-weight:700;
  color:#86CC01;
  font-weight:700;
}

.tagline {
  display:inline-block;
  margin-left:20px;
  font-size:36px;
}

#demo {
  text-align:center;
  position:relative;
  visibility:hidden;
}

#controls {
  margin-top:35px;
  text-align: center;
}

.slider {
  width:420px;
  margin:auto;
}
.sliderValues {
  margin:10px;
}

.sliderValues span {
  font-size:24px;
}

#timeScaleSlider {
  width:260px;

}

button {
  padding:1em;
  margin:20px 0 10px 0;
  font-size:12px;
  cursor:pointer;
}

li {
 display:inline-block;
 margin-right:25px;
  color:#aaa;
}

.ui-widget-content {
  background-color:rgba(255, 255, 255, 0.2);
}

.link {
  display:inline-block;
  padding-top:20px;
  text-decoration:none;
}

a.link:link, a.link:visited {
  color:rgba(255, 100, 0, 0.3);
}

a.link:hover {
  color:rgba(255, 100, 0, 0.95);
}

              
            
!

JS

              
                CSSPlugin.defaultTransformPerspective = 400;
var playBtn = $("#playBtn"),
    pauseBtn = $("#pauseBtn"),
    resumeBtn = $("#resumeBtn"),
    time = $("#time"),
    progress = $("#progress"),
    timeScale = $("#timeScale"),
    buttons = [playBtn, pauseBtn, resumeBtn],
    tagline = new SplitText(".tagline")

tl = new TimelineLite({onUpdate:updateSlider, delay:0.4});
tl.eventCallback( "onUpdate", function ()                             {
     console.log( 'onUpdate 1' );
} );
tl.eventCallback( "onUpdate", function ()                             {
     console.log( 'onUpdate 2' );
} );


TweenLite.set("#demo", {visibility:"visible"})

tl.from("#timeline_txt", 0.6, {y:-30, opacity:0})
  .from("#lite_txt", 0.6, {y:30, opacity:1}, "-=0.3")
  .staggerFrom(tagline.chars, 0.3, {rotation:90, scale:0.20, y:-60, ease:Back.easeOut}, 0.05)
  .staggerFrom("li", 0.2, {y:20, opacity:0}, 0.1)
  .set(buttons, {opacity:0.2})

// controls

$( "#progressSlider" ).slider({
  range: false,
  min: 0,
  max: 1,
  step:.001,
  slide: function ( event, ui ) {
    tl.progress( ui.value ).pause();
  }
});	

function updateSlider() {
  $("#progressSlider").slider("value", tl.progress());
  time.html(tl.time().toFixed(2));
  progress.html(tl.progress().toFixed(2))
} 

$("#playBtn").on("click", function(){
  //Play the timeline forward from the current position.
  //If tween is complete, play() will have no effect
  tl.play();
});

$("#pauseBtn").on("click", function(){
  tl.pause();
});

$("#resumeBtn").on("click", function(){
  //Resume playback in current direction.
  tl.resume();
});

$("#reverseBtn").on("click", function(){
  tl.reverse();
});

$("#restartBtn").on("click", function(){
  tl.restart();
});



$("#timeScaleSlider").slider({
  value:1,
  range: false,
  min: 0.25,
  max: 4,
  step:0.25,
  slide: function ( event, ui ) {
    tl.timeScale(ui.value );
    timeScale.html(ui.value)
  },
  change: function() {
    if(tl.paused()){
      tl.resume();
    }
    
    if (tl.progress() == 1){
      tl.restart();
    }
    
    if(tl.reversed() && tl.progress() === 0){
      tl.restart();
    }
  }
  
});	





              
            
!
999px

Console