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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div class="container">
  <div class="box"></div>

  <div class="timeline">
    <p id="time">0.00</p>

    <div class="dragger-track">
      <div id="dragger">
        <div></div>
      </div>
    </div>
    
  </div>
  
  <div class="buttons">
    <button id="play">Play</button>
    <button id="pause">Pause</button>
    <button id="reverse">Reverse</button>
    <button id="time1">timescale(0.25)</button>
    <button id="time2">timescale(1)</button>
    <button id="time3">timescale(2)</button>
    <button id="seek">seek(1.5)</button>
   </div>
</div>
              
            
!

CSS

              
                body {
  position: relative;
  padding: 10px;
  font-family: Arial,Helvetica,sans-serif;
  background-color: #fafafa;
}

.container {
  margin: 0 auto;
  max-width: 800px;
  width: 100%;
}

.box {
  position: relative;
  width: 60px;
  height: 60px;
  margin-bottom: 10px;
  border-radius: 4px;
  background: url("http://mwanoz.fr/gsap/cookie.png") no-repeat;
  -webkit-background-size: cover;
  background-size: cover;
}

.timeline {
  margin: 20px auto 0;
  height: 78px;
  max-width: 800px;
  background-color: #00acc1;
}

.timeline p {
  margin: 0;
  padding: 5px 0;
  color: #fff;
  background-color: #0097a7;
  text-align: center;
}

.dragger-track {
  position: relative;
  width: 100%;
  margin-top: 20px;
}

#dragger {
  position: absolute;
  width: 10px;
  height: 50px;
  top: -20px;
}

#dragger div {
  position: relative;
  width: 0px;
  height: 0;
  border-style: solid;
  border-width: 20px 10px 0 10px;
  border-color: #212121 transparent transparent transparent;
  left: -10px;
}

#dragger div::before {
  content: " ";
  position: absolute;
  width: 20px;
  height: 50px;
  top: -20px;
  left: -10px;
}

#dragger div::after {
  content: " ";
  position: absolute;
  width: 1px;
  height: 31px;
  top: -1px;
  left: -1px;
  border-left: solid 2px #212121;
}

.buttons {
  position: absolute;
  top: 10px;
  right: 10px;
}

button {
  display: block;
  width: 130px;
  margin-bottom: 10px;
  padding: 13px 0;
  border: none;
  border-radius: 2px;
  text-transform: uppercase;
  font: inherit;
  font-size: 16px;
  color: #eeeeee;
  background-color: #2196f3;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: all .1s ease-in;
  cursor: pointer;
}

button:hover,
button:focus,
button:active {
  transition: all .1s ease-in;
}

button:hover {
  background-color: #1e88e5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

button:focus {
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}

button:active {
  background-color: #1976d2;
  box-shadow: 0 4px 7px rgba(0, 0, 0, 0.3);
}
              
            
!

JS

              
                /**
 * Simple timeline visualizer for GSAP
 * Made with Draggable.
 * Go check the external JS files.
 */
$(function() {

  // Load TimelineMax
  var tl = new TimelineMax( {onUpdate:updateDragger, paused:true} );
  
  // Stock the container width.
  var wi = $(".container").width();

  // Your timelines stuff here
  tl.to( ".box", 5, {x: wi - 60, rotation:720, ease:Elastic.easeInOut} );

  // Set some vars for the draggable stuff
  var ti = $( "#time" );
  var tr = tl.duration() * 160;  // Time in seconds
  var dr = $( "#dragger" );

  // Update the dragger when the timeline is updated.
  function updateDragger() {
    TweenLite.set(dr, {x: tr * tl.progress()});
    ti.html(percentToRange(tl.progress(), 47, 91).toFixed(2));
  }

  //function from our good friend Chrysto http://bassta.bg/2013/05/rangetopercent-and-percenttorange/
  function percentToRange(percent, min, max) {
   return((max - min) * percent + min);
}
  
  
  /** Create the dragger with the "Draggable" plugin.
    * The 'bounds' depends o
    */
  var s = Draggable.create(dr, {
    type: "x",
    bounds: {minX: 0, maxX: wi},
    onDrag: function(){
      tl.progress(this.x / tr).pause();
    }
  });

  $( "#play" ).click(function(){ tl.play(); });
  $( "#pause" ).click(function(){ tl.pause(); });
  $( "#reverse" ).click(function(){ tl.reverse(); });
  $( "#time1" ).click(function(){ tl.timeScale(0.25); });
  $( "#time2" ).click(function(){ tl.timeScale(1); });
  $( "#time3" ).click(function(){ tl.timeScale(2); });
  $( "#seek" ).click(function(){ tl.seek(1.5); });

});
              
            
!
999px

Console