I'm not quite sure, but it was probably 2006 (correct me if I'm wrong) when with the birth of jQuery the very first non-Flash slideshows/sliders appeared on Web. Before that time, writing JavaScript was a horrible pain and therefore websites were boring, Internet wasn't that attractive as it is nowadays. Because nobody wanted to spend a week writing a thousand-lines code just to have something that does not work properly on any browser! Luckily, things have changed: JavaScript had become practical and that had heavily influenced the whole craft. Now things have changed even more: you can't ignore mobile & tablet devices, you must have your content accessible on any modern device.
The Problem
While working on a client project called Dizaino Virtuvė (Design Kitchen), I wanted to present interior portfolio in appealing and more appropriate way than what usually resides under the slideshow term. Not to mention accessibility on touch devices. So I thought: after all, moving mouse or sliding finger on screen is much easier than clicking or tapping arrows for dozens of times, right? Voila!
The Solution
The technique is based on some lines of HTML, CSS, JavaScript and (whole) jQuery framework. Unlike responsive and touch-friendly tooltip, I made it plugin-like so that you can call plenty of the slideshow instances from wherever you want.
Notice that the slideshow is returning what means anchors do not perform their primary function on touch devices. Consequently, this type of slideshow may not fit in every situation. Anyway, if you have a specific purpose, as it is in my case, the technique should serve well.
HTML
The structure couldn't be simpler: container and unordered list. What about content? It's totally up to your imagination: it could be anything from pure images to tables. An example with images:
<div id="slideshow"> <ul> <li><img src="1.jpg" alt="" /></li> <li><img src="2.jpg" alt="" /></li> <li><img src="3.jpg" alt="" /></li> <li><img src="4.jpg" alt="" /></li> <li><img src="5.jpg" alt="" /></li> </ul> </div>
CSS
I think you have just felt what the CSS code is like only by looking at the HTML above, but just in case, here's what to start with:
#slideshow
{
width: 100%;
height: 500px; /* slideshow height */
overflow: hidden;
position: relative; /* or absolute, but not static */
}
#slideshow ul
{
width: 9999%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
#slideshow li
{
height: 100%;
float: left;
margin: 0 20px; /* spacing between items */
}
JavaScript
The plugin, actually, is very tiny, however, it has too many lines to paste them here. Paradox. So I made gestured-slideshow.js available in the next tab of your browser.
There's no surprise you can call slideshow instance(s) in this way:
$( '#slideshow' ).gesturedSlideshow();
Captions, shadows, rounded borders, gradients, textures, animations and other loud phrases, for sure, are the way to style your next slideshow, but I decided to keep my demo calm and technique-focused. For that, for implementation and for more, check the demo, please:
Wait, but what about a non-returning slideshow? Yes, hopefully in one of my further posts! If you've got any thoughts on returning one, feel free to share them: leave a comment or tweet me.


9 comments. Write?
Čia tarp kitko - Demo linkas iš RSS neveikia normaliai (meta į http://feeds.feedburner.com/incoming/examples/gestures-sensitive-slideshow-responsive-and-touch-friendly). Sprendimas (mano nuomone): nelinkint /blahblahblah, o dėt pilną linką
Nice idea and works solidly on my Android. I was expecting to swipe, but that’s my fault for not reading the article properly ;)
The code I use for adding swipe to image rotators is here: https://gist.github.com/2773801 — or something similar, haven’t quite testing that exact version.
Thanks for stopping by, David. Haven’t had a chance to test it on Android, so thanks for the feedback ;-)
Wow, I dig your thinking there. Actually, by writing non-returning I had swipe in mind. Might be borrowing your idea soon!
Nice stuff, it works very well with a mouse but somehow the inverse direction when using a touch screen is unexpected and feels confusing IMO. I think if the direction of motion was consistent with the users finger then the addition of gestures and inertia may be unnecessary, it would still be a solid experience.
I like the concept, but you have to be careful with it. You used it on Dizaino Virtuvė and added the ability to enlarge the images. However, if you “scroll” to the very end and click on one of the thumbnails, it then zooms in that image but the slider resets itself back to initial position. So this kind of behavior can get rather annoying. On the other hand, the plugin suits perfectly for pages like the demo that you showed.
So to put in a nutshell, your solution can improve usability on touchscreen devices, but it can also create new usability issues along the way.
Hello,
I’ve used and adapted your code for a project in my firm.
What is it’s licence ?
That’s great, Patrick. Licensing is standard: use it however you want, but don’t sell it.
Just some feedback for you with regards to testing. It works well under the default browser on Android, it does not work at all on Firefox for Android.
If some one wishes to be updated with most recent technologies then he must be visit this web page and
be up to date everyday.