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="button-group in-buttons">
  <h3>In from tweens</h3>
  <button data-in-func="inTopLeft">Top Left</button>
  <button data-in-func="inTop">Top Center</button>
  <button data-in-func="inLeft">Left</button>
</div>
<div class="button-group ease-buttons">
  <h3>Eases</h3>
  <button class="Power0.easeNone">None</button>
  <button class="Elastic.easeOut">Elastic</button>
  <button class="Bounce.easeOut">Bounce</button>
</div>
<div id="stage-container" width="800" height="600" style="width: 800px; height: 600px;">
  
  <div id="stage" width="800" height="600" style="width: 800px; height: 600px;">
    
    <svg id="stage-svg-0" class="stage-svg" x="0" y="0" height="600" width="800">
      
      <g id="gp-0" class="svg-wrapper" ref="0" x="50" y="50" height="170" width="170" data-svg-origin="83 83" style="transform-origin: 0px 0px 0px; transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 604, 410, 0, 1); cursor: move; touch-action: none; -webkit-user-select: none; z-index: 1000;">

        <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

              
                .svg.inline {
  transform: translateZ(0);
}

.button-group {
  display: inline-block;
  padding: 5px 15px;
}

.ease-buttons {
  padding-left: 30px;
}


svg.stage-svg {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

svg.stage-svg .svg-wrapper {
  pointer-events: fill;
}

#stage-container {
  position: relative;
  width: 800px;
  height: 600px;
  margin-bottom: 15px;
  background: #ffffff;
}

#stage {
  width: 800px;
  height: 600px;
  overflow: hidden;
  position: relative;
  border: 4px #6bc28c solid;
  background: transparent;
  position: relative;
}
              
            
!

JS

              
                var masterTL = new TimelineMax(),
    svgObj = {
      el: $('#svg-0'),
      id: "0",
      gp: $('#gp-0'),
      stageSVG: $('#stage-svg-0'),
      tlIn: new TimelineMax(),
      twIn: null
    },
    activeSVG = svgObj;

function getStageDimensions() {
  var stage = $('#stage');
  return {wd: parseInt(stage.attr('width')), ht: parseInt(stage.attr('height'))};
}

function getStageHeight() {
  return getStageDimensions().ht;
}

function getStageWidth() {
  return getStageDimensions().wd;
}
/************************************************************* /\\
 * IN TWEENS
 ************************************************************** */
function inTopLeft(svgObj, gp, dur, start) {
  var svg = svgObj.el;
  var X = 0 - parseInt(svg.attr('width'));
  var Y = 0 - parseInt(svg.attr('height'));
  return TweenMax.from($(gp), dur, {y: Y, x: X, overwrite:'all',onOverwrite:overwrittenTween} ).startTime(start);
}

function inTop(svgObj, gp, dur, start) {
  var stageWd = getStageWidth();
  var svg = svgObj.el;
  var X = (stageWd/2) - (parseInt(svg.attr('width')))/2;
  var Y = 0 - parseInt(svg.attr('height'));
  return TweenMax.from($(gp), dur, {y: Y, x: X, overwrite:'all',onOverwrite:overwrittenTween} ).startTime(start);
}

function inLeft(svgObj, gp, dur, start) {
  var svg = svgObj.el;
  var stageHt = getStageHeight();
  var X = 0 - parseInt(svg.attr('width'));
  var Y = (stageHt/2) - (parseInt(svg.attr('height'))/2);
  return TweenMax.from($(gp), dur, {x: X, y: Y, overwrite:'all',onOverwrite:overwrittenTween} ).startTime(start);
}

function overwrittenTween(data) {
  // this is never running?
  console.log('ran overwrittenTweenTween');
  console.log(data);
}

/************************************************************* /\\
 * IN-BUTTON CLICK LISTENER
 ************************************************************** */
$('.in-buttons button').on('click', function(event){
  // event.stopPropagation();
  // animate the group that wraps the svg to move it around on the stage
  var gp = $(activeSVG.gp);
  var funcStr = $(this).data("in-func");

  var dur = 1;
  var startTime = 0;
  var firstTime = (activeSVG.twIn == null) ? true : false;

  activeSVG.twIn = eval(funcStr)(activeSVG,gp,dur,startTime);
  activeSVG.tlIn.add(activeSVG.twIn);
  if(firstTime) {
    masterTL.add(activeSVG.tlIn);
  }
  masterTL.play();

  var theTweens = masterTL.getChildren();
  console.log("theTweens",theTweens);
});

/************************************************************* /\\
 * EASE-BUTTON CLICK LISTENER
 ************************************************************** */
$('.ease-buttons button').on("click", function(event){
  // event.stopPropagation();
  // add ease
  var newEase = $(this).attr("class");
  console.log(newEase);
  activeSVG.twIn.vars.ease = newEase;
  activeSVG.twIn.seek(0).invalidate();
  masterTL.play();
});

              
            
!
999px

Console