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

Or if you use Deno, don't worry, first choose one of your favorite CDNs (e.g. unpkg). All the compiled files are placed in dist/, and you only need to care about mod.js and mod.d.ts in them. If you don't know yet how Deno specifies its type declaration files when importing JS modules, please check this documentation.

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)}%`;
  }
}