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

              
                <svg width="100%" height="100%" viewBox="0 0 700 700">
  <line x1="0" x2="700" y1="701" y2="701" stroke="#ccc" stroke-width="2" />
  <path id="bounce" fill="none" stroke="#336633" stroke-width="4px"/>
  <path id="squish" fill="none" stroke="#663333" stroke-width="4px"/>
  <circle id="ball" fill="blue" r="75" cx="350" cy="75"/>
</svg>

              
            
!

CSS

              
                body {
  background-color: black;
}
svg {
  position:absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  overflow: visible;
  transform: translate(-50%,-50%);
}
              
            
!

JS

              
                /*
Demonstrates the new CustomBounce ease that'll create a bouncing CustomEase according to the parameters you feed in (like strength and squash)
and also [optionally] create an accompanying "squash" ease curve that is perfectly synchronized with the bounce so that you can apply
other complimentary effects that kick in on the bounce (typically squashing/stretching). 

Special properties:

- strength: a value between 0 and 1 (default: 0.7) that controls the bounciness. The higher the number, the more bouncy.

- squash: A number that controls how much of a gap is introduced between each bounce to make room for the "squash" to happen. A common value is 2. Default is 0 (no squash)

- jump: if true, the bounce will end where it starts, meaning it'll act like it's jumping toward whatever value you define, and then falls back toward the starting value.

- squashID: The ID (name) that you want assigned to the squish CustomEase. By default, it will simply append "-squash" to the name you give the bounce. 

In the example, the green line is the bounce, and the brown line is the accompanying squash ease. Play with the strength/squash values and see what happens.

If you think about the physics of a ball bouncing (one that’s really bouncy/squashy), when it hits the ground it doesn’t INSTANTLY go back up; it strikes, compresses (so it’s still on the ground this whole time), then transfers energy back up and takes off again. That's the "stick" or gap in the bounce. The squash.
*/

CustomBounce.create("myBounce", {strength:0.9, squash:2, squashID:"myBounce-squash"});

//the bounce:
var duration = 5;
TweenMax.to("#ball", duration, {delay:0.2, y:550, ease:"myBounce", repeat:8, repeatDelay:0.5});
//the squish which affects scaleX and scaleY. To make the effect stronger/weaker, just change the scaleX/scaleY values:
TweenMax.to("#ball", duration, {delay:0.2, scaleX:1.34, scaleY:0.5, ease:"myBounce-squash", transformOrigin:"bottom center", repeat:8, repeatDelay:0.5});


//graph the lines...
document.getElementById("bounce").setAttribute("d", CustomEase.getSVGData("myBounce", {width:700, height:500}));
document.getElementById("squish").setAttribute("d", CustomEase.getSVGData("myBounce-squash", {width:700, height:500}));

//watch the video: https://www.youtube.com/watch?v=GjXUhpYA168
              
            
!
999px

Console