ぬるっと出てくるテキスト

モーション種別
  • スーッと系
コンポーネント
  • テキスト
トリガー
  • スクロール
技術
  • CSSのみ

テキストが1文字ずつぬるっと出てくるテキストです。
落ち着いたアニメーションなので、上品な印象になります。

clip-pathにて1文字ずつ出てくる様子を表現しています。
clip-pathで要素の面積をゼロにするとJavaScriptのIntersectionObserverで監視ができないので、.text自体にはclip-pathをつけず、@keyframes内でclip-pathの伸縮を定義しています。

コードサンプル

HTML

<p class="text js-scroll-anim">TEXT TEXT</p>

CSS

.text {
  display: inline-block;
  opacity: 0;
}
.text.is-active {
  animation: smoothly 1s;
  animation-fill-mode: forwards;
}
@keyframes smoothly {
  0% {
    clip-path: inset(0 100% 0 0);
    opacity: 1;
  }
  100% {
    clip-path: inset(0);
    opacity: 1;
  }
}

JavaScript

document.addEventListener("DOMContentLoaded", function () {
  const scrollTriggers = document.querySelectorAll(".js-scroll-anim");

  const revealObserver = new IntersectionObserver(
    entries => {
      entries.forEach(entry => {
        if (entry.isIntersecting) {
          entry.target.classList.add("is-active");
          revealObserver.unobserve(entry.target);
        }
      });
    },
    {
      threshold: 0.1,
    }
  );

  scrollTriggers.forEach(el => {
    revealObserver.observe(el);
  });
});

お問い合わせ Contact

制作のご依頼やその他ご相談は、お問い合わせフォームにて受け付けております。

お問い合わせフォームへ