public
Last active

fancy slideshow navigation

  • Download Gist
fancy-slideshow-navigation.html
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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
<!doctype html>
<html lang="en">
<head>
 
<title>Fancy Slideshow Navigation (example)</title>
 
<style type="text/css">
 
#slideshow {
width: 900px;
height: 500px;
overflow: hidden;
position: relative;
margin: 20px auto;
}
 
#slideshow-reel {
width: 5400px;
height: 450px;
position: absolute;
top: 0;
left: 0;
}
 
#slideshow-reel .slide {
width: 900px;
height: 450px;
float: left;
background-color: gray;
}
 
#slideshow-reel .slide:nth-child(2n+1) {
background-color: #333;
}
 
#slideshow-reel h1 {
margin: 25px 60px;
color: #FFF;
font-size: 3em;
text-shadow: 0 -1px 1px #333;
}
 
/* arrow navigation */
 
.slideshow-arrow {
display: block;
position: absolute;
top: 190px;
width: 0;
height: 0;
border-style: solid;
border-width: 28px 21px;
border-color: transparent;
outline: none;
}
 
.slideshow-arrow:hover {
opacity: .5;
filter: alpha(opacity=50);
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
}
 
#slideshow-left {
left: 0;
border-right-color: #fff;
}
 
#slideshow-right {
right: 0;
border-left-color: #fff;
}
 
/* bottom navigation */
 
#slideshow-nav {
position: absolute;
left: 0;
bottom: 0;
width: 900px;
}
 
#slideshow-nav .nav-item {
float: left;
width: 150px;
padding: 11px 0;
outline: none;
}
 
#slideshow-nav .nav-item-line {
float: left;
width: 68px;
height: 1px;
line-height: 1px;
margin: 3px 0;
background-color: #bbb;
}
 
#slideshow-nav .nav-item-line-hidden {
background-color: transparent;
}
 
#slideshow-nav .nav-item-dot {
float: left;
width: 8px;
height: 8px;
margin: 0 3px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
background-color: #ed1d27;
}
 
/* active nav dot */
 
#active-nav-item {
display: block;
position: absolute;
top: 0;
left: 0;
width: 30px;
height: 30px;
margin-left: 60px;
background-color: #8e8d8b;
background-color: rgba(28, 27, 23, .5);
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
}
 
#active-nav-item .active-nav-item-inner {
display: inline-block;
width: 8px;
height: 8px;
margin: 11px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
background-color: #000;
}
 
 
 
</style>
 
<!--[if lt IE 7]>
<style type="text/css">
.slideshow-arrow,
#slideshow-nav .nav-item-line,
#slideshow-nav .nav-item-dot {
overflow: hidden;
}
 
.slideshow-arrow,
.slideshow-arrow:hover {
border-top-color: pink;
border-bottom-color: pink;
filter: chroma(color=pink);
}
 
#slideshow-left {
border-left-color: pink;
}
 
#slideshow-right {
border-right-color: pink;
}
</style>
<![endif]-->
 
</head>
 
<body>
 
<div id="slideshow">
<div id="slideshow-reel">
<div class="slide">
<h1>Slide 1</h1>
</div>
<div class="slide">
<h1>Slide 2</h1>
</div>
<div class="slide">
<h1>Slide 3</h1>
</div>
<div class="slide">
<h1>Slide 4</h1>
</div>
<div class="slide">
<h1>Slide 5</h1>
</div>
<div class="slide">
<h1>Slide 6</h1>
</div>
</div>
<a href="#" id="slideshow-left" class="slideshow-arrow"></a>
<a href="#" id="slideshow-right" class="slideshow-arrow"></a>
<div id="slideshow-nav">
<a href="#" class="nav-item">
<span class="nav-item-line nav-item-line-hidden"></span>
<span class="nav-item-dot"></span>
<span class="nav-item-line"></span>
</a>
<a href="#" class="nav-item">
<span class="nav-item-line"></span>
<span class="nav-item-dot"></span>
<span class="nav-item-line"></span>
</a>
<a href="#" class="nav-item">
<span class="nav-item-line"></span>
<span class="nav-item-dot"></span>
<span class="nav-item-line"></span>
</a>
<a href="#" class="nav-item">
<span class="nav-item-line"></span>
<span class="nav-item-dot"></span>
<span class="nav-item-line"></span>
</a>
<a href="#" class="nav-item">
<span class="nav-item-line"></span>
<span class="nav-item-dot"></span>
<span class="nav-item-line"></span>
</a>
<a href="#" class="nav-item">
<span class="nav-item-line"></span>
<span class="nav-item-dot"></span>
<span class="nav-item-line nav-item-line-hidden"></span>
</a>
<span id="active-nav-item">
<span class="active-nav-item-inner"></span>
</span>
</div>
</div>
 
 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
"></script>
<script type="text/javascript">
 
$(function() {
function changeSlide( newSlide ) {
// cancel any timeout
clearTimeout( slideTimeout );
// change the currSlide value
currSlide = newSlide;
// make sure the currSlide value is not too low or high
if ( currSlide > maxSlide ) currSlide = 0;
else if ( currSlide < 0 ) currSlide = maxSlide;
// animate the slide reel
$slideReel.animate({
left : currSlide * -900
}, 400, 'swing', function() {
// hide / show the arrows depending on which frame it's on
if ( currSlide == 0 ) $slideLeftNav.hide();
else $slideLeftNav.show();
if ( currSlide == maxSlide ) $slideRightNav.hide();
else $slideRightNav.show();
// set new timeout if active
if ( activeSlideshow ) slideTimeout = setTimeout(nextSlide, 1200);
});
// animate the navigation indicator
$activeNavItem.animate({
left : currSlide * 150
}, 400, 'swing');
}
function nextSlide() {
changeSlide( currSlide + 1 );
}
// define some variables / DOM references
var activeSlideshow = true,
currSlide = 0,
slideTimeout,
$slideshow = $('#slideshow'),
$slideReel = $slideshow.find('#slideshow-reel'),
maxSlide = $slideReel.children().length - 1,
$slideLeftNav = $slideshow.find('#slideshow-left'),
$slideRightNav = $slideshow.find('#slideshow-right'),
$activeNavItem = $slideshow.find('#active-nav-item');
// set navigation click events
// left arrow
$slideLeftNav.click(function(ev) {
ev.preventDefault();
activeSlideshow = false;
changeSlide( currSlide - 1 );
});
// right arrow
$slideRightNav.click(function(ev) {
ev.preventDefault();
activeSlideshow = false;
changeSlide( currSlide + 1 );
});
// main navigation
$slideshow.find('#slideshow-nav a.nav-item').click(function(ev) {
ev.preventDefault();
activeSlideshow = false;
changeSlide( $(this).index() );
});
// start the animation
slideTimeout = setTimeout(nextSlide, 1200);
});
 
</script>
 
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.