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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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,600' rel='stylesheet' type='text/css'>
<form>
	<div id="controls">
		<li style="padding-left:20px;">
			<div>Boxes: <select id="boxes">
					<option value="50">50</option>
					<option value="100">100</option>
					<option value="250">250</option>
					<option value="500">500</option>
					<option value="1000" selected>1000</option>
					<option value="2000" >2000</option>
					<option value="3000">3000</option>
					<option value="4000">4000</option>
				</select>
			</div>
			<div>
				stagger: <select id="stagger">
					<option value="0" selected>none</option>
					<option value="0.001">slight (1ms)</option>
					<option value="0.005">moderate (5ms)</option>
					<option value="0.02">large (20ms)</option>
				</select>
			</div>
		</li>
		<li>

		</li>
		<li style="border-left:1px solid #333;">
			<div>
				<label><input type="checkbox" id="lazy" /> lazy <span style="font-style: italic;">(enabled by default in 1.12.0)</span></label>
			</div>
			<div>
					<label><input type="checkbox" id="lagSmoothing" /> lagSmoothing</label> <div style="display:inline-block; vertical-align:top;"><div><span>threshold:</span><select id="threshold" disabled>
						<option value="50">50</option>
						<option value="100">100</option>
           <option value="200">200</option>
						<option value="300">300</option>
           <option value="500" selected>500 (default)</option>
						<option value="1000">1000</option>
           <option value="2000">2000</option>
						<option value="0">none</option>
					</select></div><div><span>adjustedLag:</span> <select id="adjustedLag" disabled>
						<option value="0">0</option>
           <option value="16">16</option>
           <option value="33" selected>33 (default)</option>
						<option value="50">50</option>
						<option value="100">100</option>
						<option value="250">250</option>
           <option value="500">500</option>
						<option value="1000">1000</option>
					</select></div>
				</div>
			</div>
		</li>
		<li style="border-left:1px solid #333;">
			<div id="start">RUN TEST</div>
      <div id="time" style="color:#F90; margin-top:5px;"></div>
		</li>
		<li style="width:70%;"></li>
	</div>
</form>
<div id="container"></div>
              
            
!

CSS

              
                body {
  background-color: black;
  margin:0;
  padding:0;
  color:#ccc;
  font-family: Signika Negative, sans-serif;
  font-weight: 300;
  font-size: 1.15em;
}
strong {
  font-weight: 600;
  color: white;
}
.feature {
  width:48%;
  float:left;
  margin: 1%;
  padding: 10px;
  border: 1px solid #444;
  box-sizing: border-box;
  background-color: #222;
}
h1 {
  color: white;
  font-weight: normal;
  padding: 10px 20px;
  margin-bottom: 0;
  clear:both;
}
h2 {
  padding: 0;
  margin: 0;
  color: white;
  font-weight: normal;
  clear:both;
}
#container {
  color: #555;
  line-height: 0;
  height: 300px;
  overflow: hidden;
  user-select:none;
  -webkit-user-select:none;
  pointer-events: none;
}
#container div {
  display:inline-block;
  position:relative;
  width: 5px;
  height: 5px;
  border: 1px solid black;
  background-color: blue;
}
button {
  font-size: 20px;
  padding: 10px;
}
pre {
  overflow:auto;
  border: 1px solid #444;
  padding: 6px;
  background-color: #000;
  color: white;
}
code {
  color: white;
  font-size: 1.2em;
  padding: 3px 3px;
}
form {
  clear:both;
  display:table;
  width:100%;
  height:100%;
}
a {
  color: #71B200;
}
#controls {
  display:table-row;
  width: 100%;
  background-color:#555;
  background: linear-gradient(to bottom,  #777 0%,#444 100%);
  padding:10px 10px 10px 5px;
  z-index:1000;
}
#controls li {
  display:table-cell;
  padding:12px 8px 10px 8px;
  vertical-align:middle;
  text-shadow: 1px 1px 1px #000;
  white-space: nowrap;
  color: white;
}
#start {
  color: black;
  border-radius: 6px;
  padding: 5px 18px;
  border: 2px solid black;
  background: #9af600;
  background: linear-gradient(to bottom,  #9af600 0%,#71B200 100%);
  cursor: pointer;
  text-shadow: none;
  font-weight: 400;
  display:inline-block;
  text-align: center;
}
#controls li span {
  color: #ccc;
  font-size:13px;
}
              
            
!

JS

              
                var container = document.getElementById("container"),
		boxes = [],
		$lagSmoothing = $("#lagSmoothing"),
		$threshold = $("#threshold"),
		$adjustedLag = $("#adjustedLag"),
    isFirefox = (navigator.userAgent.indexOf("Firefox") !== -1),
		time;

if (isFirefox) {
  $("#boxes")[0].selectedIndex = 4; //Firefox is significantly slower, so we'll adjust the default number of boxes.
}

function createBoxes() {
	var i = parseInt($("#boxes").val(), 10),
		div;
	container.innerHTML = "";
	boxes.length = 0;
	while (--i > -1) {
		div = document.createElement("div");
		div.setAttribute("id", "div" + i);
		container.appendChild(div);
		boxes.push(div);
	}
}

createBoxes();
$("#boxes").change(createBoxes);
		$lagSmoothing.change(function() {
			var disabled = !$lagSmoothing.prop("checked");
			$threshold.prop("disabled", disabled);
			$adjustedLag.prop("disabled", disabled);
		});


$("#start").click(function() {
	var threshold = $lagSmoothing.prop("checked") ? parseInt($threshold.val(), 10) : 0;
	$("#time").text("Running... (please wait)");
  TweenLite.set(boxes, {y:0, overwrite:true});
	TweenLite.set("#start", {opacity:0.5});
	TweenLite.lagSmoothing(threshold, parseInt($adjustedLag.val(), 10) );
	setTimeout(runTest, 10); //wait for a moment just so that the browser renders the changes to the button and text before the CPU-intensive test runs.
});

function runTest() {
	var i = boxes.length,
		lazy = !!$("#lazy").prop("checked"),
		stagger = parseFloat($("#stagger").val()),
		num = 0;
	while (--i > 0) {
		boxes[i]._gsTransform = null; //remove any cashed transform values, otherwise things would be much faster. We're trying to make it act like things are running for the first time every time.
		TweenLite.to(boxes[i], 2, {y:150, lazy:lazy, overwrite:true, ease:Linear.easeNone, delay:++num * stagger});
	}
	//attach an onStart to the very last one so we can report the time.
	TweenLite.to(boxes[0], 2, {y:150, lazy:lazy, onStart:reportTime, overwrite:true, ease:Linear.easeNone, delay:num * stagger, onComplete:function() {
    //return the boxes back to their start after 4 seconds.
    TweenLite.set(boxes, {y:0, delay:4});
  }});
	time = Date.now();
}

function reportTime() {
	if ( parseFloat($("#stagger").val()) === 0) {
		$("#time").text("Took " + (Date.now() - time) + "ms to start");
	} else {
		$("#time").text("");
	}
	TweenLite.set("#start", {opacity:1});
}
              
            
!
999px

Console