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

              
                <link href='//fonts.googleapis.com/css?family=Signika+Negative:300,400' rel='stylesheet' type='text/css'>

<div class="wrapper">
  <!-- <h1>Tween a tween! Huh?</h2> -->
  <h2>Tween the timeScale() of a timeline</h2>

  <p>By tweening the timeScale() of the particles timeline we can progressively speed up and slow down the entire animation with a single tween.</p>
  
  <div class="nav">
    <button id="slow">slow: timeScale(0.1)</button>
    <button id="normal">normal: timeScale(1)</button>
    <button id="fast">fast: timeScale(4)</button>
  </div>
   <div class="demo" id="bubbleContainer">
    
  </div>
  
</div>
<div class="brandBar">
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/GreenSock-logo-text-outlines.svg"></div>
              
            
!

CSS

              
                /* Global styles come from external css https://codepen.io/GreenSock/pen/JGaKdQ*/


.demo{
  background-color:black;
  width:600px;
  height:250px;
  overflow:hidden;
  position:relative;
  
}

.bubble{
  border-radius: 50%;
  position: absolute;
}

.smallBubble{
	width:20px;
	height:20px;
	background-color:#7ADD20;
}

.mediumBubble{
	width:30px;
	height:30px;
	background-color:#7ADD20;
}

.largeBubble{
	width:40px;
	height:40px;
  background-color:#7ADD20;
}

button {
  text-transform:none;
}

h1 {
  font-size:30px;
}

h2 {
  font-szie:20px;
}
              
            
!

JS

              
                //From 7 Hidden Gems of GSAP (Net Magazine)
//Read full article: https://medium.com/net-magazine/7-hidden-gems-of-the-greensock-animation-platform-4fb71389f6ca#.t6xniz19i
var sizes = ["small", "medium", "large"],
    bubbleContainer = document.getElementById("bubbleContainer"),
    slowBtn = document.getElementById("slow"),
    normalBtn = document.getElementById("normal"),
    fastBtn = document.getElementById("fast"),
    startY = 250,
    endY = -50;


//build the timeline

var particles = new TimelineMax();

for (var i = 0; i < 50; i++) {
  var sizeIndex = randomNumber(0,2); //get random number between 0 and 2
  var size = sizes[sizeIndex]; //get random size
  var speed = (3 - sizeIndex) //larger faster
  var bubble = $('<div class="bubble ' + size + 'Bubble"/>').appendTo(bubbleContainer); //create a bubble
  particles.set(bubble, {y:startY, x:300}, 0) // place it at the bottom
  
  //create an animation at a random start time
  particles.to(bubble, speed, {y:endY, x:randomNumber(0, 600), repeatDelay:Math.random()*2, repeat:500}, Math.random() * 2)
}
  
 // control the timeScale() of the timeline

normal.onclick = function() {
  TweenLite.to(particles, 2, {timeScale:1, ease:Power1.easeIn}); // normal speed
}

slow.onclick = function() {
  TweenLite.to(particles, 2, {timeScale:0.1, ease:Power1.easeIn}); // 1/10th normal speed
}

fast.onclick = function() {
  TweenLite.to(particles, 2, {timeScale:4, ease:Power1.easeIn}); // 4 times as fast
}
  
function randomNumber(min, max){
	return Math.floor(Math.random() * (1 + max - min) + min);
}
              
            
!
999px

Console