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

scroll-carousel

v1.2.7

Published

Scroll carousel, a unique content slider that specially works on window scroll.

Readme

Scroll Carousel

Simple content slider, works on scroll. Absolutely free for use. Thriving for precision & community growth.

NPM | Documentation | Demos

Note: This carousel only operates in browser.

Contents

Features

  • Mobile friendly: It is meant to be utilized in mobile web apps and mobile websites.
  • Autoplay: Scroll carousel supports autoplay.
  • Library Agnostic: It is significantly smaller and faster because it doesn't need any JavaScript libraries like jQuery.
  • Responsive: It is responsive by default.
  • Typescript support: Scroll carousel is fully typed.

Install

Download

CDN

To get started with Scroll Carousel right away, there are a few CDN available to serve the file faster:

Example usign jsDelivr

Add a link to the css file in your <head>:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/scroll.carousel.min.css">

Then, before your closing <body> tag, add:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/scroll.carousel.min.js"></script>

Package managers

npm
npm install scroll-carousel

Using with npm needs import js and css. Let's see -

Import JS in your js file

import ScrollCarousel from 'scroll-carousel';

Import CSS in your css file

@import 'node_modules/scroll-carousel/dist/scroll.carousel.css';

Usage

Scroll Carousel basically works with a container element and a set of child item elements. Wrap your item elements (div, a, span, li etc) with a container element (div, ul etc).

<div class="my-carousel">
  <div class="my-slide">...</div>
  <div class="my-slide">...</div>
  <div class="my-slide">...</div>
  ...
</div>

NOTE: my-carousel class name is not mandatory. You can use any class or id name according to your choice and need.

Initialize with vanilla Javascript

Initialize the Scroll Carousel with new keyword.

new ScrollCarousel(".my-carousel", {
  ...options
})

or,

const myCarousel = document.querySelector(".my-carousel");

new ScrollCarousel(myCarousel, {
  ...options
})

Initialize with HTML

You can initialize Scroll Carousel in HTML, without writing any JavaScript. Add data-carousel attribute to the carousel element. Options can be set in its value.

<div class="my-carousel" data-carousel>
  <div class="my-slide">...</div>
  <div class="my-slide">...</div>
  <div class="my-slide">...</div>
  ...
</div>

Options

| Option | Type | Default | Description | | ------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------- | | speed | number | 7 | The value given is how fast you want to move on the scroll. It needs to be greater than 0. | | smartSpeed | boolean | false | To calculate the speed of how fast or slow you are scrolling a website. | | margin | number | 10 | To make gap between two slide | | slideSelector | string | null | Select the slides with a class name you want to select for the carousel. Other elements will behave as simple. | | autoplay | boolean | false | The option will allow the slides move automatically and still you will have the ability to handle sliding speed on scroll. | | autoplaySpeed | number | 5 | Control autoplay speed. It needs to be greater than 0 | | direction | string | 'rtl' | Control direction left to right or right to left. Two possible option - ltr or rtl |

Example with options
new ScrollCarousel(".my-carousel", {
  speed: 15,
  autoplay: true,
  autoplaySpeed: 5,
  smartSpeed: true,
  slideSelector: ".my-slide",
  direction: "rtl",
  margin: 10
})

or,

<div class="my-carousel" data-carousel='{"speed": 15, "autoplay": true, "smartSpeed": true, "slideSelector": ".my-slide"}'>
  <div class="my-slide">...</div>
  <div class="my-slide">...</div>
  <div class="my-slide">...</div>
  ...
</div>

:warning: Options set in HTML must be valid JSON. Keys need to be quoted, for example "speed":. Note that the attribute value uses single quotes ', but the JSON entities use double-quotes ".

Methods

| Method | Return | Description | | --------- | ---------------- | -------------------------------------------------------------------------------------------------------------------- | | destroy() | void | Remove ScrollCarousel functionality completely. destroy will return the element back to its pre-initialized state. | | reinit() | ScrollCarousel{} | This will initialize your carousel after destroy with previous options and returned the ScrollCarousel instance. |

Example of methods
let scrollCarousel = new ScrollCarousel(".my-carousel", {
  speed: 15,
  autoplay: true,
  smartSpeed: true,
  slideSelector: ".my-slide"
})

document.querySelector('#button').addEventListener('click', function () {
  if(scrollCarousel.isActive) {
    scrollCarousel.destroy();
  } else {
    scrollCarousel = scrollCarousel.reinit()
  }
});

Events

| Event | Description | | ------- | --------------------------------------------------------- | | ready | This event will fire when the plugin is ready to action | | destroy | This event will fire when the destroy method is being hit | | move | This event will fire when the carousel is on move |

Example of events
let scrollCarousel = new ScrollCarousel(".my-carousel", {
  speed: 15,
  autoplay: true,
  smartSpeed: true,
  slideSelector: ".my-slide",
  on: {
    ready: function () {
      console.log("Be ready");
    },
    destroy: function () {
      console.log("Destroyed");
    }
  }
})

scrollCarousel.on("move", function (progress) {
  consol.log(progress);
})

Browser support

Desktop: Firefox 8+ ✓ Chrome 15+ ✓ (Should works on Chrome 4-14 as well, but I couldn't test it.) Safari 4+ ✓ Opera 12.1+ ✓ IE 8+ ✓

Mobile: Android Browser 4.2+ ✓ Chrome Mobile 63+ ✓ Firefox Mobile 28+ ✓ Maxthon 4+ ✓

License

The code and the documentation are released under the MIT License.

Contributors

This project exists thanks to all the people who contribute. [Contribute].