Very Simple Image Touch Slider With Limited Options – Swipe

Looking for a affordable website?

GET STARTED
www.codingexpertz.com
Very Simple Image Touch Slider With Limited Options – Swipe

File Size: 1814KB

Total Views: 6827

Date Created:

Last Modified Date:

Official Website: Go to website

License: MIT

Swipe is a very simple and easy to use image/content slider plugin that creates a sliding effect to any types of content easily. It has few options to modify or control the slider, so you can use this when you need a very basic slider. It supports slider movement on touch for touch-enabled devices only. Slider appearance can be modified easily with a bit help of CSS.

Features:

  • Most accurate touch slider.
  • Very simple and easy to use.
  • Supports on all modern devices and browsers.
  • Easy customizable with CSS.

How to use it:

1. Include the Javascript swipe.js at the bottom of the web page.

<script src="path/to/swipe.js"></script>

2. Add few styles to your stylesheet.

.swipe {
  overflow: hidden;
  visibility: hidden;
  position: relative;
}
.swipe-wrap {
  overflow: hidden;
  position: relative;
}
.swipe-wrap > div {
  float:left;
  width:100%;
  position: relative;
}

3. Add the basic HTML to the page.

<div id="slider" class="swipe">
  <div class="swipe-wrap">
    <div><img src="path/to/slide-1.jpg" alt=""></div>
    <div><img src="path/to/slide-2.jpg" alt=""></div>
    <div><img src="path/to/slide-3.jpg" alt=""></div>
  </div>
</div>

4. Initialize the plugin and we’re ready to go.

window.mySwipe = new Swipe(document.getElementById('slider'), {
  speed: 400,
  auto: 3000,
  continuous: true,
  disableScroll: false,
  stopPropagation: false,
  callback: function(index, elem) {},
  transitionEnd: function(index, elem) {}
});

Plugin’s default options:

Name Default Type Description
startSlide 0 Integer Index position Swipe should start at
speed 300 Integer Speed of prev and next transitions in milliseconds.
auto Integer Begin with auto slideshow (time in milliseconds between slides)
continuous true Boolean Create an infinite feel with no endpoints
disableScroll false Boolean Stop any touches on this container from scrolling the page
stopPropagation false Boolean Stop event propagation
callback Function() Runs at slide change.
transitionEnd Function() Runs at the end slide transition.

Swipe API

prev() slide to prev

next() slide to next

getPos() returns current slide index position

getNumSlides() returns the total amount of slides

slide(index, duration) slide to set index position (duration: speed of transition in milliseconds)

Leave a comment

Your email address will not be published. Required fields are marked *

STAYUPDATED

Receive all our future posts instantly in your inbox. Enter your email to enroll.