Tiny Content Slider with Pure JavaScript

Category: Javascript , Slider | July 14, 2018
Author: ganlanyuan
Views Total: 3,377
Official Page: Go to website
Last Update: July 14, 2018
License: MIT

Preview:

Tiny Content Slider with Pure JavaScript

Description:

A tiny yet feature-rich content slider built using pure JavaScript and plain Html / CSS.

Features:

  • Autoplay.
  • Navigation and pagination.
  • Infinite loop like a carousel.
  • Responsive design.
  • Multiple items in one slide.
  • Custom animations.
  • Keyboard navigation.

Basic usage:

Add the tiny-slider.css and tiny-slider.js to your webpages.

<link rel="stylesheet" href="assets/css/tiny-slider.css">
<script src="assets/js/tiny-slider.js"></script>

Add html content to the slider.

<div class="container">
  <div class="slider">
    <div>
      <p>Slide 1</p>
    </div>
    <div>
      <p>Slide 2</p>
    </div>
    <div>
      <p>Slide 3</p>
    </div>
  </div>
</div>

Initialize the slider.

tns({container: '.container'});

Available customization options.

tns({
  container: '.slider',
  mode: 'carousel', // or 'gallery'
  axis: 'horizontal', // or 'vertical'
  items: 1,
  gutter: 0,
  edgePadding: 0,
  fixedWidth: false,
  slideBy: 1,
  controls: true,
  controlsText: ['prev', 'next'],
  controlsContainer: false,
  nav: true,
  navContainer: false,
  navAsThumbnails: false,
  arrowKeys: false,
  speed: 300,
  autoplay: false,
  autoplayTimeout: 5000,
  autoplayDirection: 'forward',
  autoplayText: ['start', 'stop'],
  autoplayHoverPause: false,
  autoplayButton: false,
  autoplayButtonOutput: true,
  autoplayResetOnVisibility: true,
  loop: true,
  rewind: false,
  autoHeight: false,
  responsive: false,
  lazyload: false,
  touch: true,
  mouseDrag: false,
  swipeAngle: 15,
  nested: false,
  freezable: true,
  onInit: false
});

Changelog:

v2.8.1 (07/14/2018)

  • update

v2.7.4 (07/08/2018)

  • update vertical slider classes

v2.7.3 (06/30/2018)

  • gallery: fix page overlapping when click nav, fix getImageArray() and getMaxSlideHeight()
  • fix an issue in navInit

v2.7.3 (06/24/2018)

  • gallery: fix page overlapping when click nav, fix getImageArray() and getMaxSlideHeight()

v2.7.2 (06/17/2018)

  • update has3D.js so that it can run in <head>

v2.7.1 (06/09/2018)

  • gallery mode: prevent touching/draging

v2.7.0 (06/02/2018)

  • gallery mode: prevent touching/draging

v2.6.0 (05/30/2018)

  • update touch variables

One thought on “Tiny Content Slider with Pure JavaScript

  1. Tomas

    Can anyone please tell me if its possible to have 2 items?
    Getting a:
    “items are not enough to show on 1 page” error

    Reply

Leave a Reply