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">
  <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>
<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">

        <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

              
                body, html {
  background: #efefef;
}

h3 { color: #000; }

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

.buttons-wrapper {
  display: block;
  width: 800px;
  margin: 0 auto;
}

.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: 0 auto 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(),
    timelineIn = new TimelineMax(),
    tweenIn = null;

/************************************************************* /\\
 * IN TWEENS
 ************************************************************** */
function inTopLeft(easeVal) {
  easeVal = (easeVal === undefined) ? 'Power0.easeNone' : easeVal;
  return TweenMax.from($('#gp-0'), 1, {y: -170, x: -170, ease: easeVal, overwrite:'auto',onOverwrite:overwrittenTween} );
}

function inTop(easeVal) {
  easeVal = (easeVal === undefined) ? 'Power0.easeNone' : easeVal;
  return TweenMax.from($('#gp-0'), 1, {y: -170, x: 315, ease: easeVal, overwrite:'auto',onOverwrite:overwrittenTween} );
}

function inLeft(easeVal) {
  easeVal = (easeVal === undefined) ? 'Power0.easeNone' : easeVal;
  return TweenMax.from($('#gp-0'), 1, {x: -170, y: 215, ease: easeVal, overwrite:'auto',onOverwrite:overwrittenTween} );
}

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

// for testing, start the svg already placed. start in the middle

TweenMax.set("#gp-0", {x: 315, y: 215});

/************************************************************* /\\
 * IN-BUTTON CLICK LISTENER
 ************************************************************** */
$('.in-buttons button').on('click', function(){
  // get the name of the function to run from the button clicked
  var funcStr = $(this).data("in-func");
  
  var newTween;
  
  // check to see if the tween has already been set...
  var firstTime = (tweenIn == null) ? true : false;
  // if already set, get the current ease value and reset the newTween object
  if( !firstTime ) {
    var easeVal = tweenIn.vars.ease;
    newTween = eval(funcStr)(easeVal); // this time pass the ease value
    // move the SVG to the end position and then kill the current tween
    tweenIn.seek(1).kill();
    // remove the nested timeline from the master timeline
    masterTL.remove(timelineIn);
  } else {
    // get the new tween obj from one of the functions above
    newTween = eval(funcStr)();
  }
  
  tweenIn = newTween;
  timelineIn.add(tweenIn);
  masterTL.add(timelineIn);
  masterTL.play();
  
  // checking to be sure there's only one nested timeline tween
  var theTweens = masterTL.getChildren();
  console.log("theTweens",theTweens);
});

/************************************************************* /\\
 * EASE-BUTTON CLICK LISTENER
 ************************************************************** */
$('.ease-buttons button').on("click", function(){
  if(tweenIn == null) { return; }
  // get the ease value from the click
  var newEase = $(this).attr("class");
  
  // snag the existing tween's vars
  var cssObj = tweenIn.vars.css;
  cssObj.ease = newEase;
  cssObj.overwrite = overwrite;
  var overwrite = tweenIn.vars.overwrite;
  
  // move the SVG to the end position and then kill the current tween
  tweenIn.seek(1).kill();
  // remove the nested timeline from the master timeline
  masterTL.remove(timelineIn);

  // reset everything and play
  tweenIn = TweenMax.from($('#gp-0'), 1, cssObj);
  timelineIn.add(tweenIn);
  masterTL.add(timelineIn);
  masterTL.play();
});

              
            
!
999px

Console