Scroll · 12 of 34

Clip Reveal

Content is unmasked from one edge as it enters view, as if a curtain is pulled back. A clip-path inset that animates to zero, leaving the element itself in place.

HTML · CSS · JavaScript · No dependencies · MIT

HTML

<section class="clip-reveal-section">
  <h2>Clip Reveal</h2>
</section>

CSS

.clip-reveal-section {
  min-height: 35vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clip-reveal-section h2 {
  font-size: 2.5rem;
  color: #f0f0f5;
  clip-path: inset(0 100% 0 0); /* fully clipped from the right */
  transition: clip-path 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.clip-reveal-section.in-view h2 {
  clip-path: inset(0 0 0 0);
}

JavaScript

var section = document.querySelector('.clip-reveal-section');

new IntersectionObserver(function (entries) {
  entries.forEach(function (entry) {
    entry.target.classList.toggle('in-view', entry.isIntersecting);
  });
}, { threshold: 0.25 }).observe(section);