<div class="animatable-element supersonic-element">
  I'm an animatable element, start scrolling to see me animating<br />
  Once I will be played to the end I will stop rendering
</div>

<div class="animatable-element-2 supersonic-element">
  I'm an animatable element, start scrolling to see me animating<br />
  I am rendering as usual
</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,
.animatable-element-2 {
  position: fixed;
  left: 18px;
  top: 50%;
  z-index: 10;

  animation-name: animation;
  animation-duration: 10s; /* 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-fill-mode: forwards; /* This is recommended so that your animation holds last frame on finish */
}

.animatable-element-2 {
  left: auto;
  right: 18px;
}

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

new TheSupersonicPlugin([
  {
    start: ".start",
    end: ".end",
    elements: [
      {
        selector: ".animatable-element",
        animations: [
          {
            name: "animation",
            hooks: {
              onInit(animation) {
                animation.data.isRendering = true;
              },
              onBeforeRender(animation) {
                if (animation.driver.progress === 1)
                  animation.data.isRendering = false;
                return animation.data.isRendering;
              }
            }
          }
        ]
      },
      ".animatable-element-2"
    ]
  }
]);

External CSS

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

External JavaScript

This Pen doesn't use any external JavaScript resources.