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 🙏

© 2025 – Pkg Stats / Ryan Hefner

flexismooth

v1.0.0

Published

Dependency-free smooth scrolling library

Downloads

9

Readme

Flexismooth

Build Status

Dependency-free smooth scrolling library

About the FlexiJS series

There are JavaScript libraries for everything you would ever want to do in a browser. A lot of them either:

  • depend on a large library (like Underscore or jQuery) or even framework even though they only need tiny fractions of the features or
  • have awful code quality.

Most fit in both categories.

Because most tasks are simple, there shouldn't be the need for huge libraries for simple tasks. That's why I started writing small, UNIXy JavaScript libraries in a series called FlexiJS. Flexismooth is one of them, but feel free to check out the others, too.

Features

  • Doesn't require any dependencies, less than 1 KB compressed
  • Robust and well-tested code
  • Promise API, uses requestAnimationFrame
  • Supports scrolling to pixel values or elements
  • Comes with simple easeIn, easeOut and easeInOut functions and supports custom easing functions
  • Doesn't annoy the user by default by stopping automatically if the user scrolls manually while the animation is running

Browser support

Flexismooth requires the following browser features:

  • Promises
  • requestAnimationFrame

Apart from that, it should support pretty much all relevant browsers.

Installation

Flexismooth uses AMD if available, otherwise it exports itself as window.Flexismooth. There are several ways to get Flexismooth:

  • Download the minified or development version directly
  • npm install flexismooth
  • bower install flexismooth

Usage

Flexismooth(target[, options])

Takes a target (pixel value counted from the top of the page or element object) and scrolls to it in the time specified in options. options can be:

  • an object with any of the following options:
    • time: Time in ms, defaults to 0 ("scroll instantly")
    • easingFunction: Easing function, defaults to Flexismooth.easing.easeInOut(2)
    • annoyUsers: Don't stop if the animation is interrupted by the user (not recommended!)
  • just a time value
  • completely omitted to default to a time value of 0

The function returns a Promise that is resolved after the animation is done and rejected if it was interrupted.

Flexismooth.easing.easeIn(exponent)

Returns an easing function with the given exponent. An exponent of 1 equals a linear easing function. easeIn converts a float between 0 and 1 to a float that accelerates from zero velocity.

Flexismooth.easing.easeOut(exponent)

Returns an easing function with the given exponent. An exponent of 1 equals a linear easing function. easeOut converts a float between 0 and 1 to a float that decelerates to zero velocity.

Flexismooth.easing.easeInOut(exponent)

Returns an easing function with the given exponent. An exponent of 1 equals a linear easing function. easeInOut combines easeIn and easeOut.

Examples

// Scroll to the top of the page within 500 ms
Flexismooth(0, 500).then(function(result) {
	console.log('We are at the top: ' + result);
}).catch(function(err) {
	console.log('Something went wrong: ' + err);
});

// Scroll to a specified element
var element = document.querySelector('.main');
Flexismooth(element, 500).then(function(result) {
	console.log('We have reached the element: ' + result);
}).catch(function(err) {
	console.log('Something went wrong: ' + err);
});

// Sometimes you don't care whether the animation was successful
// or not or when it completed
// That's fine too, you don't need to do anything with the Promise
Flexismooth(0, 500);

// Use a custom easing function
var options = {
	time: 500,
	easingFunction: Flexismooth.easing.easeInOut(3)
};
Flexismooth(0, options);

// Use a completely custom easing function
var options = {
	time: 3000,
	easingFunction: function(value) {
		// This one is not recommended for production
		// You'll see when you try it out...
		return -0.5 * Math.cos(3 * Math.PI * value) + 0.5;
	}
};
Flexismooth(0, options);

// Force the animation on the user (not recommended!)
var options = {
	time: 500,
	annoyUsers: true
};
Flexismooth(0, options);

License

http://www.opensource.org/licenses/mit-license.php

Author

Lukas Bestle [email protected]