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

magic-roundabout

v1.3.2

Published

A tiny JavaScript carousel

Downloads

41

Readme

Magic Roundabout

A tiny JavaScript carousel

Install

npm install magic-roundabout

Usage

First, create the HTML structure for your slider.

<div class="slideshow" id="slideshow">
  <div class="slideshow__slides">
    <div class="slideshow__slide">
      <!-- First slide content -->
    </div>

    <div class="slideshow__slide">
      <!-- Second slide content -->
    </div>
  </div>
</div>

Then, create a new instance of magic roundabout.

import MagicRoundabout from 'magic-roundabout'

const magicRoundabout = new MagicRoundabout('#slideshow')

Magic Roundabout does not include any CSS, making it easy to style as you see fit. The following should be enough to get you started

#your-selector {
  overflow: hidden;
}
  #your-selector .slideshow__slides {
    align-items: stretch;
    display: flex;
    flex-wrap: nowrap;
    transition: transform .3s;
    width: 100%;
  }
  #your-selector .slideshow__slide {
    flex: 0 0 100%;
  }

If you want to add navigation buttons, just add them into the main .slideshow element.

<div class="slideshow" id="slideshow">
  <div class="slideshow__slides">
    <div class="slideshow__slide">
      <!-- First slide content -->
    </div>

    <div class="slideshow__slide">
      <!-- Second slide content -->
    </div>
  </div>

  <a href="javascript:void('')" class="slideshow__button slideshow__button--prev">Previous</a>
  <a href="javascript:void('')" class="slideshow__button slideshow__button--next">Next</a>
</div>

Options

Magic Roundabout's full option list is shown below:

const magicRoundabout = new MagicRoundabout('#your-element', {
  // Whether the slider should autoplay
  auto: false,

  // Whether next/previous buttons are in the container
  buttons: true,

  // If true, slides will be centered in the container
  // (Disabled if `limit` option is `true`)
  center: false,

  // If true, clicking a slide will transition to it
  click: true,

  // When auto == true, the time between transitions
  delay: 10000,

  // If true, the user can click-and-drag or swipe-and-drag the slideshow
  draggable: false,

  // If true, the arrow keys will control the slider while it is in the viewport
  keys: true,

  // If true, the slider will not be allowed to scroll past the last slide's right edge
  // (Disabled if `loop` option is `true`)
  limit: true,

  // Whether the slider should return to the start when at the end
  loop: true,

  // A function which is fired when the current slide changes
  onChange: (magicRoundabout) => {},

  // If true, the carousel will respond to swipe events
  touch: true,

  // If true, the carousel will respond to scroll events
  scroll: true,

  // If true, the carousel will transition vertically
  vertical: false
})