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

Auto Save

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="scroller" data-splitting="">
  Scroll•Scroll•
</div>
<main>
  <ul class="backdrops">
    <li>
      <img src="https://images.unsplash.com/photo-1628174383885-642404980686?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=1080&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTY2NDIyNzYxNQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1920" width="1920" alt="">
    </li>
    <li>
      <img src="https://images.unsplash.com/photo-1519608487953-e999c86e7455?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=1080&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTY2NDIyNzYxOQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1920" width="1920" alt="">
    </li>
    <li>
      <img src="https://images.unsplash.com/photo-1515036551567-bf1198cccc35?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=1080&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTY2NDI5NTgxNQ&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1920" width="1920" alt="">
    </li>
    <li>
      <img src="https://images.unsplash.com/photo-1573455494060-c5595004fb6c?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=1080&ixid=MnwxfDB8MXxyYW5kb218MHx8Y3liZXJwdW5rfHx8fHx8MTY2NDI5NTgyNA&ixlib=rb-1.2.1&q=80&utm_campaign=api-credit&utm_medium=referral&utm_source=unsplash_source&w=1920" width="1920" alt="">
    </li>
  </ul>
  <ul class="contents">
    <li>
      <h2>Scroll</h2>
    </li>
    <li>
      <h2>Scroll more</h2>
    </li>
    <li>
      <h2>Scroll further</h2>
    </li>
    <li>
      <h2>That's it!</h2>
    </li>
  </ul>
</main>
              
            
!

CSS

              
                @import "https://unpkg.com/normalize.css" layer(normalize);
@import "https://unpkg.com/open-props/open-props.min.css" layer(open-props);
@import "https://unpkg.com/open-props/normalize.min.css" layer(open-props);

*,
*:after,
*:before {
	box-sizing: border-box;
	max-inline-size: 100%;
}

body {
	display: grid;
	place-items: center;
	height: 100vh;
	overflow: auto;
  overflow: hidden;
	font-family: 'Google Sans', sans-serif, system-ui;
}

ul {
	margin: 0;
	padding: 0;
	list-style-type: none;
}

li {
	height: 100vh;
	width: 100vw;
	padding: 0;
}

ul.backdrops {
	position: fixed;
	inset: 0;
	z-index: -1;
}

ul.contents {
	height: 100vh;
	scroll-snap-type: y mandatory;
	overflow: auto;
}

.contents > li {
	display: grid;
	place-items: center;
	scroll-snap-align: center;
}

h2 {
	font-size: var(--font-size-fluid-3);
	color: var(--gray-0);
	/* display: none; */
	background: hsl(0 0% 0% / 0.75);
	padding: 1rem;
}

img {
	height: 100%;
	width: 100%;
	object-fit: cover;
	filter: grayscale(0.5);
}

.backdrops li {
	position: absolute;
	inset: 0;
}

.backdrops li:not(:first-of-type) img {
	transform: translateY(100%);
}

.scroller {
	--radius: -2.25rem;
	text-transform: uppercase;
	color: var(--gray-0);
	font-weight: bold;
	position: fixed;
	top: 1rem;
	right: 2rem;
	aspect-ratio: 1;
	width: 6rem;
}

.scroller:before {
	content: "";
	position: absolute;
	display: block;
	inset: 0;
	border-radius: 50%;
	border: 1.5rem solid hsl(0 0% 0% / 0.75);
}

.scroller .char {
	display: inline-block;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) rotate(calc((360 / var(--char-total)) * var(--char-index) * 1deg)) translateY(var(--radius));
}

/* Do I need to build different timelines but apply to
 * different elements to get things working?
*/

/* .backdrops > li:nth-of-type(1) img {
	animation: exit both;
	animation-timeline: --one;
	animation-delay: exit 0%;
	animation-end-delay: exit 100%;
}

.backdrops > li:nth-of-type(2) img {
	animation: enter both, exit both;
	animation-timeline: --one, --two;
	animation-delay: exit 0%, exit 0%;
	animation-end-delay: exit 75%, exit 100%;
}



@keyframes exit {
	100% {
		transform: translateY(-100%);
	}
}

@keyframes enter {
	100% {
		transform: translateY(0%);
	}
} */
              
            
!

JS

              
                import Splitting from 'https://cdn.skypack.dev/splitting'

const TRIGGERS = document.querySelectorAll('.contents li')
const BACKDROPS = document.querySelectorAll('.backdrops li')
const SCROLLER = document.querySelector('.scroller')

// For each TRIGGER set up a ViewTimeline
// Then create WAAPI for each backdrop

const TIMELINES = []

TRIGGERS.forEach(subject => {
  TIMELINES.push(new ViewTimeline({
    subject,
    axis: 'block'
  }))
})

BACKDROPS.forEach((backdrop, index) => {
  const IMG = backdrop.querySelector('img')

  IMG.animate([{
    transform: 'translateY(0%)'
  }
  ], {
    timeline: TIMELINES[index - 1],
    fill: 'both',
    delay: {
      phase: 'exit', 
      percent: CSS.percent(5),
    },
    endDelay: {
      phase: 'exit', 
      percent: CSS.percent(75),
    }
  })

  IMG.animate([{
    transform: 'translateY(-50%)'
  }
  ], {
    timeline: TIMELINES[index],
    fill: 'both',
    delay: {
      phase: 'exit', 
      percent: CSS.percent(5),
    },
    endDelay: {
      phase: 'exit', 
      percent: CSS.percent(100),
    }
  })
})

// Split the progress wheel
Splitting()

SCROLLER.animate([
  {
    transform: 'rotate(360deg)'
  }
], {
  fill: 'both',
  timeline: TIMELINES[TIMELINES.length - 1],
  delay: {
    phase: 'enter',
    percent: CSS.percent(-200)
  },
  endDelay: {
    phase: 'enter',
    percent: CSS.percent(100)
  }
})
              
            
!
999px

Console