npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

easing-scroll

v1.0.5

Published

♿️ Smooth scrolling

Downloads

260

Readme

easing-scroll

npm version npm bundle size license TypeScript

Programmatic smooth scrolling with custom easing, abort support, and promise-based completion tracking.

Demo

Highlights

  • Zero dependencies — ~450 bytes min+gzip
  • TypeScript-first — written in TypeScript, ships type declarations
  • Dual package — ESM and CJS builds
  • Customizable — bring your own easing function
  • Cancellable — abort with AbortSignal
  • Promise-basedawait completion or track partial progress
  • Universal — works with any scrollable Element

Install

npm install easing-scroll
pnpm add easing-scroll

Quick Start

import { easingScroll } from "easing-scroll";

const container = document.querySelector(".container");

await easingScroll(container, {
  top: 300,
  duration: 400,
  easing: (x) => 1 - Math.pow(1 - x, 3), // easeOutCubic
});

API

easingScroll(target, options): Promise<number>

Smoothly scrolls target to the given position.

target

Type: Element

Any scrollable DOM element.

options

| Option | Type | Default | Description | | ---------- | ----------------------- | ---------- | ---------------------------------------------------------------------------- | | top | number | — | Target vertical scroll position in pixels | | left | number | — | Target horizontal scroll position in pixels | | duration | number | 0 | Animation duration in milliseconds | | easing | (t: number) => number | (t) => t | Easing function mapping progress (0–1) to eased value | | signal | AbortSignal | — | Signal to cancel the animation |

Return value

Resolves with a number between 0 and 1 representing animation progress:

| Value | Meaning | | ----------- | ---------------------------------------------------- | | 1 | Animation completed fully | | 0 < x < 1 | Animation was aborted at x progress | | 0 | Animation never started (signal was already aborted) |

Behavior

  • Instant scroll — when duration is 0 or negative, the element scrolls instantly and resolves 1.
  • No-op — when both top and left are omitted, resolves 1 immediately.
  • Clamping — scroll values are clamped to the element's scrollable range. No visual flash occurs.
  • Already-aborted signal — resolves 0 without scrolling.

Examples

Custom Easing

The default easing is linear (t) => t. Pass any function from easings.net:

await easingScroll(element, {
  top: 500,
  duration: 600,
  // https://easings.net/#easeOutCubic
  easing: (x) => 1 - Math.pow(1 - x, 3),
});

Abort Scrolling

Use an AbortController to cancel an in-flight animation:

const controller = new AbortController();

setTimeout(() => controller.abort(), 100);

const progress = await easingScroll(element, {
  top: 1000,
  duration: 400,
  signal: controller.signal,
});

if (progress < 1) {
  console.log(`Aborted at ${Math.round(progress * 100)}%`);
}

React Hook

A reusable hook that cancels the previous scroll when dependencies change or the component unmounts:

import { useEffect, RefObject } from "react";
import { easingScroll } from "easing-scroll";

function useEasingScroll(ref: RefObject<HTMLElement | null>, top: number) {
  useEffect(() => {
    const target = ref.current;
    if (!target) return;

    const controller = new AbortController();

    easingScroll(target, {
      top,
      duration: 400,
      signal: controller.signal,
      easing: (x) => 1 - Math.pow(1 - x, 3),
    });

    return () => controller.abort();
  }, [top]);
}

License

MIT