1.0.2 • Published 6 years ago

easy-slider v1.0.2

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

easy-slider

A simple carousel works without frameworks, tiny size and easy to use. Support commonly used desktop browsers include IE10, and commonly used mobile broswers.

Install

npm i easy-slider

Usage

import EasySlider from "easy-slider";
/**
 * @constructor
 * @description Sets the selector and options, then return the instance
 * @param selector {String} The selector string of the entry node
 * @param config {Object} Component configuration object
 */
var easySlider = new EasySlider('.simple-carousel', {
    loop: true,
    initialSlide: 0
});

Documentation

Configuration

Check the available configuration list:

ParameterTypeDefaultDescription
debugbooleanfalseOpen debug info (indevelopemnt)
initialSlidenumber0Set initial slide index (start with 0)
speednumber300Slide animation duration (in ms)
loopbooleanfalseSet to true to enable continuous loop mode
effectstring'slide'Tranisition effect. Only support "slide" for now

Methods

We provide usefull methods to play with for EasySlider instance.

Methode nameDiscription
slideTo(index)Go to the 'index'th slide
slideNext()Go to next slide
slidePrev()Go to previous slide
on(event, callback)add event listener
off(event, callback)remove evet listener

Event

We provide event hander to track the component behaviour instead of callbacks.

var easySlider = new EasySlider('.simple-carousel');
// add event handler
var initHandler = () => console.log('init');
easySlider.on('init', initHandler);
// remove event handler
easySlider.off('init', initHandler);

Note: this keyword within event handler always points to EasySlider instance

Event nameArgumentsDescription
initCall after slider initialized
slideChangeCall after slider changed
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago