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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@orthodoxauto/fluidscroll

v3.1.7

Published

A cross-browser compatible, lightweight, easy-to-use library for smooth scrolling.

Downloads

362

Readme

FluidScroll

A cross-browser compatible, lightweight, easy-to-use library for smooth scrolling.

fluidScroll({ options });

Installation

This library can be installed with NPM.

npm i @orthodoxauto/fluidscroll

Then, it may be used in this manner:

// ES Module
import { fluidScroll } from '@orthodoxauto/fluidscroll';

// CommonJS
const fluidScroll = require('@orthodoxauto/fluidscroll');

Alternatively, it can be directly included as a script on any HTML page. For example, with a CDN:

<script
    src="https://cdn.jsdelivr.net/npm/@orthodoxauto/[email protected]"
    integrity="sha384-ZvfwaJZFftLPOaPS13spccPYdWRcrfz/GDgUYAf7b6I2OBXY74KiAC6WVg0XF3Qq"
    crossorigin="anonymous"
></script>

You can also manually download dist/fluidscroll.umd.min.js and include it in the head of the page using your own path:

<script src="path/to/fluidscroll.min.js"></script>

It can additionally be used in a module script:

<script type="module">
    import { fluidScroll } from 'https://cdn.jsdelivr.net/npm/@orthodoxauto/[email protected]/dist/fluidscroll.esm.mjs';
</script>

Import maps can furthermore be used to simplify the module specifier when importing as well as check the integrity.

<script type="importmap">
    {
        "imports": {
            "fluidscroll": "https://cdn.jsdelivr.net/npm/@orthodoxauto/[email protected]/dist/fluidscroll.esm.mjs"
        },
        "integrity": {
            "https://cdn.jsdelivr.net/npm/@orthodoxauto/[email protected]/dist/fluidscroll.esm.mjs": "sha384-uRZwvJLM1xS19wbYkR8/uqMLzM58mVHEluImXjOaBV4H3LerGAjCSGbQfBYrpNCQ"
        }
    }
</script>
<script type="module">
    import { fluidScroll } from 'fluidscroll';
</script>

Simple Uses

Scroll to y-position 1000px in 750 milliseconds:

fluidScroll({ yPos: 1000, duration: 750 });

Scroll to the bottom of the page:

fluidScroll({ yPos: 'end' });

Scroll to x-position 500px and y-position 500px:

fluidScroll({ xPos: 500, yPos: 500 });

Options

Return Value

fluidScroll returns an object with the destroy property which is a function that stops the scrolling when called.

var s = fluidScroll({ yPos: 5000, duration: 3000 });
// Stop the scrolling sometime later
s.destroy();

Instantiation

Using the new operator will create an instance with the passed in options as defaults. Properties specified in this options object will override the original defaults. Call the fluidScroll method on the returned value to perform smooth scrolling with these defaults.

var scroller = new fluidScroll({ duration: 700, block: 'center' });
scroller.fluidScroll({ yPos: 500 }); // duration is 700 (rather than the original default of 500)

Getting and Setting Global Defaults

fluidScroll.defaults() returns an object containing the default values for each option. Passing an object to fluidScroll.defaults will overwrite each option in the defaults with the value from that object if it is set.

fluidScroll.defaults({ duration: 700 }); // set default duration to 700ms

Other Methods and Properties

fluidScroll.stopAll() stops all current scroll animations and returns true/false depending on whether there were running animations that were stopped.

fluidScroll.scrolling() returns true/false depending on whether or not there are current scrolling animations.

fluidScroll.nativeSupported indicates whether or not the CSS scroll-behavior property is supported in the current browser.

fluidScroll.easing is an object containing the predefined easing functions.

Examples

Examples of common use cases can be found in the examples folder. These can be run by cloning the repository, then opening any of the HTML files in a browser. Note that many newer JavaScript features are not used in order to demonstrate more cross-browser compatible code.