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

              
                <h3>Bouncing Ball GSAP and SVG Test</h3>
<div id="main">
  <svg id="bouncing-ball" viewbox="0 0 600 400">
    <g id="ball">

      <g id="mc_shadow_path">
        <g id="mc_shadow" transform="matrix(1 0 0 1 300 324)">
          <path fill="#222222" d="M28.3,-4.1Q16.6,-5.8 0,-5.8 -16.6,-5.8 -28.3,-4.1 -40,-2.4 -40,0 -40,2.5 -28.3,4.2 -16.6,5.9 0,5.9 16.6,5.9 28.3,4.2 40.1,2.5 40.1,0 40.1,-2.4 28.3,-4.1" />
        </g>
      </g>


      <g id="mc_ball" transform="matrix(1 0 0 1 300 279)">
        <g id="mc_ball_base">

          <path fill="#EA512D" d="M19,-33.1Q30,-29.1 38.9,-20.1 40.4,-18.6 41.8,-17.1 41.7,-17.2 41.7,-17.3 38.4,-25.2 31.8,-31.8 18.7,-45 0,-45 -9.6,-45 -17.8,-41.5 -20.4,-37.2 -23.2,-32.3 -23.3,-32.2 -23.3,-32 -23.4,-31.9 -23.5,-31.8 -22.6,-31.9 -20.1,-33.4 -19.7,-33.5 -19.4,-33.6 -10.7,-36.6 -0.8,-36.6 9.8,-36.6 19,-33.1"
          />
          <path fill="#FFFFFF" d="M38.9,-20.1Q30,-29.1 19,-33.1 9.8,-36.6 -0.8,-36.6 -10.7,-36.6 -19.4,-33.6 -19.7,-33.5 -20.1,-33.4 -22.6,-31.9 -23.5,-31.8 -23.4,-31.9 -23.3,-32 -23.3,-32.2 -23.2,-32.3 -20.4,-37.2 -17.8,-41.5 -25.4,-38.2 -31.7,-31.9 -31.3,-32 -30.5,-32.1 -29.7,-32.3 -27.1,-32 -25.4,-31.9 -24.4,-31.7 -24.2,-31.7 -24.1,-31.7 -23.8,-31.7 -23.5,-31.6 -23.5,-31.7 -23.5,-31.7 0.2,-27.5 15.6,-12.1 33,5.3 34,29.5 45,17 45,0 45,-8 42.6,-14.9 42.2,-16.1 41.8,-17.1 40.4,-18.6 38.9,-20.1"
          />
          <path fill="#EA512D" d="M-31.7,-31.9Q-31.7,-31.9 -31.8,-31.8 -32.5,-31.1 -33.1,-30.4 -37.3,-25.9 -40,-20.8 -40.1,-20.6 -40.3,-20.3 -40.1,-20.5 -40,-20.6 -32.9,-27.2 -23.8,-31.3 -25.9,-20.5 -25.9,-11 -25.9,13.9 -8.4,31.4 -0.2,39.6 9.7,44 22.2,41.4 31.8,31.8 32.9,30.7 34,29.5 33,5.3 15.6,-12.1 0.2,-27.5 -23.5,-31.7 -23.5,-31.7 -23.5,-31.6 -23.8,-31.7 -24.1,-31.7 -24.2,-31.7 -24.4,-31.7 -25.4,-31.9 -27.1,-32 -29.7,-32.3 -30.5,-32.1 -31.3,-32 -31.7,-31.9"
          />
          <path fill="#FFFFFF" d="M-23.7,-31.3Q-23.7,-31.3 -23.7,-31.3L-23.9,-30.3Q-23.8,-30.5 -23.7,-31.3" />
          <path fill="#FFFFFF" d="M-40,-20.6Q-40.1,-20.5 -40.3,-20.3 -45,-11.1 -45,0 -45,18.7 -31.8,31.8 -18.6,45 0,45 5,45 9.7,44 -0.2,39.6 -8.4,31.4 -25.9,13.9 -25.9,-11 -25.9,-20.5 -23.8,-31.3 -32.9,-27.2 -40,-20.6" />
          <path fill="none" stroke="#4C526C" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" d="M0,-45Q-9.6,-45 -17.8,-41.5 -25.4,-38.2 -31.7,-31.9 -31.7,-31.9 -31.8,-31.8 -32.5,-31.1 -33.1,-30.4 -37.3,-25.9 -40,-20.8 -40.1,-20.6 -40.3,-20.3 -45,-11.1 -45,0 -45,18.7 -31.8,31.8 -18.6,45 0,45 5,45 9.7,44 22.2,41.4 31.8,31.8 32.9,30.7 34,29.5 45,17 45,0 45,-8 42.6,-14.9 42.2,-16.1 41.8,-17.1 41.7,-17.2 41.7,-17.3 38.4,-25.2 31.8,-31.8 18.7,-45 0,-45"
          />
        </g>

        <!-- ball shade -->
        <path id="ball_shade" fill="#666" fill-opacity="0.6" d="M31.7,31.8Q35.3,28.2 37.9,24.2 25.4,29 10.9,29 -20.1,29 -42.1,7 -43.6,5.5 -45,4 -43.7,20.1 -31.9,31.8 -18.8,45 -0.1,45 18.5,45 31.7,31.8" />
      </g>
    </g>
  </svg>

  <div id="ground"></div>
  <div id="sky"></div>


