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

@hugeinc/carousel

v0.8.7

Published

A micro, responsive, touch-enabled carousel.

Downloads

30

Readme

Carousel

Build Status NPM Version License

A carousel that'll use CSS to dynamically adapt its width. Uses transforms for its transitions and is also touch-enabled.

Introduction

The general idea is that this component should maintain a separation of state and style. That is to say, the Javascript maintains the state of the carousel (which slide, etc), while the CSS should take care of the presentation of this state (ie. transitions between slides, responsive, etc).

Overview

Features a touch-based interface, simple API, and a very-lightweight footprint. It does the basics well, but that's it. No bloat. You can swipe to drag a slide yet still use CSS to control how the slide transitions will behave. You can also choose to change slides by using the exposed API. The carousel works on both desktop and mobile, while only weighing in at 2.5 KB!

Getting Started

There is an ES6 module you may consume however you wish. Alternatively, you can also include the relevant scripts in your web page, and then:

<!-- sample carousel markup -->
<div class="carousel">
  <ul class="wrap">   <!-- slideWrap -->
    <li>slide 1</li>  <!-- slide -->
    <li>slide 2</li>
    <li>slide 3</li>
  </ul>
</div>
  // available options
  var options = {
    onSlide: someFunction,
    activeClass: 'active',
    slideWrap: 'ul',
    slides: 'li',
    infinite: true,
    display: 1,
    disableDragging: false,
    initialIndex: 0
  };

  var container = document.querySelector('.carousel');
  var carousel = new Carousel(container, options);

Options

| name | type | default | description | | --------------- | -------- | --------- | ----------- | | onSlide | function | undefined | A function to execute on slide. It is passed to and from indices. | | slideWrap | string | ul | The selector to use when searching for the slides' container. This is used only to bind touch events to, on mobile. | | slides | string | li | The selector to use when searching for slides within the slideWrap container. | | activeClass | string | active | Class to use on the active slide. | | animateClass | string | animate | Class to use on the wrapper when animating. | | infinite | boolean | true | Enable an infinitely scrolling carousel or not | | display | integer | 1 | the maximum # of slides to display at a time. If you want to have prev/next slides visible outside those currently displayed, they'd be included here. | | disableDragging | boolean | false | if you'd like to disable the touch UI for whatever reason | | initialIndex | integer | 0 | which slide it's going to start on |

Methods

| method | description | | --------- | ----------- | | next() | Advances carousel to the next slide | | prev() | Move carousel to the previous slide | | to(i) | Advance carousel to the ith slide | | destroy() | Destroy carousel and remove all EventListeners |

Demo

Hugeinc Carousel

Develop

After cloning the repo:

npm i
npm start

A server will spin up at http://localhost:8080, where you may play with the various examples. See the "demo" directory.

Support

  • IE8+
  • Safari / Chrome
  • Firefox
  • iOS
  • Android 4.0+

Release History

0.6

  • updated some css

0.5

  • added destroy()
  • added some tests

0.4

  • better dragging response
  • fixed click bug when dragging

0.3

  • cleaning up cloning logic
  • further optimizations

0.2

  • bug fixes, mostly
  • updated slide engine
  • more robust dragging on mobile

0.1

  • first release