2.0.4 • Published 6 years ago

alexemashev-swipeslider v2.0.4

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

Image Slider With Swipe

About

This is a tiny jQuery plugin that represents image slider (carousel). Slider supports mouse and touch inputs to slide through images. Also the slider supports HTML content.

Demo picture

Click the demo page

Features

  • mouse and touch (swipe) support;
  • next, previous buttons;
  • bullets to change current slide;
  • can work with images as well as HTML;
  • various options (animation effect, timings, enable, disable certain properties);
  • using css transition to change slides (so it should be video accelerated);
  • responsiveness, can take up available space and shrink images to fit slider if needed;

Installation

Installation Using npm

Use following command: npm i alexemashev-swipeslider

Installation Using Bower

Use following command: bower install swipeslider or bower install swipeslider --save to save to your project as dependency.

Manual Installation

Add these two files to your page: swipeslider.min.js swipeslider.css

You'll also need to add jQuery library if it's not already.

Within your HTML add markup for slides, something like that:

<figure id="sample_slider" class="swipeslider">
<ul class="sw-slides">
  <li class="sw-slide">
    <img src="img/lang_yie_ar_kung_fu.jpg" alt="Lang from Yie Ar Kung Fu">
  </li>
  <li class="sw-slide">
    <img src="img/summer_beach.jpg" alt="Summer beach concept">
  </li>
  <li class="sw-slide">
    <img src="img/borderlands_tiny_tina.jpg" alt="Tiny Tina from Borderlands 2">
  </li>
  <li class="sw-slide">
    <img src="img/redhead.jpg" alt="Redhead girl">
  </li>
</ul>
</figure>

Add following script to make things going:

<script>
$(window).load(function() {
  $('#sample_slider').swipeslider();
});
</script>

Do not forget to add at least height to your slider via css.

How To Customize

Plugin Settings

Plugin can be customized via JavaScript object. For example:

$('#sample_slider').swipeslider({autoPlay: false, swipe: false});
PropertyDefaultDescription
sliderHeight'60%'Height of the slider block. Set in percents if you want automatic resizing according to width of slider (useful is you need a responsiveness). Set it in pixels it you want to have constant height.
transitionDuration500Duration of transition effect between slides (in msec.)
timingFunction'ease-out'Easing function that will be used in transition effect (CSS easing function).
autoPlaytrueEnable automatic transition between slides.
autoPlayTimeout3000Delay (msec.) between slide transition when autoPlay is true.
prevNextButtonstrueShow next and previous slide buttons.
bulletstrueShow bullets that indicate which slide is active and used to quick switching between slides.
swipetrueEnable swipe function to switch between slides.

Style

The interface can be customized by overriding attributes of CSS classes. SCSS file included.

ClassDescription
.swipsliderBlock that contains slider itself.
.sw-slidesBlock that contains slides.
.sw-slideSlide block, can contain either block with content or img element.
.sw-slide > imgImage of slide.
.sw-contentBlock that can be used instead of img element and can contain other HTML elements. It can be used as a slide with content.
.sw-next-prevOverall style of previous and next button.
.sw-prevStyle for previous button (to override the content use ::after pseudo element).
.sw-nextStyle for next button (to override the content use ::after pseudo element).
.sw-bulletBullets container.
.sw-bullet liSingle bullet
.sw-bullet li.activeActive bullet

Dependencies

  • jQuery;

License

The MIT public license.

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago