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="buttons-wrapper">
  <button class="play">Play</button>
  <label for="set-start">Set start time: </label>
  <select name="set-start" id="set-start">
    <option value="0">0</option>
    <option value="1">1 second</option>
    <option value="2">2 seconds</option>
    <option value="3">3 seconds</option>
    <option value="4">4 seconds</option>
  </select>
  <label for="set-tween">Set tween time: </label>
  <select name="set-tween" id="set-tween">
    <option value="0">0.5 seconds</option>
    <option value="1">1 second</option>
    <option value="2">2 seconds</option>
    <option value="3">3 seconds</option>
    <option value="4">4 seconds</option>
  </select>
</div>
<div class="data">
  Tween status: <input type="text" name="tw-status" value="" readonly> Tween duration: <input type="text" name="tw-duration" value="" readonly>
  <label for="twseek">Tween set seek(0) on Play?</label>
  <input id="twseek" name="twseek" type="checkbox" value="1" checked />
</div>
<div class="data">
  Timeline status: <input type="text" name="tl-status" value="" readonly> Timeline duration: <input type="text" name="tl-duration" value="" readonly>
  <label for="tlseek">Timeline set seek(0) on Play?</label>
  <input id="tlseek" name="tlseek" type="checkbox" value="1" checked />
</div>
<div id="stage-container" width="800" height="400" style="width: 800px; height: 400px;">
  
  <div id="stage" width="800" height="400" style="width: 800px; height: 400px;">
    
    <svg id="stage-svg-0" class="stage-svg" x="0" y="0" height="400" width="800">
      
      <g id="gp-0" class="svg-wrapper" ref="0" x="50" y="50" height="170" width="170">

        <svg id="svg-0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 170 170" class="svg inline" height="170" width="170">
          <path fill="#FFF" d="M85 170c-46.87 0-85-38.13-85-85S38.13 0 85 0s85 38.13 85 85-38.13 85-85 85z"/>
          <path fill="none" stroke="#282D33" stroke-width="4" d="M93.312 108.145h16.16c6.685 0 12.103 4.796 12.103 10.714v13.39M44.242 132.25v-13.392c0-5.918 5.42-10.714 12.105-10.714h16.13M93.078 100.51v8.206l-10.17 10.872-10.17-10.872v-8.205M57.29 48.265c-2.11 3.162-3.614 6.763-4.343 10.633-4.207 2.49-7.025 6.986-7.025 12.135 0 4.558 2.22 8.592 5.64 11.19-.616 1.323-.966 2.76-.966 4.27 0 6.453 6.197 11.685 13.842 11.685.636 0 1.262-.036 1.874-.106M102.96 91.47c1.166.61 2.493.955 3.9.955 4.667 0 8.45-3.783 8.45-8.45 0-1.903-.186-3.308-1.25-4.722 3.64-2.578 5.564-7.092 5.564-11.815 0-6.16-4.027-11.388-9.648-13.355.106-.376-.496-3.37-2.087-6.02"/>
          <path fill="none" stroke="#282D33" stroke-width="4" d="M105.16 66.653c.84-.307 1.744-.475 2.69-.475 4.318 0 7.82 3.502 7.82 7.82s-3.502 7.82-7.82 7.82M57.156 81.818c-4.318 0-7.818-3.5-7.818-7.82s3.5-7.82 7.818-7.82"/>
          <path fill="none" stroke="#282D33" stroke-width="4" d="M106.976 65.69v11.892c0 14.166-11.483 25.65-25.65 25.65-14.164 0-25.648-11.484-25.648-25.65v-11.89M74.617 91.853c5.156 2.08 10.72 1.608 15.283-.818"/>
          <path fill="none" stroke="#282D33" stroke-width="4" d="M72.52 49.55c-2.196 6.24-6.645 11.74-12.937 15.01-1.686.877-2.967 1.484-4.922 2.158M107.176 66.313c-11.058.62-24.47-2.95-29.73-14.33l-1.27-2.75M73.752 72.673h-4.675M92.492 72.673h-4.674M84.75 82.952h-5.033V70.01"/>
          <path fill="none" stroke="#282D33" stroke-width="4" d="M107.48 49.55h-50v-12.5c15.772-7.726 34.23-7.726 50 0v12.5z"/>
          <g fill="none" stroke="#282D33" stroke-width="4">
            <path d="M82.482 35.48v10.433M87.7 40.696H77.265"/>
          </g>
          <g fill="none" stroke="#282D33" stroke-width="4">
            <path d="M78.375 132.3l-7.225-23.54h-3.877l-4.11 7.146 5.507 4.905-4.188 4.35 3.427 7.14M87.35 132.3l7.224-23.54h3.877l4.113 7.146-5.508 4.905 4.187 4.35-3.427 7.14"/>
          </g>
          <rect width="100%" height="100%" fill="rgba(255,255,255,0"/>
        </svg>
      </g>
    </svg>
  </div>
</div>
              
            
!

CSS

              
                html, body
  font-family: sans-serif

.buttons-wrapper
  display: block
  width: 800px
  margin: 0 auto
  button
    cursor: pointer
    &.play
      display: block
      background: blue
      color: white
      border: 0
      padding: 10px 20px
      border-radius: 4px
      font-size: 18px
      margin-bottom: 5px
svg.stage-svg
  position: absolute
  left: 0
  top: 0

.data
  width: 800px
  margin: 5px auto

#stage-container
  position: relative
  width: 800px
  height: 400px
  margin: 0 auto 15px
  background: #000
  border: 4px #6bc28c solid

.buttons
  width: 800px
  position: relative
  display: block
  margin: 10px auto

#stage
  display: block
  width: 800px
  height: 400px
  position: relative
  background: transparent
  position: relative

              
            
!

JS

              
                var tw,
    tl = new TimelineMax(
      {
        paused: true,
        onStart: function(){
          $('input[name=tl-status]').val('started...');
          $('input[name=tl-duration]').val('');
        },
        onComplete: function(){
          $('input[name=tl-status]').val('finished');
          $('input[name=tl-duration]').val(tl.duration());
        }
      }
    );

function addTween() {
  tw = TweenMax.to(
    $('#gp-0'), 
    0.5, 
    {
      x: 300, 
      y: 200, 
      onStart: function(){
        $('input[name=tw-status]').val('started...');
        $('input[name=tw-duration]').val('');
      },
      onComplete: function(){
        $('input[name=tw-status]').val('finished');
        $('input[name=tw-duration]').val(tw.duration());
      }
    });
  tl.add(tw);
  // tl.add(tw).repeat(-1);
}

function resetFields() {
  $('input').val('');
}

function changeStartTime(val) {
  tw.startTime(val);
  tl.pause();
}

function changeTweenDuration(val) {
  tw.duration(val);
}

$('.play').on("click", function(){
  resetFields();
  if($('input[name=twseek]').is(':checked')) {
    tw.seek(0);
  }
  if($('input[name=tlseek]').is(':checked')) {
    tl.seek(0);
  }
  tl.play();
  console.log(tw.vars);
});

$('#set-tween').on("change", function(){
  changeTweenDuration(parseFloat($(this).val()));
});

$('#set-start').on("change", function(){
  changeStartTime(parseFloat($(this).val()));
});

addTween();

              
            
!
999px

Console