0.4.5 • Published 3 years ago

@onrewind/krousel v0.4.5

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

NPM Version Package Size

krousel

Carousel library with vanilla Javascript

Disclaimer: This library is inspired by Slick which is a jQuery plugin. The goal is to provide a similar utility without the jQuery dependency. The API here is almost the same as Slick's one.

Installation

$ npm install @onrewind/krousel

Features

  • Infinite loop
  • Change transition speed & type (slide / fade)
  • Autoplay & autoplay speed
  • Enable / Disable arrows
  • Enable / Disable navigation dots
  • Show multiple slides at once
  • Slide multiple slides at once
  • Responsive: change config using breakpoints
  • Change where dots and/or arrows will be inserted
  • Use custom arrows

Options

OptionTypeDefaultDescription
appendArrowsHTMLElementnullChange where arrows are attached (default is the target)
appendDotsHTMLElementnullChange where the navigation dots are attached
arrowsbooleantrueenable or disable arrows
autoplaybooleanfalseAuto play the carousel
autoplaySpeednumber3000Change the interval at which autoplay change slide
dotsbooleantrueDisplay or hide dots
infinitebooleantrueEnable or disable infinite behavior
nextArrowHTMLElementnullCustomize the "next" arrow
pauseOnHoverbooleantruepause autoplay when a slide is hovered,
prevArrowHTMLElementnullCustomize the "previous" arrow
responsiveArraynullbreakpoints config, see below
slidesToShownumber1Number of slide to show at once
slidesToScrollnumber1Number of slide to scroll at once
speednumber300transition speed when changing slide
swipebooleantrueEnable or disable drag to change slide
transition one of: 'slide', 'fade' 'slide' Change transition type when changing slideNOTE: transition 'fade' disable options slidesToShow and slidesToScroll

Responsive option example

The responsive option takes an array of breakpoints, each one should be an object structured as follow:

  • breakpoint • Number • Screen width at which the breakpoint will be activated
  • settings • Object • Object containing options that will overwrite initial options

LIMITATION: the settings property only accepts overwrites for these options:

slidesToShow, slidesToScroll, infinite

This list could increase over time

Only one breakpoint will be enabled at a time.

const options = {
  // [...]
  responsive: [
    {
      breakpoint: 1024,
      settings: {
        slidesToShow: 3,
        slidesToScroll: 3,
        infinite: true,
      },
    },
    {
      breakpoint: 600,
      settings: {
        slidesToShow: 2,
        slidesToScroll: 2,
        infinite: true,
      },
    },
    {
      breakpoint: 400,
      settings: {
        slidesToShow: 1,
        slidesToScroll: 1,
        infinite: false,
      },
    },
  ],
};
0.4.5

3 years ago

0.4.4

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago