1.1.0 • Published 7 years ago

crystalslider v1.1.0

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

Crystal Slider

version 1.1.0

Readme languages: English, Русский

Features

  • lightweight slider with minimum required functionality written in vanilla JS;
  • no dependencies;
  • responsive;
  • touch device support;
  • user-friendly;

Demo

https://vadimbogomazov.github.io/CrystalSlider/

More examples

Installation

Create HTML markup

Create <div class="crystal-slider"> and <div> inside for each slide:

<div class="crystal-slider">
  <div>
    <img src="img/slide-1.jpg" alt="">
  </div>
  <div>
    <img src="img/slide-2.jpg" alt="">
  </div>
  <div>
    <img src="img/slide-3.jpg" alt="">
  </div>
</div>

Include plugin files

Include crystalslider.css and crystalslider.min.js:

<link rel="stylesheet" href="css/crystalslider.css">
<script src="js/crystalslider.min.js">

Slider css is divided into styles needed for correct plugin work, and styles of the basic theme (optional).

Call plugin

And the last step — calling plugin by specifying the required selector in options:

<script>
  const crystalSlider = new CrystalSlider({
    selector: 'your-selector' // .crystal-slider – default selector
  });
</script>

Options

The slider plugin has the following options:

NameDescriptionTypeDefault
selectorslider selectorString.crystal-slider
activeSlideactive slide indexNumber1
loopslider loopBooleantrue
autoplayslider autoplayBooleanfalse
playIntervalplay intervalNumber5000
pauseOnHoverpause on hoverBooleanfalse
fadefade modeBooleanfalse
durationanimation duration (in ms)Number500
draggableslide draggingBooleantrue
adaptiveHeightadaptive heightBooleanfalse
thresholdtouch dragging threshold (in px)Number30
titlesslides titles (values are taken from the data-attributes of slides)Booleanfalse
keyboardkeyboard arrows ← →Booleanfalse
easingeasing function (http://easings.net/en)Stringease-out
navnavigationBooleantrue
navPrevValprevious button valueStringPrev
navNextValnext button valueStringNext
appendNavToelement where the navigation are attachedString or DOM elementnull
paginationpaginationBooleanfalse
appendPaginationToelement where the pagination are attachedString or DOM elementnull
thumbnailsthumbnails (images are taken from the data-attributes of slides)Booleantrue
zIndexslide z-index (used in fade mode)Number98
onReadycallback after slider initiationFunction
beforeChangecallback before slide changeFunction
afterChangecallback after slide changeFunction

API

NameDescription
prevSlide()slides to the previous slide
nextSlide()slides to the next slide
goToSlide(index)slides to a slide with the set index (index {Number})
play()start auto changing slides
stop()stop auto changing slides
isEnabledOption(option)returns true if the option is enable (option {String})
destroy()destroy the slider instance
reinit(options)slider reinit with new options (options {Object})
activeSlideactive slide index (read only)
slidesLengthnumber of slides (read only)

License

MIT