Hover scrub
https://github.com/edgeui/jQuery-Scrubnails
by Elon Zito
HTML
<ul id="thumbnails"></ul>
<div id="progress"></div>
CSS
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after, q:before, q:after {
content:'';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/* ------------------------------------------------------------------------ */
body {
background: #ccc;
padding: 30px;
font-family:"Open Sans";
}
.nail {
width: 700px;
height: 300px;
background-color: white;
border-radius: 4px;
overflow: hidden;
display: inline-block;
margin-right: 10px;
margin-bottom: 10px;
position: relative;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
}
.nail > img {
float:left;
border-radius: 2px;
}
.nail:hover {
cursor: pointer;
}
.nail .overlay {
position: absolute;
top:0;
width:700px;
height: 300px;
z-index: 2000;
background: -moz-linear-gradient(top, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 1)),...
JavaScript
/**
* Scrubnails
* Author: Chris Johnson ([email protected] / http://explore.js)
* Version: 1.0
* Dependencies: jQuery
*/
(function ($) {
$.fn.Scrubnails = function (options) {
if (!this.length) {
return this;
}
var opts = $.extend(true, {}, $.fn.Scrubnails.defaults, options);
this.each(function () {
var $this = $(this);
// build images
for (var i = 0; i < opts.images.length; i++) {
var itemImages = opts.images[i].images;
var li = $('<li/>').addClass('nail').attr('id', 'nail_' + i);
$this.append(li);
for (var j = 0; j < itemImages.length; j++) {
var img = $('<img/>').addClass('frame').attr('src', itemImages[j]).attr('width','700').css({
display: 'block',
position: 'absolute',
top: 0,
left: 0,
zIndex: 1000
}).hide();
li.append(img);
li.children('img').eq(0).show();
}
}
$(".nail").mousemove(function (e) {
var self = this;
var x = (e.pageX - this.offsetLeft);
var width = $(this).width();
var imageCount = $(this).children('img').length;
var step = Math.floor(width / imageCount);
var max = 0;
var min = 0;
var idx = 0;
loop();
function loop() {
if (x >= min && x < max + step) {
$(self).children('img').hide();
$(self).children('img').eq(idx).show();
} else {
$(self).children('img').hide();
min = max;
max = max + step;
idx = idx + 1;
...