-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproto-carousel-ui.html
More file actions
389 lines (343 loc) · 11.9 KB
/
proto-carousel-ui.html
File metadata and controls
389 lines (343 loc) · 11.9 KB
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Responsive Grid</title>
<!-- Bootstrap -->
<link href="resources/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="resources/font-awesome-4.7.0/css/font-awesome.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
/* Global Base Styles
=====================================*/
h1{
margin-bottom:50px;
}
a:hover, a:focus, a:visited{
text-decoration:none;
}
.box{
width:100%;
height:250px;
border-radius:5px;
border:1px solid #666;
margin-bottom:30px;
}
.box h2{
font-size:24px;
margin:0;
padding:20px;
}
#zoom-view{
position: fixed;
top:0;
left:0;
width: 100%;
height: 100%;
opacity:0;
z-index: 99;
overflow:hidden;
perspective: 1000px;
pointer-events:none;
-webkit-transition: .5s;
-moz-transition: .5s;
-ms-transition: .5s;
-o-transition: .5s;
transition: .5s;
}
.zoom-controls{
position: fixed;
width:70px;
height:70px;
font-size:40px;
color:#000;
margin: 15px;
padding: 15px;
text-align:center;
vertical-align:middle;
cursor:pointer;
z-index:100;
-webkit-transition: .5s;
-moz-transition: .5s;
-ms-transition: .5s;
-o-transition: .5s;
transition: .5s;
}
.zoom-view-exit{
top: 0;
right: 0;
}
.zoom-next-slide{
top:50%;
right:0;
margin-top:-33px;
}
.zoom-prev-slide{
top:50%;
left:0;
margin-top:-33px;
}
.zoom-view-slides{
margin:0;
padding:0;
width:100%;
height:100%;
list-style:none;
-webkit-transform-style:preserve-3d;
transform-style:preserve-3d;
-webkit-transform: translate3d(0,0,150px);
transform: translate3d(0,0,150px);
-webkit-transition: -webkit-transform .5s;
-moz-transition: .5s;
-ms-transition: .5s;
-o-transition: .5s;
transition: transform .5s;
/*-webkit-transition-delay: 2s; Safari
transition-delay: 2s;*/
}
#zoom-view.open ul.zoom-view-slides{
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
.zoom-slide{
position:absolute;
width:800px;
height:560px;
top:50%;
left:50%;
margin-top:-280px;
margin-left:-400px;
background-color:#fff;
border-radius:10px;
box-shadow: 0px 5px 30px rgba(0,0,0,0.5);
overflow:hidden;
-webkit-transition: .5s;
-moz-transition: .5s;
-ms-transition: .5s;
-o-transition: .5s;
transition: .5s;
}
.zoom-slide h2{
margin:0;
padding:20px;
}
.zoom-slide:after{
content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(255,255,255,0.8);
-webkit-transition: background 0.5s;
-moz-transition: .5s;
-ms-transition: .5s;
-o-transition: .5s;
transition: background 0.5s;
}
.zoom-slide.current:after{
background: rgba(255,255,255,0);
-webkit-transition: background 0.5s;
transition: background 0.5s;
}
#zoom-view.open{
pointer-events:auto;
-webkit-transition: .5s;
-moz-transition: .5s;
-ms-transition: .5s;
-o-transition: .5s;
transition: .5s;
opacity:1;
background-color: rgba(0,0,0,.6);
}
.current{
z-index:1;
}
</style>
</head>
<body>
<div id="zoom-view">
<nav> <!-- Controls -->
<span class="zoom-controls zoom-view-exit fa fa-times"></span>
<span class="zoom-controls zoom-next-slide fa fa-chevron-right"></span>
<span class="zoom-controls zoom-prev-slide fa fa-chevron-left"></span>
</nav>
</div>
<div class="container">
<h1>Responsive Grid Demo</h1>
<div class="row">
<div class="col-xs-12 col-sm-4">
<div class="box">
<h2>Content Box 1</h2>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="box">
<h2>Content Box 2</h2>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="box">
<h2>Content Box 3</h2>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
<div class="box">
<h2>Content Box 4</h2>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="box">
<h2>Content Box 5</h2>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div class="box">
<h2>Content Box 6</h2>
</div>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="resources/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script>
;(function(window, document, $, undefined){
// Zoom-view cooldown
var cd = 500; // transition time in ms
var ready = true; // when not one cooldown, zoom-view init is ready
// Viewport dimensions
var viewport = {width: $(window).width(), height: $(window).height()};
// Event Listeners
$( ".box" ).click(function(){ zoomView( $(".box").index(this) ); });
$( ".zoom-controls").click(function(){ controls($(this)) });
$( window ).on('keydown', function(event){
// Move slides with left and right arrow keys
var key = event.which || event.keyCode;
var node;
if(key == 37) node = $(".zoom-prev-slide"); // Left
if(key == 39) node = $(".zoom-next-slide"); // Right
moveSlides(node);
});
// If window is resized, update viewport object
// Reposition slides if window is resized
var timer;
$(window).on('resize', function(e) {
viewport = {width: $(window).width(), height: $(window).height()};
// Timeout function executed at end of resize
clearTimeout(timer);
timer = setTimeout(function() {
positionSlides($(".zoom-view-slides").children(".current").index());
}, 250);
});
// Initializes zoom-view
// Calls functions to create and position new elements for zoom-view
function zoomView(i){
if(ready){
createSlideShow(i);
positionSlides(i);
setTimeout(function() {
$('#zoom-view').addClass('open');
}, 100);
ready = false;
console.log(ready);
setTimeout(function(){ ready = true; console.log(ready); }, cd);
}
}
function createSlideShow(index){
// Create slides container as an ul.zoom-view-slides
var slidesContainer = document.createElement('ul');
slidesContainer.className = "zoom-view-slides";
document.getElementById("zoom-view").appendChild(slidesContainer);
// Get html from existing slides
// Create new slide elements
// Append new slides to ul slideContainer
$(".box").each(function(ind){
var html = $(this).html();
var slide = document.createElement('li');
slide.className = "zoom-slide";
slide.innerHTML = html;
document.getElementsByClassName("zoom-view-slides")[0].appendChild(slide);
});
}
function positionSlides(index){
$(".zoom-slide").each(function(ind){
var diff = ind - index;
var percentage = .75; // percentage of viewport width
if($(this).hasClass("current")) $(this).removeClass("current");
if(diff == 0){
$(this).addClass("current");
$(this).removeAttr('style');
return;
}
if(diff < 0){
if(diff == -1){
$(this).css( "transform", "translate3d(-"+ (viewport.width*percentage) +"px , 0px, -150px)" );
}else{
$(this).css( "transform", "translate3d(-"+ (viewport.width*2*percentage) +"px , 0px, -150px)" );
}
}
else if(diff > 0){
if(diff == 1){
$(this).css( "transform", "translate3d("+ (viewport.width*percentage) +"px , 0px, -150px)" );
}else{
$(this).css( "transform", "translate3d("+ (viewport.width*2*percentage) +"px , 0px, -150px)" );
}
}
});
// Check zoom-view arrows
// If at the beginning or the end, make arrow 'inactive' (reduce opacity)
if($(".zoom-slide").last().hasClass("current")) $(".zoom-next-slide").css("opacity", "0.4");
else if($(".zoom-slide").first().hasClass("current")) $(".zoom-prev-slide").css("opacity", "0.4");
else $(".zoom-next-slide, .zoom-prev-slide").removeAttr('style');
}
// Determines which arrow was clicked and changes slides index accordingly
// Passes new index into positionSlides()
function moveSlides(el){
var currentSlide = ($(".zoom-view-slides").children(".current").index());
if(el.hasClass("zoom-next-slide")){
if(currentSlide < ($(".zoom-slide").length - 1)){
currentSlide ++;
}
}else if(el.hasClass("zoom-prev-slide")){
if(currentSlide > 0){
currentSlide --;
}
}
positionSlides(currentSlide);
}
// Determines which button was clicked
// and calls the respective function
function controls(el){
// If 'x' is clicked, call close zoom-view function
if(el.hasClass("zoom-view-exit")){
closeZoomView();
}
// Otherwise, one of the arrows was clicked so need to move the slides
else{ moveSlides(el); }
}
// Close zoom-view (remove open class)
// Remove slide container and slides
function closeZoomView(){
// Initializes zoom-view close
$("#zoom-view").removeClass("open");
// setTimeout removes slides after transition .5s
setTimeout(function() {
$(".zoom-view-slides").remove();
}, 500);
}
})(window, document, jQuery);
</script>
</body>
</html>