Skip to content

A very lightweight (~2.5kb), minimal, easy to use image slider/carousel. No jQuery, no dependencies

Notifications You must be signed in to change notification settings

lukakerr/lightweight-slider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A lightweight image slider/carousel

Demo

Have a look at the slider here

Features

  • Auto play with a timer that resets when next, back or a random image is clicked
  • Super lightweight (3kb)
  • Easy to use
  • Custom left and right cursors (shown in second image below)
  • Simple customisation
  • Vanilla JavaScript (no jQuery)

Images

Taken by me!

slider
slider

Usage

Simply include the slider.min.js file at the bottom of your .html file, shown below.

For every image you include in the .banner div, you need to have a <a href="1"></a> with the corresponding image number.

<!DOCTYPE html>
<html>
<head>

  <title>lightweight-slider</title>

</head>
<body>

  <div class="banner" data-height="600" data-width="100%" data-slide-speed="900" data-autoslide="5000">
    <img src="1.jpg" class="slider">
    <img src="2.jpg" class="slider">
    <img src="3.jpg" class="slider">

    <div class="previous" data-previous-cursor="left.png"></div>
    <div class="next" data-next-cursor="right.png"></div>

    <div class="links">
        <a href="1"></a>
        <a href="2"></a>
        <a href="3"></a>
    </div>
  </div>

  <script src="slider.min.js"></script>

</body>
</html>

Customisation

Height:

  • Add data-height="600" to the .banner div. Height is in pixels.

Width:

  • Add data-width="100%" to the .banner div. Width is in percentages.

Slide transition speed:

  • Add data-slide-speed="900" to the .banner div. Speed is in milliseconds.

Autoslide:

  • Add data-autoslide="5000" to the .banner div. Time is in milliseconds.

Cursors:

  • Add data-previous-cursor="left.png" to the .previous div. You can provide an image as shown in the example, or leave blank to use the CSS attribute cursor: w-resize.
  • Add data-next-cursor="right.png" to the .next div. You can provide an image as shown in the example, or leave blank to use the CSS attribute cursor: e-resize.

About

A very lightweight (~2.5kb), minimal, easy to use image slider/carousel. No jQuery, no dependencies

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published