</div>
              
            
!

CSS

              
                html, body {
  height:100%;
}

body {
  background-color: #CCC;
  margin: 0;
  padding: 0;
}

h3 {
  font-size:22px;
  font-family:"Open Sans", Arial;
  line-height:1em;
  font-weight:bold;
  margin-left:1em;
  white-space:nowrap;
}

/* main wrapper */

#main {
  background: #666;
  width: 600px;
  /*100%*/
  /* makes responsive */
  
  height: 400px;
  /*100%*/
  /* makes responsive */
  
  position: relative;
  /* absolute */
  margin-left:1.5em;
  border:1px solid #777;
}


/* foreground and background */

#sky {
  background:#49cfef;
  background: linear-gradient(to bottom, #49cfef, #a7f3f2);
  
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 70%;
  /*300px*/
  
  z-index: 0;
}

#ground {
  background:#666;
  background: linear-gradient(to bottom, #666666, #999999);
    
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30%;  
  z-index: 0;
}
/* svg styles */

svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

#mc_shadow {
  position: absolute;
  left: 300px;
  top: 324px;
}

#mc_shadow #shadow_path {
  fill-opacity: 1;
}

#mc_ball {
  position: absolute;
  top: 0;
  left: 300px;
  top: 279px;
}

#mc_ball_base {
  position: absolute;
  top: 0;
}
              
            
!

JS

              
                $(document).ready(function() {

  TweenLite.set("#mc_shadow", {
    transformOrigin: "50% 50%",
    x: 300,
    y: 324
  });

  TweenLite.set("#mc_ball", {
    transformOrigin: "50% 50%",
    x: 300,
    y: 279
  });

  TweenLite.set("#mc_ball_base", {
    transformOrigin: "50% 50%"
  });

  $(window).on("load", function() {

    // setup 1st master timeline
    var bounceTL = new TimelineMax({
      paused: true,
      repeat: -1
    });

    ////////////////////////////////////////////
    /* ball bounce up and down child timeline */
    function ballBounce() {

      var tl = new TimelineMax();

      tl

      /* ball bounce up */
        .to("#mc_ball", 0.5, {
        transformOrigin: "50% 50%",
        y: 90,
        ease: Circ.easeOut
        //ease: Power1.easeInOut
      }, "bounce")

      /* ball bounce down */
      .to("#mc_ball", 0.4, {
        transformOrigin: "50% 50%",
        y: 279,
        ease: Circ.easeIn
          //ease: Power1.easeInOut
      }, "bounce2")

      /* ball squash */
      .to("#mc_ball", 0.15, {
        transformOrigin: "50% 100%",
        scaleX: 1.5,
        scaleY: 0.6,
        ease: Power1.easeInOut
        //ease: Bounce.easeOut
      }, "bounce3-=0.04")

      /* ball rotateZ around */
      .to("#mc_ball_base", 1, {
        force3D: true,
        rotation: "+=360",
        ease: Power0.easeNone
      }, "bounce")

      return tl;
    }

    ////////////////////////////////////////
    /* ball shadow stretch child timeline */
    function ballShadow() {

      var tl = new TimelineMax();

      tl

      /* ball shadow stretch */
        .to("#mc_shadow", 0.5, {
          transformOrigin: "50% 50%",
          autoAlpha: 0.15,
          scaleX: 1.7,
          scaleY: 1.2,
          ease: Power1.easeInOut
        }) //, "bounce"

      /* ball shadow normal */
      .to("#mc_shadow", 0.5, {
          transformOrigin: "50% 50%",
          autoAlpha: 1,
          scaleX: 1,
          scaleY: 1,
          ease: Power1.easeInOut
        }) //, "bounce2"

      return tl;
    }

    window.requestAnimationFrame(function() {

      //////////////
      /* masterTL */

      bounceTL
        .add(ballBounce(), "ball")
        .add(ballShadow(), "ball")

        .progress(1).progress(0)
        //.timeScale(0.9)
        .play();

    });

  });

});
              
            
!
999px

Console