-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsimple-useful-jquery-slideshow_nivo-slider-like-effect.html
247 lines (207 loc) · 9.04 KB
/
simple-useful-jquery-slideshow_nivo-slider-like-effect.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple Useful JQuery Slideshow - Nivo Slider Like Effect Slideshow</title>
<!--[if IE]><script type='text/javascript' src='http://html5shiv.googlecode.com/svn/trunk/html5.js'></script><![endif]-->
<style type="text/css">
* {margin:0;padding:0}
body {
background-color:#111;
padding:50px;
}
/* Slider */
#slider {
display:block;
border:4px solid #000;
width:400px; /* slider width */
height:250px; /* slider height */
margin:0 auto;
background:white url('data:image/gif;base64,R0lGODlhEAAQAPYAAP///wAAANTU1JSUlGBgYEBAQERERG5ubqKiotzc3KSkpCQkJCgoKDAwMDY2Nj4+Pmpqarq6uhwcHHJycuzs7O7u7sLCwoqKilBQUF5eXr6+vtDQ0Do6OhYWFoyMjKqqqlxcXHx8fOLi4oaGhg4ODmhoaJycnGZmZ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50%;
overflow:hidden;
position:relative;
}
/* For caption */
#slider figcaption {
display:block;
background-color:black;
font:normal normal 11px Arial,Sans-Serif;
color:white;
opacity:.8;
padding:10px 15px;
position:absolute;
right:0;
bottom:-100px; /* hide the caption with this way :) */
left:0;
z-index:99;
}
#slider img {
display:block;
margin:0 0;
width:400px; /* slide width */
height:250px; /* slide height */
position:absolute;
top:0;
left:0;
}
/* Navigation */
#slider-nav {
display:block;
position:absolute;
top:10px;
right:10px;
margin:0 0;
padding:0 0;
z-index:99;
}
#slider-nav a {
display:block;
float:left;
width:10px;
height:10px;
background-color:#111;
font-size:0;
color:transparent;
overflow:hidden;
text-indent:-99px;
margin:0 2px 0 0;
border:2px solid white;
-webkit-border-radius:100%;
-moz-border-radius:100%;
border-radius:100%;
-webkit-box-shadow:0 1px 2px rgba(0,0,0,.4);
-moz-box-shadow:0 1px 2px rgba(0,0,0,.4);
box-shadow:0 1px 2px rgba(0,0,0,.4);
}
#slider-nav .active {
background-color:#2589B4;
}
/* Hide all element inside the '#slider' until the page has been loaded! */
#slider .container, #slider figcaption {display:none}
#slider-nav {opacity:0}
</style>
</head>
<body data-author="Taufik Nurrohman$">
<figure id="slider">
<div class="container">
<img src="http://lorempixel.com/400/250/sports/1" alt="Lorem ipsum dolor sit amet...">
<img src="http://lorempixel.com/400/250/sports/2" alt="Consectetuer adipiscing elit...">
<img src="http://lorempixel.com/400/250/sports/3" alt="Sed diam nonummy nibh euismod tincidunt...">
<img src="http://lorempixel.com/400/250/sports/4" alt="Ut laoreet dolore magna aliquam erat volutpat...">
</div>
<figcaption></figcaption> <!-- slideshow caption -->
<nav id="slider-nav"></nav> <!-- navigation -->
</figure>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
/**
* NIVO SLIDER LIKE EFFECT SLIDESHOW BY TAUFIK NURROHMAN
* URL: https://plus.google.com/108949996304093815163/about
* Based on this slideshow framework: http://www.dte.web.id/2012/09/simple-useful-jquery-slideshow.html
*/
(function($) {
// ==================================================================================
// Configuration here:
// ----------------------------------------------------------------------------------
var config = {
slices: 10, // number of slices
speed: 600, // slideshow speed
easing: null, // easing type
interval: 3000 // slideshow interval
};
// ==================================================================================
// Some variables...
var $slider = $('#slider'),
$caption = $slider.find('figcaption'),
$container = $slider.find('.container'),
$nav = $('#slider-nav'),
$slide = $container.children(),
autoSlide = null,
$first = $slide.first();
// Auto append navigation item based on the slides length
$slide.each(function(index) {
var i = index + 1;
$nav.append('<a href="#slide-'+i+'">'+i+'</a>');
$(this).attr('id', 'slide-'+i);
});
// Set the slices size
var slice_w = $slider.width() / config.slices,
slice_h = $slider.height();
// Build the slices
for (var i = 0; i < config.slices; i++) {
$('<div class="slice" />').css({
'position':'absolute',
'width':slice_w,
'height':slice_h,
'left':slice_w*i,
'z-index':4,
'background-color':'transparent',
'background-repeat':'no-repeat',
'background-position':'-' + slice_w*i + 'px 0'
}).appendTo($slider);
}
// Catch the slices, and also set the different position between odd and even slices
var $sliceOdd = $slider.find('.slice:odd').css('bottom',0),
$sliceEven = $slider.find('.slice:even').css('top',0);
// Click to switch!
$nav.find('a').on("click", function() {
$nav.find('.active').removeClass('active');
$(this).addClass('active');
var pos = $(this).index(),
text = $slide.eq(pos).attr('alt'),
bg = $slide.eq(pos).attr('src');
$slide.hide().eq(pos).trigger("load").show();
// Do the caption and slices animation here!
$caption.stop().animate({bottom:'-100px'}, config.speed/2);
$sliceOdd.each(function(i) {
$(this).stop().delay(i*100).animate({bottom:'-'+slice_h+'px',opacity:0}, config.speed, config.easing, function() {
$(this).css({
'background-image':'url('+bg+')',
'bottom':0,
'opacity':1
});
});
});
$sliceEven.each(function(i) {
$(this).stop().delay(i*100).animate({top:'-'+slice_h+'px',opacity:0}, config.speed, config.easing, function() {
$(this).css({
'background-image':'url('+bg+')',
'top':0,
'opacity':1
});
});
}).promise().done(function() {
$caption.html(text).stop().animate({bottom:'0'}, config.speed/2);
});
clearInterval(autoSlide);
autoSlide = setInterval(slideShow, config.interval);
return false;
}).first().addClass('active');
// Init slideshow
$caption.html($slide.first().attr('alt')).stop().animate({bottom:'0'}, config.speed);
// Navigation clicker
function slideShow() {
if ($nav.find('.active').next().length) {
$nav.find('.active').next().trigger("click");
} else {
$nav.find('a').first().trigger("click");
}
}
// Run the slideshow on page load...
$(window).on("load", function() {
// remove the 'loading background-image' of '#slider'
$slider.css('background-image','none');
// Show the '.container', 'figcaption' and '#slide-nav' when the page has been loaded!
$container.show();
$caption.show();
$nav.css('opacity',1);
// Another init slideshow
$slider.find('.slice').css('background-image', 'url('+$first.attr("src")+')');
// Then, start the interval...
autoSlide = setInterval(slideShow, config.interval);
});
})(jQuery);
</script>
<a title="Demo by Taufik Nurrohman" href="http://www.dte.web.id/2012/09/nivo-slider-like-effect-slideshow.html" style="font:bold 12px Arial,Sans-Serif;color:#39f;display:block;text-decoration:none;position:absolute;top:10px;right:12px;">DTE :]</a>
</body>
</html>