-
Notifications
You must be signed in to change notification settings - Fork 27
/
examples.html
211 lines (193 loc) · 7.03 KB
/
examples.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
<link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen" />
<!-- <link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" /> -->
<title>Glitch.js by sjhewitt</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/sjhewitt/glitch.js/master/glitch.js"></script>
<script src="javascripts/html2canvas.js"></script>
</head>
<body>
<div class="outer-container">
<header>
<div class="container">
<h1><a href="index.html">Glitch.js</a></h1>
<h2>Glitched DOM elements</h2>
</div>
</header>
<div class="container">
<div id="example1" class="example">
<h1>Glitch an image</h1>
<img class="source" src="images/Lenna.png" style="width: 100%;" />
<div class="middle"><button class="btn">Glitch</button></div>
<div class="target"></div>
</div>
<script>
$("#example1 button").click(function(){
$("#example1 .source").glitch(function(canvas){
$("#example1 .target").html(canvas);
});
})
</script>
<div id="example2" class="example">
<h1>Glitch some HTML elements</h1>
<div class="source">
<h2 style="background: #238aa1;">Header Element</h2>
<div>
<input type="text" value="input text" />
</div>
<ul>
<li>List Element 1</li>
<li>List Element 2</li>
<li>List Element 3</li>
<li>List Element 4</li>
</ul>
<button class="btn">Button with rounded corners</button>
</div>
<div class="middle"><button class="btn">Glitch</button></div>
<div class="target"></div>
</div>
<script>
var example2 = false;
$("#example2 button").click(function(){
if(!example2) {
example2 = $("#example2 .source");
} else {
$("#example2 canvas").replaceWith(example2);
}
example2.glitch();
})
</script>
<div id="example3" class="example">
<h1>HTML and cross-domain images</h1>
<div class="source" style="background: #aaa; border: 5px solid green;">
<h2 style="background: #238aa1;">Header Element</h2>
<div>
<input type="text" value="input text" />
</div>
<div style="display: inline-block; background-image: url(http://www.google.com/logos/2011/gregormendel11-res.jpg); width: 256px; height: 341px;">
<p style="text-align: center; color: red;">And some text on top of it</p>
</div>
</div>
<div class="middle"><button class="btn">Glitch</button></div>
<div class="target"></div>
</div>
<script>
var example3 = false;
$("#example3 button").click(function(){
if(!example3) {
example3 = $("#example3 .source");
} else {
$("#example3 canvas").replaceWith(example3);
}
example3.glitch();
})
</script>
<style type="text/css">
#example4 .source {
background: #4a3b9c;
border: 5px solid green;
height: 300px;
overflow: auto;
}
#example4 h2 {
background: #238aa1;
}
</style>
<div id="example4" class="example">
<h1>Glitch Transition</h1>
<div class="source">
<h2>Page 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="middle"><button class="btn">Glitch</button></div>
<div class="target"></div>
</div>
<script>
$(function(){
var example4a = $("#example4 .source");
var example4b = $("<div class='source'><h2>Page 2</h2><p>Beard flexitarian semiotics tofu retro. Synth sustainable accusamus hoodie, scenester retro wayfarers occupy. Twee ea marfa nesciunt pickled pork belly. Pop-up fugiat squid, aute brunch viral fingerstache american apparel et cupidatat placeat butcher etsy art party. Mlkshk sriracha delectus, dreamcatcher occaecat freegan esse placeat fugiat williamsburg aliquip nisi cred retro jean shorts. Stumptown mixtape gastropub, you probably haven't heard of them master cleanse laboris sunt scenester post-ironic dreamcatcher ex. Williamsburg sriracha cray high life cillum.</p></div>");
$("#example4 button").click(function(){
if(example4a[0].parentNode) {
example4a.glitch(example4b, {
effect: "slide"
});
} else {
example4b.glitch(example4a);
}
});
});
</script>
<style type="text/css">
#example5 .source {
background: #4a3b9c;
border: 5px solid green;
}
#example5 h2 {
background: #238aa1;
}
</style>
<div id="example5" class="example">
<h1>Glitch Transition (different size elements)</h1>
<div class="source">
<h2>Page 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="middle"><button class="btn">Glitch</button></div>
<div class="target"></div>
</div>
<script>
$(function(){
var example5a = $("#example5 .source");
var example5b = $("<div class='source'><h2>Page 2</h2><p>Beard flexitarian semiotics tofu retro. Synth sustainable accusamus hoodie, scenester retro wayfarers occupy. Twee ea marfa nesciunt pickled pork belly. Pop-up fugiat squid, aute brunch viral fingerstache american apparel et cupidatat placeat butcher etsy art party. Mlkshk sriracha delectus, dreamcatcher occaecat freegan esse placeat fugiat williamsburg aliquip nisi cred retro jean shorts. Stumptown mixtape gastropub, you probably haven't heard of them master cleanse laboris sunt scenester post-ironic dreamcatcher ex. Williamsburg sriracha cray high life cillum.</p></div>").width(400);
$("#example5 button").click(function(){
if(example5a[0].parentNode) {
glitch.transition(example5a, example5b);
} else {
glitch.transition(example5b, example5a, {
effect: "slide"
});
}
});
});
</script>
<div id="wholePage" class="example centered">
<h1>Now glitch the whole page</h1>
<div class="middle">
<button class="btn">GLITCH!!</button>
</div>
</div>
<script>
$("#wholePage button").click(function(){
window.oldContent = $(".outer-container");
glitch.transition(
window.oldContent,
$("<div class='outer-container'><div class=\"container middle\"><button id=\"restore\" class='btn'>Restore</button></div></div>"),
{
effect: "slide"
});
})
</script>
</div>
</div>
<script>
$("body").on("click", "#restore", function(){
glitch.transition($(".outer-container"), window.oldContent);
});
</script>
</body>
</html>