Scroll · 19 of 34

Scale + Rotate

Content scales up while rotating into alignment, a slightly more dramatic take on Scale Up. Two transforms on one transition.

HTML · CSS · JavaScript · No dependencies · MIT

HTML

<section class="scale-rotate-section">
  <h2>Scale + Rotate</h2>
</section>

CSS

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

.scale-rotate-section h2 {
  font-size: 2.5rem;
  color: #f0f0f5;
  opacity: 0;
  transform: scale(0.5) rotate(-20deg);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.scale-rotate-section.in-view h2 {
  opacity: 1;
  transform: scale(1) rotate(0);
}

JavaScript

var section = document.querySelector('.scale-rotate-section');

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