Skip to main content
The Deno 2 Release Candidate is here
Learn more

Scroll Cat

I want to catch the best scene of my life. The browser wants to, too.

version ci api license

There are too many good works in the world that are a hundred times better than my work, both in terms of performance and stability, so make sure you use them first.

If you are really ready to waste time on this crappy work, please run:

npm install scrollcat

Usage

import { Scroller } from "scrollcat";

const life = new Scroller(document.body);
catchScene(document.querySelector("#a"));
catchScene(document.querySelector("#b"));

async function catchScene(el) {
  const scene = life.addSceneWithDefault(el);

  for await (const [type, event] of scene.emitter) {
    const { progress, target } = event;
    if (type !== "update") {
      console.log(type, event);
    }
    target.textContent = `${(progress * 100).toFixed(2)}%`;
  }
}