1.0.2 • Published 3 years ago

@snigo.dev/carousel v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

Carousel

Zero-dependencies awesome carousel react component for everyday use. Demo: https://carousel.snigo.dev

Usage

  1. Install the package
npm i @snigo.dev/carousel
  1. Wrap stuff with Carousel component
<main>
  <Carousel
    onApproach={() => { /** Load more images */}}
    onChange={(from, to) => { /** Keep track of the current slide showing */ }}
  >
    {
      images.map((imageId: string) => (
        <Image src={`https://source.unsplash.com/${imageId}/960x600`} width={960} height={600} key={imageId} />
      ))
    }
  </Carousel>
</main>
  1. Enjoy the ride

Carousel screenshot

Features

  • Supports swiping by both mouse and touch interactions
  • No configuration required to start, just wrap any number of components
  • Slides can have interactive elements
  • Url to particular slide can be passed as https://myapp.com/#slides3

Props

Prop nameTypeDefault valueDescription
startnumber0Starting index of the slide
loopbooleanfalseRestarts the carousel after the last slide
autoplaynumber0Number of seconds to autoshow next slide or 0 to disable
thresholdnumber40Number of pixels slided to trigger navigation to the next slide
showDotsbooleantrueShows dots at the bottom of the carousel
showArrowsbooleantrueShows arrows on both sides of the carousel
allowSwipebooleantrueAllows swipe either by mouse or touch interaction
allowDotClickbooleantrueAllows navigation by clicking on the dot
onStartfunctionCallback to be called when carousel is rendered on the screen
onEndfunctionCallback to be called on the last slide
onApproachfunctionCallback to be called slides are approaching the end
onChangefunctionCallback to be called on every slide change

Dimensions

Carousel is designed to be contained by parent, meaning it will always take full width and full height of the container. Same applies to the default slide size.

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago