1.3.2 • Published 4 years ago

magic-roundabout v1.3.2

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

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
})
1.3.2

4 years ago

1.3.1

4 years ago

1.3.0-15

5 years ago

1.3.0-13

5 years ago

1.3.0-12

5 years ago

1.3.0-11

5 years ago

1.3.0-10

5 years ago

1.3.0-9

5 years ago

1.3.0-8

5 years ago

1.3.0-7

6 years ago

1.3.0-6

6 years ago

1.3.0-5

6 years ago

1.3.0-4

6 years ago

1.3.0-3

6 years ago

1.3.0-1

6 years ago

1.3.0-0

6 years ago

1.2.2-0

6 years ago

1.2.1-beta

6 years ago

1.2.0

6 years ago

1.2.0-beta3

6 years ago

1.2.0-beta2

6 years ago

1.2.0-beta

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago