<div class="animatable-element supersonic-element">
  I'm an animatable element, start scrolling to see me animating<br />
  My animation duration is 2.5s, which means it will be played 4 times on scroll (total duration is always 10s, which is driver.progress * 10000)
</div>

<div class="start supersonic-driver">
  I'm a driver, I start an animation when I appear
</div>

<div class="end supersonic-driver">
  I'm a driver, I finish an animation when I appear
</div>
.start {
  position: absolute;
  top: 100vh;
}

.end {
  position: absolute;
  top: 200vh;
}

.animatable-element {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 10;
  translate: -50% 0 0;

  animation-name: animation;
  animation-duration: 2.5s; /* This is required */
  animation-play-state: paused; /* This is required, playback is controlled by plugin */
  animation-timing-function: linear; /* This is recommended so that your animation will be consistent */
  animation-direction: alternate;
  animation-iteration-count: 4;
}

@keyframes animation {
  to {
    scale: 1.5;
    opacity: 0;
  }
}
import { TheSupersonicPlugin } from "https://esm.sh/the-supersonic-plugin-for-scroll-based-animation@2.1.0";

new TheSupersonicPlugin([
  {
    start: ".start",
    end: ".end",
    elements: [".animatable-element"]
  }
]);

External CSS

  1. https://the-illarionov.com/assets/main.css

External JavaScript

This Pen doesn't use any external JavaScript resources.