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

autoscroll-carousel

v1.2.0

Published

A simple, minimalistic carousel with navigation dots, arrows, 5-sec autoscroll

Downloads

30

Readme

Carousel Component

This package provides a simple and customizable carousel component for displaying images or other content. It includes basic controls like navigation arrows and dot navigation. Follow the instructions below to integrate it into your project.

Features

  • Infinite scrolling through images or content
  • Navigation using arrows and dot indicators
  • Auto-scroll with smooth animations
  • Customizable styles

Installation

To install the package, use npm:

npm install niccost-carousel

Include the necessary CSS and JavaScript in your project after installation.

HTML Structure

To set up the carousel, your HTML should follow this structure:

<div class="first-level">
    <div class="container">
        <div class="carousel">
            <div class="carousel-item">
                <img src="https://example.com/image1.png" alt="image 1">
            </div>
            <div class="carousel-item">
                <img src="https://example.com/image2.png" alt="image 2">
            </div>
            <div class="carousel-item">
                <img src="https://example.com/image3.png" alt="image 3">
            </div>
            <!-- Add more carousel items as needed -->
        </div>
    </div>

    <!-- Navigation Arrows -->
    <div class="carousel-nav-arrows">
        <button class="scroll-left-button"> ◀ </button>
        <button class="scroll-right-button"> ▶ </button>
    </div>
</div>

Explanation of HTML Elements

  • .first-level: The outer container that wraps everything related to the carousel.
  • .container: The main wrapper for the carousel, with scrolling disabled for better control.
  • .carousel: Contains all carousel items, which scroll horizontally.
  • .carousel-item: Wraps each item (image or content) to be displayed.
  • .carousel-nav-arrows: Contains navigation buttons for left and right scrolling.
    • .scroll-left-button: Scrolls the carousel to the left.
    • .scroll-right-button: Scrolls the carousel to the right.

JavaScript Usage

To use the carousel, simply ensure your HTML follows the required structure, then include the script in your project:

import './niccost-carousel';

The carousel will automatically initialize when the DOM is loaded, handling dot creation, navigation, and auto-scrolling.

Dot Navigation

The script automatically generates navigation dots based on the number of items in the carousel. Clicking a dot scrolls to the corresponding slide and updates the active state.

Arrow Navigation

The left and right buttons allow users to navigate between carousel items manually. The carousel also auto-scrolls every 5 seconds by default.

CSS Customization

You can override or extend the default styles provided in style.css and normalize.css:

.carousel {
    display: flex;
    overflow: hidden;
    scroll-behavior: smooth;
}

.carousel-item {
    min-width: 100%;
    flex-shrink: 0;
}

.dots-container {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.dot-link {
    background-color: #bdbcbc;
    height: 8px;
    width: 8px;
    border-radius: 50%;
}

.dot-link.active {
    background-color: #707070;
}

Feel free to customize dimensions, colors, or add more advanced transitions as per your design requirements.

Additional Features

  • Prevent default actions: The carousel disables right-click context menus and drag interactions on the images for a more streamlined experience.
  • Auto-scroll: The carousel automatically scrolls to the next image every 5 seconds. This can be adjusted in the script.

License

This project is licensed under the ISC License. See the ./license file for details.