Basic Cross-browser Image Slider Plugin with jQuery - slider.js

File Size: 20.6 KB
Views Total: 1779
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Basic Cross-browser Image Slider Plugin with jQuery - slider.js

Yet another jQuery plugin used for generating a basic automatic slider / carousel from a list of images that allow the visitor to slide manually between slides using navigation arrows or pagination bullets. Written with jQuery, JavaScript and SASS.

How to use it:

1. Load the slider.css file for the basic slider styles.

<link href="css/slider.css" rel="stylesheet">

2. Add a list of images together with the slider controls to the slider.

<div class="slider-wrapper">

  <ul class="slider">
    <li class="slide"><img src="images/lake.jpg" /></li>
    <li class="slide"><img src="images/GobiSunrise.jpg" /></li>
    <li class="slide"><img src="images/rocks.jpg" /></li>
    <li class="slide"><img src="images/duomo.jpg" /></li>
    <li class="slide"><img src="images/swiss.jpg" /></li>
  </ul>

  <div class="arrow arrow-left">
    <span class="icon-left-open"></span>
  </div>

  <div class="arrow arrow-right">
    <span class="icon-right-open"></span>
  </div>

</div>

3. Load jQuery library the slider.js script at the end of the html document.

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="js/slider.js"></script>

4. Create new Slider object for each '.slider-wrapper' found, and initialize. Sliders as objects allows for multiple indepedent sliders on the same page. To style differently (size, margins, etc), add specific classes in SCSS file.

$('.slider-wrapper').each(function() {      
  var slider = new Slider($(this));
  slider.assignSlideClasses();
  slider.activateControls();    
  slider.beginSlider();
});

This awesome jQuery plugin is developed by eahenke. For more Advanced Usages, please check the demo page or visit the official website.