css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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>
            
          
!
            
              /* 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;
}
            
          
!
            
              //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:Linear.easeNone}); // normal speed
}

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

fast.onclick = function() {
  TweenLite.to(particles, 2, {timeScale:4, ease:Linear.easeNone}); // 4 times as fast
}
  
function randomNumber(min, max){
	return Math.floor(Math.random() * (1 + max - min) + min);
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console