Adaptor, an extensible jQuery content slider

Posted on June 16, 2012 by Phil   18 comments

This jQuery plugin is a free and lightweight content slider for creating cool 3D (and 2D) slideshows for featured content on your website. In older browsers that do not support CSS3 with 3D transitions the plugin detects them and degrades gracefully to a simple transition maintaining the rich user experience for everyone. The plugin is powered by jQuery and CSS and is designed to be easy to add to an existing web page with the minimal effort on the designer or developer’s part. If you are a developer and want to spice things up a bit the plugin exposes a simple API for adding animation effects and extending it’s core functionality with paging controls and feedback indicators.

The full developer documentation for the plugin can be found on the Github project pages—the same place you can download the latest version of the code. This post aims to provide a high level example of how to set the plugin up along with a demo of the available effects and extensions.

Setting up the HTML

For 3D effects the HTML will need an outer box within which the animated box will rotate—I call this the view port. Next is the box itself within which the content slides will be added. The view port and box must be the same size as the content slides otherwise the animation effects won’t look good. Below is an example of how to configure the HTML.

<div class="slider-viewport"><!-- works as a viewport for the 3D transitions -->
  <div class="content-box"><!-- the 3d box -->
    <figure><!-- first slide -->
      <img src="img/slide-1.png">
      <figcaption>This is slide one's description</figcaption>
    </figure>
    <figure>
      <img src="img/slide-2.png">
      <figcaption>This is slide two's description</figcaption>
    </figure>
    <figure>
      <img src="img/slide-3.png">
      <figcaption>This is slide three's description</figcaption>
    </figure>
    <figure class="slide">
      <img src="img/slide-4.png">
      <figcaption>This is slide four's description</figcaption>
    </figure>
  </div>
</div>

With the above, if each .slide image is 600px x 400px then the view port and box should also be that size. It is also a good idea to initially constrain the height of the viewport and prevent the overflow so that all of the content slides don’t appear to spew down the page and jump back up once the plugin initialises. Below is the CSS for the HTML example above.

.slider-viewport, .content-box, .slide { width: 600px; height: 400px }
.content-box { overflow: hidden } /* stop slides overflowing */

The overflow will be set back to visible once the plugin has been initialised

Including the jQuery

Include the latest version of jQuery in your page and then include box-slider-all.jquery.min.js below it. For other builds with custom animations please visit the Github project.

<script src="js/jquery.min.js"></script>
<script src="js/box-slider-all.jquery.min.js"></script>

Next select the box, not the view port, and apply the plugin with your desired options. You can view all available options on the Github project pages.

$('.content-box').boxSlider({
    autoScroll: true
  , timeout: 5000
  , speed: 1200
  , pauseOnHover: true
});

Get involved

I’d love to see other people add effects, I plan to add plenty more myself! If you develop your own effects I’d ask you share those by either sending me your code or collaborating on Github. I hope you enjoy!!

18 Responses So Far

  1. Phil July 1, 2012 at 11:31 am

    There is a bug with the way Firefox transitions the 3D transform between 90 to 180deg which is currently under review.

    https://bugzilla.mozilla.org/show_bug.cgi?id=769892

  2. Thomas July 23, 2012 at 12:52 pm

    Hi. Thanks for the slider. I am trying to use it with the youtube video in one of the slides but it displays black screen in firefox and there is a ploblem with 3d sliding in Google Chrome. So I have decided to use fake image instead of the video.
    function start_video() {
    var iframe =
    '';
    document.getElementById("video_player").innerHTML = iframe;
    }

    and in the “figure” tag:

    But now I am having problem hiding this iframe when moving to the next slide. Any advise how to fix this problem. Thanks.

    • Phil July 23, 2012 at 1:00 pm

      Hi Thomas, thanks for using the plugin.

      The plugin is pretty new so I’d love to see what you have done so that I can help fix the problem and get it working with the video which shouldn’t be a problem.

      Can you zip up the code and send it to me or give me a link to visit. You can mail me at phil(at)profilepicture.co.uk

  3. corto August 14, 2012 at 1:11 pm

    Huge ! Gonna try this asap

  4. Pingback: Adaptor jQuery Content Slider | mintik

  5. Pingback: 様々な3Dエフェクトアニメーションでのコンテンツスライダーを実装できるjQueryプラグイン「Adaptor::jQuery content slider」 | BlackFlag

  6. Simon September 22, 2012 at 6:38 pm

    Hi Phil,

    Thanks for the slider, it’s very nice !

    Do you have news about the problem on Firefox (rotation problem) ?

    I’ll use this slider on my next folio version ;)

  7. Phil October 2, 2012 at 10:31 am

    Hi Phil.
    This is Phil.

    Just a short line to say Bravo!
    I think I’m goin to use it for the page of a friend of mine I’m workin on.

    Maybe a little question?
    Thanks.

    Do you think it would be possible to have a YouTube video embedded?

  8. Phil October 2, 2012 at 1:25 pm

    Okey dokey…
    I’ll show you the result.

  9. Pingback: Weekly Fresh Resources for Designers and Developers | TIPSMIX

  10. Pingback: Weekly Fresh Resources for Designers and Developers [October 2012] » Creative Design

  11. Ramiro January 8, 2013 at 6:52 pm

    Thats great plugin

    But, don’t work propertly in the last versions of CHROME ans FIREFOX

  12. Brandon January 10, 2013 at 4:18 am

    Hey Phil, I’m super new to developing and can not figure this out. If I zip a file can I send it to you? Or if you have any resources you could point me to I would relly appreciate it.

  13. Pingback: Weekly Fresh Resources for Designers and Developers [October 15th,2012] | Design Inspiration

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recommended reading

  • Ben Nadel Articles on “obsessively thorough web development” with Coldfusion and jQuery
  • Christian Heimann's blog – Wait till I come!! Articles on web development
  • David Walsh Articles around PHP, CSS, MooTools, jQuery and just about everything else
  • John Resig Javascript programmer and the creator of the jQuery library
  • Mary Lou (Codrops) Stunning designs with lots of cool jQuery effects

Photostream

  • Loading photostream from Flickr...