Pen Settings



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


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


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.


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.


I did all the art. You can read the full version here: 

=-->  <div class="alice-falling" id="alice"></div>
  <div id="tunnel" class="frightened">
      <div class="page page_falling falling_frightened" data-mood="frightened">
          <p>Either the well was very deep or she fell very slowly, for she had plenty of time to look about her on the way down.</p>
      <div class="page page_falling falling_curious" data-mood="curious">
          <p>At first it was too dark for her to see anything, but as her eyes adjusted, she could make out what seemed to be cupboards, bookshelves, paintings, lining the walls she was rushing past. </p>
      <div class="page page_falling falling_bored" data-mood="bored">
          <p>Down, down, down she fell. Would it never come to an end? She began to wonder how many miles she’d fallen and whether she’d end up at the center of the Earth&mdash;or come out the other side!</p>
      <div class="page page_falling falling_sleeping" data-mood="sleeping">
          <p>How would she call her sister? What if she didn’t speak the language? What if they couldn’t understand her and put her in an orphanage? She’d never see her sister or her cat again!</p>
      <div class="page page_falling falling_waking" data-mood="waking">
          <p>Poor Tuna! Would they remember to clean his litter box or give him his kibble? If only Tuna were with her now. There were no mice to live on in the air, but perhaps he could catch a bat. </p>

          <!-- Wait 3 seconds or so for the video to end. Then return to the scene -->
      <div class="page page_falling falling_weird" data-mood="weird">
          <p>Before she could worry too much, her eyes grew heavy and she began to nod off whispering, “Do cats eat bats?” to no one in particular.</p>
      <div class="page page_falling falling_aftermath" data-mood="jolted">
          <p>She must’ve been dreaming, because for a moment she imagined he was there with her, as large as her sister.</p>
      <div class="page page_falling falling_lookit-cat" data-mood="jolted"></div>
      <div class="page page_falling falling_cat-reveal" data-mood="jolted"></div>
      <div class="page page_falling falling_cat-out" data-mood="jolted">
          <p>&ldquo;Oh yes, cats eat bats all the time. You wouldn’t happen to be a bat, now would you?&rdquo;</p>


                #tunnel {
  position: relative;
  top: 0; left: 0;
  background: url( 0 0 repeat-y, url( 100% 0 repeat-y, url( top center repeat-y, url(, #6c373f;
  background-size: 20px 150px,  20px 150px,  80% auto, auto auto;

.page {
  /* Each page has a 3/4 ratio */
  padding-top: 100vh;
  /* Hide the text */
  text-indent: 100%;
	white-space: nowrap;
	overflow: hidden;

.alice-falling {
  background-image: url('');
  background-size: 100% auto;
  width: 31.25%;
  padding-top: 48.73047%;
  top: -10%;
  left: 50%;
  margin-left: -15.625%;
  position: fixed;
  z-index: 20;

.curious .alice-falling {
  background-position: 0 20%;

.bored .alice-falling {
  background-position: 0 80%;

.sleeping .alice-falling {
  background-position: 0 60%;

.waking .alice-falling {
  background-position: 0 100%;

.weird .alice-falling {
  background-position: 0 0;

.jolted .alice-falling {
  background-position: 0 40%;

@keyframes freak-out {
  0% {
    background-position: 0 0;
  100% {
    background-position: 0 200%;

.frightened .alice-falling {
  animation: freak-out 1.5s steps(2) infinite;
  background: url('') 0 0 no-repeat;
  background-size: 100% auto;


                // Goal: recreate the behavior of
// with native support for Intersection observer and WAAPI
var body = document.body;

 // For parallax:
 // Create animation moving Alice from top to bottom.
 var aliceDuration = 8000;
 var alice = document.getElementById('alice').animate(
    { top: '-10%' },
    { top: '80%' }   
  ], { 
    duration: aliceDuration, 
    easing: 'ease-in', 
    fill: 'both'


 // Get the length of the doc
 var docLength = body.innerHTML.length;
 // and current scroll position
 var scrollPosition = window.scrollY;

 // what percentage along we are.
 var scrollProgress = scrollPosition/docLength;

 // update onScroll
  window.addEventListener('scroll', function(){
   docLength = body.scrollHeight;
   scrollPosition = window.scrollY;
   scrollProgress = scrollPosition/docLength;
   alice.currentTime = aliceDuration * scrollProgress;

 // TODO
 // throttle scroll event
 // rehash all on resize

 // Ok, now let's convert to intersection observer.
 // Via
 // 'splains all the ES6. This is how I learn this stuff. Grump grump.

  // what we want to fire when we scroll different "pages" into view
  function updateMood(entry) {
      var currentMood = entry[0].target.getAttribute("data-mood");

  // list of options
  // more on thresholds:
  let options = {
    threshold: [0.5]

  // instantiate a new Intersection Observer
  let observer = new IntersectionObserver(updateMood, options); 

  // list of "pages" that update her mood.
  let elements = document.querySelectorAll('.page');

  // loop through all elements
  // pass each element to observe method
  // ES2015 for-of loop can traverse through DOM Elements
  for (let elm of elements) {