-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
171 lines (150 loc) · 5.18 KB
/
index.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
<!doctype html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="http://www.turnjs.com/css/jquery.ui.css">
<link type="text/css" rel="stylesheet" href="http://www.turnjs.com/css/default.css">
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<script type="text/javascript" src="http://www.turnjs.com/lib/hash.js"></script>
<script type="text/javascript" src="http://www.turnjs.com/lib/turn.min.js"></script>
<script type="text/javascript" src="http://www.turnjs.com/lib/zoom.min.js"></script>
<script type="text/javascript" src="jquery.waitforimages.min.js"></script>
<script type="text/javascript" src="images.js"></script>
<style>
#wrapper {
padding-top:100px;
margin:auto;
width:400px;
height:300px;
}
.sample-flipbook{
width:400px;
height:200px;
-webkit-transition:margin-left 0.2s;
-moz-transition:margin-left 0.2s;
-ms-transition:margin-left 0.2s;
-o-transition:margin-left 0.2s;
transition:margin-left 0.2s;
}
.sample-flipbook .page{
width:200px;
height:200px;
background-color:white;
line-height:300px;
font-size:20px;
}
.sample-flipbook .page-wrapper{
-webkit-perspective:2000px;
-moz-perspective:2000px;
-ms-perspective:2000px;
-o-perspective:2000px;
perspective:2000px;
}
.sample-flipbook .hard{
background:#ccc !important;
color:#333;
-webkit-box-shadow:inset 0 0 5px #666;
-moz-box-shadow:inset 0 0 5px #666;
-o-box-shadow:inset 0 0 5px #666;
-ms-box-shadow:inset 0 0 5px #666;
box-shadow:inset 0 0 5px #666;
font-weight:bold;
}
.sample-flipbook .odd{
background:-webkit-gradient(linear, right top, left top, color-stop(0.95, #FFF), color-stop(1, #DADADA));
background-image:-webkit-linear-gradient(right, #FFF 95%, #C4C4C4 100%);
background-image:-moz-linear-gradient(right, #FFF 95%, #C4C4C4 100%);
background-image:-ms-linear-gradient(right, #FFF 95%, #C4C4C4 100%);
background-image:-o-linear-gradient(right, #FFF 95%, #C4C4C4 100%);
background-image:linear-gradient(right, #FFF 95%, #C4C4C4 100%);
-webkit-box-shadow:inset 0 0 5px #666;
-moz-box-shadow:inset 0 0 5px #666;
-o-box-shadow:inset 0 0 5px #666;
-ms-box-shadow:inset 0 0 5px #666;
box-shadow:inset 0 0 5px #666;
}
.sample-flipbook .even{
background:-webkit-gradient(linear, left top, right top, color-stop(0.95, #fff), color-stop(1, #dadada));
background-image:-webkit-linear-gradient(left, #fff 95%, #dadada 100%);
background-image:-moz-linear-gradient(left, #fff 95%, #dadada 100%);
background-image:-ms-linear-gradient(left, #fff 95%, #dadada 100%);
background-image:-o-linear-gradient(left, #fff 95%, #dadada 100%);
background-image:linear-gradient(left, #fff 95%, #dadada 100%);
-webkit-box-shadow:inset 0 0 5px #666;
-moz-box-shadow:inset 0 0 5px #666;
-o-box-shadow:inset 0 0 5px #666;
-ms-box-shadow:inset 0 0 5px #666;
box-shadow:inset 0 0 5px #666;
}
#flipbook {
text-align: center;
font-family: "helvetica neue", helvetica, arial;
}
img {
width: 200px;
}
body {
background-color: #000000;
background-image: url(BGD-Page.jpg);
background-repeat: repeat-x;
background-position: left top;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="flipbook" class="sample-flipbook">
</div>
</div>
<script type="text/javascript">
var book = $('#flipbook');
book.append('<div class="hard">Demo</div>');
book.append('<div class="hard"></div>');
$.each(images, function(key, val) {
book.append('<div><img src="' + val + '"></div></li>');
});
if (images.length % 2 != 0) { book.append('<div></div>'); }
book.append('<div class="hard"></div>');
book.append('<div class="hard">Yours truly</div>');
$(window).load(function() {
var page_width = 400;
var page_height = 300;
var book_width = page_width * 2;
$('#wrapper').css('width', book_width + 'px');
$('#wrapper').css('height', page_height + 50 + 'px');
$('#flipbook .page').css('width', page_width + 'px');
$('#flipbook .page').css('height', page_height + 'px');
$('img').css('width', page_width);
//resize images
$('img').each(function() {
var maxWidth = page_width; // Max width for the image
var maxHeight = page_height; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max
if(width > maxWidth){
ratio = maxWidth / width; // get ratio for scaling image
$(this).css("width", maxWidth); // Set new width
$(this).css("height", height * ratio); // Scale height based on ratio
height = height * ratio; // Reset height to match scaled image
width = width * ratio; // Reset width to match scaled image
}
// Check if current height is larger than max
if(height > maxHeight){
ratio = maxHeight / height; // get ratio for scaling image
$(this).css("height", maxHeight); // Set new height
$(this).css("width", width * ratio); // Scale width based on ratio
width = width * ratio; // Reset width to match scaled image
}
});
$("#flipbook").turn({
width: book_width,
height: page_height,
autoCenter: true
});
});
</script>
</body>
</html>