1.2.2 • Published 7 years ago

rs-carousel v1.2.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

License GitHub version NPM version Downloads

RS Carousel

Customizable basic fullpage carousel

Features

  • Easy extensible
  • Written in ES6
  • Progressive background image loading with blur (like medium.com)

Example

ES6 basic - demo

ES6 horizontal - demo

ES6 custom controls - demo

Or see example dir

Installation

npm install rs-carousel

Dependencies

jQuery and Velocityjs

Usage

import { RSBaseCarousel } from 'rs-carousel';

const $container = $('.js-carousel');
const carousel = new RSBaseCarousel($container, opts);

Lazy loading background images

Use attributes for urls of images

<div class="m-carousel__slide js-rs-carousel__slide">
    <div class="js-rs-carousel__slide__bg" data-image-small="img_small.jpg" data-image="img_large.jpg"></div>
    ...
</div>

Options

OptionTypeDefaultDescription
slideSelstring'.js-rs-carousel__slide'Carousel elements selector
slideBgSelstring'.js-rs-carouselslidebg'Slide background selector
slideBgCanvasClassstring'bg-canvas'Class for slide background canvas (used for blur small background image)
slideBgImgClassstring'bg-img'Class for slide background element (used for full background image)
slideBgImgStylesobject{ backgroundPosition: 'center center', backgroundSize: 'cover' }Css for background element
slideBgImgLoadingClassstring'bg-img-loading'Class form slide background element while loading full image
slideBgImgLoadedClassstring'bg-img-loaded'Class for slide background element when loaded full image
slideBgImgFadeDurationnumber500Duration of animation backgrounds
blurRadiusnumber30Used for blur small background image
slideZIndexnumber1000Carousel elements z-index
swipeThresholdnumber30Minimal distance required before slides change
durationnumber1000Animation duration
directionnumber24Carousel direction (see constants)
easingstring'easeInOutCubic'Animation easing (see velocityjs easings)
infinitebooleantrueInfinite looping

Constants

import { constants } from 'rs-carousel';

console.log(constants);
{
    directions: {
        left: 2,
        right: 4,
        up: 8,
        down: 16,
        vertical: 24,
        horizontal: 6
    },
    animationsNames: {
        in: {
            "2": "carouselSlideLeftIn",
            "4": "carouselSlideRightIn",
            "8": "carouselSlideUpIn",
            "16": "carouselSlideDownIn"
        },
        out: {
            "2": "carouselSlideLeftOut",
            "4": "carouselSlideRightOut",
            "8": "carouselSlideUpOut",
            "16": "carouselSlideDownOut"
        }
    }
}

Api

Methods and props

Methods and props are called on carousel instances

const carousel = new RSBaseCarousel($container, opts);

carousel.goTo(2); // Method
carousel.currentSlide; // Prop
MethodArgumentDescription
goToindex : numberGoes to slide by index
nextGoes to next slide
prevGoes to next slide
addBeforeCbfn : functionAdd before slide change callback
addAfterCbfn : functionAdd after slide change callback
lockLock carousel
unlockUnlock carousel
PropDescription
currentSlideCurrent slide
nextIndexNext slide index
prevIndexPrev slide index
$containerConstainer of carousel instance
settingsCarousel settings of current instance

Build (for developers)

npm run build

License

Released under the MIT License. See the bundled LICENSE file for details.

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago