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

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

              
                <div class="floater-wrapper">
	<div class="floater">
		Here is some text in a floater.
	</div>	
</div>
<h2>Two examples of GSAP TimelineMax in action</h2>
<p>Open the console then click on the Squish button or the floating footer a few times.</p>
<p>Why does <b>resetTL()</b> think the first parameter is undefined ("Cannot read property 'progress' of undefined")? Note the string parameter - which I have included for reference - is working as expected, as you can see from the console.log output.</p>
 <section class="div_morphs">
	 <p>
	 	<button type="button" id="squish">Squish</button>
	 </p>
	 <div class="outer">
	 		<table>
	 		    <thead>
			 			<tr>
			 				<th>Name</th>
			 			</tr>
	 		    </thead>
	 		    <tbody>
			 			<tr>
			 				<td>Apple</td>
			 			</tr>
			 			<tr>
			 				<td>Banana</td>
			 			</tr>
			 			<tr>
			 				<td>Carrot</td>
			 			</tr>
			 			<tr>
			 				<td>Durian</td>
			 			</tr>
			 			<tr>
		 				  <td>Elderberry</td>
			 			</tr>
			 			<tr>
			 				<td>Fruit</td>
			 			</tr>
	 		    </tbody>
	 		</table>
	 </div>
</section>




              
            
!

CSS

              
                body {
  margin: 30px;
  font-family: sans-serif;
  background-color: grey;
  position: relative;
}

table {
  background-color: white;
  border-collapse: collapse;
}

td, th {
  border: 1px solid black;
  padding: 5px 8px;
}

.outer {
  overflow: hidden;
}

.floater-wrapper {
  left: 0;
  right: 0;
  top: 0;
  position: fixed;
  bottom: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 9;
}

.floater {
  position: absolute;
  background-color: lightgrey;
  padding: 15px 17px;
  box-sizing: border-box;
  width: 100%;
  bottom: 0;
  pointer-events: auto;
  cursor: pointer;
}

.floater:hover {
  background-color: green;
  color: white;
}

              
            
!

JS

              
                // // For the table squish
var tl4 = new TimelineMax({ paused: true });
var tl5 = new TimelineMax({ paused: true });
var lastPlayed = null;

var tbl = $(".outer table");
tbl.attr("original_height", tbl.outerHeight());
tbl.attr("final_height", tbl.find("thead").outerHeight());

tl4.to(
  ".outer",
  0.5,
  { height: tbl.attr("final_height"), ease: Bounce.easeOut },
  "h0"
);

tl5.to(
  ".outer",
  0.5,
  { height: tbl.attr("original_height"), ease: Bounce.easeOut },
  "h1"
);

$("#squish").on("click", function(e) {
  if (tl4.isActive() || tl5.isActive()) {
    return;
  }

  if (lastPlayed !== tl4) {
    lastPlayed = tl4;
    tl4.play(0);
  } else {
    lastPlayed = tl5;
    tl5.play(0);
  }
});

              
            
!
999px

Console