Coder Social home page Coder Social logo

slider's Introduction

A simple jQuery slide plugin.

Table of contents

Main

dist/
├── slider.js     (10 KB)
└── slider.min.js ( 5 KB)

Getting started

Quick start

Three quick start options are available:

  • Download the latest release.
  • Clone the repository: git clone https://github.com/fengyuanchen/slider.git.
  • Install with NPM: npm install @fengyuanchen/slider.

Installation

Include files:

<script src="/path/to/jquery.js"></script><!-- jQuery is required -->
<script src="/path/to/slider.js"></script>

Usage

Initialize with $.fn.slider method.

$('#slider').slider({
  activeClass: 'slider-active', // for slide nav
  autoPlay: true,
  contentClass: 'slider-content',
  disableClass: 'slider-disabled', // for slide "prev" and "next" button
  duration: 5000,
  effect: 'fade',
  easing: 'swing', // support "swing" and "linear", powered by jQuery
  navClass: 'slider-nav',
  nextClass: 'slider-next',
  prevClass: 'slider-prev',
  speed: 1000,
  trigger: 'click' // for slide nav
});

⬆ Back to top

Options

// Set slider options
$().slider(options);

// Set the global default options
$.fn.slider.setDefaults(options);

activeClass

  • Type: String
  • Default: 'slider-active'

An active state class for nav items.

autoPlay

  • Type: Boolean
  • Default: true

Auto play the slide after initialized.

contentClass

  • Type: String
  • Default: 'slider-content'

The content container.

disableClass

  • Type: String
  • Default: 'slider-disabled'

A disable state class for previous and next button.

duration

  • Type: Number
  • Default: 5000

The duration milliseconds of each slide item.

effect

  • Type: String
  • Options: 'fade', 'scrollX', 'scrollY'
  • Default: 'fade'

easing

  • Type: String
  • Options: 'swing', 'linear'
  • Default: 'swing'

Powered by jQuery.

navClass

  • Type: String
  • Default: 'slider-nav'

The navigation container.

prevClass

  • Type: String
  • Default: 'slider-prev'

The previous button.

nextClass

  • Type: String
  • Default: 'slider-next'

The next button.

speed

  • Type: Number
  • Default: 1000

The speed of the animation.

trigger

  • Type: String
  • Default: 'click'

The event for triggering slide.

⬆ Back to top

Methods

render()

Render the slider.

start()

Start the slider.

$().slider({
  autoPlay: false
}).slider('start');

stop()

stop the slider.

enable()

Enable the slider.

disable()

Disable the slider.

destroy()

Destroy the slider.

⬆ Back to top

No conflict

If you have to use other plugin with the same namespace, just call the $.fn.slider.noConflict method to revert to it.

<script src="other-plugin.js"></script>
<script src="slider.js"></script>
<script>
  $.fn.slider.noConflict();
  // Code that uses other plugin's "$().slider" can follow here.
</script>

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Opera (latest)
  • Edge (latest)
  • Internet Explorer 8+

As a jQuery plugin, you also need to see the jQuery Browser Support.

Versioning

Maintained under the Semantic Versioning guidelines.

License

MIT © Fengyuan Chen

⬆ Back to top

slider's People

Contributors

fengyuanchen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.