Skip to content

Commit cea355b

Browse files
committed
Add Larry
1 parent 3a188ff commit cea355b

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

assets/application.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(function ($, undefined) {
2+
23
// Put custom repo URL's in this object, keyed by repo name.
34
var repoUrls = {
45
"bootstrap": "http://twitter.github.com/bootstrap/",
@@ -114,4 +115,89 @@
114115
});
115116
});
116117

118+
function randomItem(array) {
119+
return array[Math.floor(Math.random() * array.length)];
120+
}
121+
122+
var $flyzone;
123+
124+
function flyzone() {
125+
if (!$flyzone) {
126+
$flyzone = $("<div>").attr("id", "flyzone").prependTo(document.body);
127+
}
128+
129+
return $flyzone;
130+
}
131+
132+
var sizes = ["smaller", "small", "medium", "large", "fat"];
133+
134+
var sizeDimensions = {
135+
"smaller": 20,
136+
"small": 50,
137+
"medium": 100,
138+
"large": 200,
139+
"fat": 300
140+
};
141+
142+
var speeds = ["slow", "medium", "fast"];
143+
144+
var speedDurations = {
145+
"slow": 45000,
146+
"medium": 30000,
147+
"fast": 20000
148+
};
149+
150+
function makeLarry(sizeName, speedName) {
151+
var size = sizeDimensions[sizeName];
152+
var top = Math.floor((flyzone().height() - size) * Math.random());
153+
154+
var $img = $("<img>")
155+
.addClass("larry size-" + sizeName)
156+
.attr("src", "assets/larry.png")
157+
.attr("width", size)
158+
.attr("height", size)
159+
.css({
160+
position: "absolute",
161+
opacity: Math.random(),
162+
top: top,
163+
left: -size
164+
});
165+
166+
$img.prependTo(flyzone());
167+
168+
var left = flyzone().width() + size;
169+
var speed = speedDurations[speedName];
170+
171+
$img.animate({left: left}, speed, function () {
172+
$img.remove();
173+
makeRandomLarry();
174+
});
175+
176+
return $img;
177+
}
178+
179+
function makeRandomLarry() {
180+
var size = randomItem(sizes);
181+
var speed = randomItem(speeds);
182+
return makeLarry(size, speed);
183+
}
184+
185+
$(function () {
186+
$("#logo").click(function () {
187+
makeRandomLarry();
188+
});
189+
});
190+
191+
var match = (/\blarry(=(\d+))?\b/i).exec(window.location.search);
192+
193+
if (match) {
194+
var n = parseInt(match[2]) || 20;
195+
196+
$(function () {
197+
for (var i = 0; i < n; ++i) {
198+
setTimeout(makeRandomLarry, Math.random() * n * 500);
199+
}
200+
});
201+
}
202+
117203
})(jQuery);

assets/larry.png

2.86 KB
Loading

assets/style.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ a:hover {
3131
}
3232

3333
#wrapper {
34+
position: relative;
3435
width: 960px;
3536
margin: 0 auto;
3637
padding: 20px 0;
@@ -204,3 +205,48 @@ li.repo h3 {
204205
.repo.python::after {
205206
border-right-color: #6aad2d;
206207
}
208+
209+
@keyframes small-swing { 0% { margin-top: 0px } 50% { margin-top: -10px } 100% { margin-top: 0px } }
210+
@-moz-keyframes small-swing { 0% { margin-top: 0px } 50% { margin-top: -10px } 100% { margin-top: 0px } }
211+
@-webkit-keyframes small-swing { 0% { margin-top: 0px } 50% { margin-top: -10px } 100% { margin-top: 0px } }
212+
@-ms-keyframes small-swing { 0% { margin-top: 0px } 50% { margin-top: -10px } 100% { margin-top: 0px } }
213+
214+
@keyframes medium-swing { 0% { margin-top: 0px } 50% { margin-top: -20px } 100% { margin-top: 0px } }
215+
@-moz-keyframes medium-swing { 0% { margin-top: 0px } 50% { margin-top: -20px } 100% { margin-top: 0px } }
216+
@-webkit-keyframes medium-swing { 0% { margin-top: 0px } 50% { margin-top: -20px } 100% { margin-top: 0px } }
217+
@-ms-keyframes medium-swing { 0% { margin-top: 0px } 50% { margin-top: -20px } 100% { margin-top: 0px } }
218+
219+
@keyframes large-swing { 0% { margin-top: 0px } 50% { margin-top: -40px } 100% { margin-top: 0px } }
220+
@-moz-keyframes large-swing { 0% { margin-top: 0px } 50% { margin-top: -40px } 100% { margin-top: 0px } }
221+
@-webkit-keyframes large-swing { 0% { margin-top: 0px } 50% { margin-top: -40px } 100% { margin-top: 0px } }
222+
@-ms-keyframes large-swing { 0% { margin-top: 0px } 50% { margin-top: -40px } 100% { margin-top: 0px } }
223+
224+
.larry.size-smaller, .larry.size-small {
225+
animation: small-swing 1.5s infinite ease-in-out;
226+
-moz-animation: small-swing 1.5s infinite ease-in-out;
227+
-webkit-animation: small-swing 1.5s infinite ease-in-out;
228+
-ms-animation: small-swing 1.5s infinite ease-in-out;
229+
}
230+
231+
.larry.size-medium, .larry.size-large {
232+
animation: medium-swing 1.5s infinite ease-in-out;
233+
-moz-animation: medium-swing 1.5s infinite ease-in-out;
234+
-webkit-animation: medium-swing 1.5s infinite ease-in-out;
235+
-ms-animation: medium-swing 1.5s infinite ease-in-out;
236+
}
237+
238+
.larry.size-medium, .larry.size-fat {
239+
animation: large-swing 1.5s infinite ease-in-out;
240+
-moz-animation: large-swing 1.5s infinite ease-in-out;
241+
-webkit-animation: large-swing 1.5s infinite ease-in-out;
242+
-ms-animation: large-swing 1.5s infinite ease-in-out;
243+
}
244+
245+
#flyzone {
246+
position: fixed;
247+
top: 0;
248+
left: 0;
249+
width: 100%;
250+
height: 100%;
251+
overflow: hidden;
252+
}

0 commit comments

Comments
 (0)