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

react-scrolling-effects

v0.5.0

Published

A simple, customizable and easy-to-use React package to make scroll animation with over 20 types

Downloads

16

Readme

React Scrolling Effects

This is a React implementation that simulates 20 scrolling types. It's a simple, customizable, and easy-to-use package.

Demo

Demo gif

Getting Started

Use your favorite package manager to install react-scrolling-effects.

npm install react-scrolling-effects
# or
yarn add react-scrolling-effects

Import the scroll function and an effect that you like (in this example, we're gonna use smoothstep effect):

import { scroll, smoothstep } from "react-scrolling-effects";

Link it to a component click event:

<Example 
    onClick={() => scroll(".my-target", {
         container: "#my-container",
         duration: 1000,
         effect: smoothstep
    })}
/>

It will make the #my-container scroll to .my-target location using smoothstep effect and make this animation adapt to a timestamp of 1s (1000ms).

  • Note that any CSS selector can be used to address both container and target, not only classes or ids.

In case you want to scroll the whole user's view, not only a specific container, then you can omit container prop:

<Example 
    onClick={() => scroll(".my-target", {
         // container: "#my-container",
         // now, container will be equivalent to document
         duration: 1000,
         effect: smoothstep
    })}
/>

Alternatively, you can also make it scroll some pixels instead of to a specific element:

  • Scroll down 500px:
<Example 
    onClick={() => scroll(500, /* replace the string with a number */{
         duration: 1000,
         effect: smoothstep
    })}
/>
  • Scroll up 500px:
<Example 
    onClick={() => scroll(-500, {
         duration: 1000,
         effect: smoothstep
    })}
/>

API

Required props

  • target: String or Number. When a string, it's a CSS selector that points to a DOM element to which the page will be scrolled. When a number, it will scroll n pixels, as the provided number.

All props

  • container: String. The element that will be used to scroll. Default: If left empty, it will be equivalent to the whole user's view.
  • duration: Number. The time in milliseconds that the scrolling animation will take to finish. Default: 500ms.
  • effect: func = (x: Number) => Number. You need to import an animation effect from the library and input it in effect prop. You may also create custom scrolling effects if you want. Default: Smoothstep.
  • yAxis: Boolean. Check if the container will be scrolled vertically/on the y-axis. Default: true.
  • xAxis: Boolean. Check if the container will be scrolled horizontally/on the x-axis. Default: false.

Effects

  • smoothstep;
  • easeInBack, easeOutBack and easeInOutBack;
  • easeInBounce, easeOutBounce and easeInOutBounce;
  • easeInCirc, easeOutCirc and easeInOutCirc;
  • easeInCubic, easeOutCubic and easeInOutCubic;
  • easeInElastic, easeOutElastic and easeInOutElastic;
  • easeInQuint, easeOutQuint and easeInOutQuint;
  • easeInSine, easeOutSine and easeInOutSine.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT