Skip to content
This repository

A fullscreen, hardware accelerated slider for jQuery.

tree: d90ba4b70a

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

Superslides 0.4

Superslides is a full screen slider for jQuery heavily influenced by Nathan Searles' SlidesJS. It's designed to be as flexible as possible, while maintaining a reasonable code base and good browser compatibility.

It is 4kb minified (8kb uncompressed).

Usage

Check out the demo for a complete example. Basic usage is as follows. See options below for things you can change.

$('#slides').superslides(options_hash)

Options

Currently, Superslides has a few configurable options: auto play with a delay, slide transition speed, and slide easing (jQueryUI or the jQuery easing plugin required).

Listed as option: default_value

delay: 5000
play: false
slide_speed: 'normal'
slide_easing: 'linear'
nav_class: 'slides-navigation'
container_class: 'slides-container'
pagination: true
hashchange: true

Events

Superslides triggers a few events that you can bind to (listed in the order they are fired):

slides.initialized
slides.animated

When the window is resized and on first load before slides.initialized:

slides.image_adjusted
slides.sized

Binding to events:

$('body').on('slides.initialized', '#slides', function(){
  console.log('Superslides initialized')
})

You can also control the slider by triggering the respective events:

$('#slides').trigger('slides.start')
$('#slides').trigger('slides.stop')
$('#slides').trigger('slides.play')
$('#slides').trigger('slides.next')
$('#slides').trigger('slides.prev')

Alternatively, use the API to control the slider

$('#slides').superslides('start')
$('#slides').superslides('stop')
$('#slides').superslides('play')
$('#slides').superslides('prev')
$('#slides').superslides('next')
$('#slides').superslides('animate', 3) // where 3 is a slide number

Notes on the differences between play and start:

Play will slide only after the delay time. Start will slide first, then start playing (i.e., slide, then continue sliding after the delay time--5 seconds by default)

Markup

Markup is pretty straightforward. At minimum it looks like this:

<div id="slides">
  <div class="slides-container">
    <img src="http://flickholdr.com/1000/800" alt="">
    <img src="http://flickholdr.com/1000/800" alt="">
  </div>
</div>

You could even use a UL as the slides-container

<div id="slides">
  <ul class="slides-container">
    <li>
      <img src="http://flickholdr.com/1000/800" alt="">
      <div class="container">
        Slide one
      </div>
    </li>
    <li>
      <img src="http://flickholdr.com/1000/800/space" alt="">
      <div class="container">
        Slide two
      </div>
    </li>
    <li>
      <img src="http://flickholdr.com/1000/800/tech" alt="">
      <div class="container">
        Slide three
      </div>
    </li>
  </ul>
  <nav class="slides-navigation">
    <a href="#" class="next">Next</a>
    <a href="#" class="prev">Previous</a>
  </nav>
</div>

Hardware Acceleration

Superslides is compatible with the jQuery Animate Enhanced plugin. Simply include it before this plugin and it will automatically smooth out transitions using CSS instead of JavaScript.

Contributing

If you'd like to contribute by fixing bugs, adding features, or otherwise, you should know that Superslides is written in Coffeescript with Jasmine and Jasmine Headless Webkit. Write a test for your feature and submit a pull request :)

Known Bugs & Caveats

  • IE 7 & 8 don't scale the image nicely due to min/max-width. You can remedy this with a polyfill.

MIT License

Copyright (C) 2012 Nic Haynes (aka, Nic Aitch)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.