From 67ae241d24afbad399e8ad7da923a362a870897f Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Fri, 27 Jan 2012 15:29:46 -0800 Subject: [PATCH] More randomness --- assets/application.js | 29 +++++++++++++++-------------- assets/style.css | 16 ++++++++-------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/assets/application.js b/assets/application.js index 380ef02c9..d922209f9 100644 --- a/assets/application.js +++ b/assets/application.js @@ -33,7 +33,7 @@ function addRecentlyUpdatedRepo(repo) { var $item = $("
  • "); - var $name = $("").attr("href", repoUrl(repo)).text(repo.name); + var $name = $("").attr("href", repo.html_url).text(repo.name); $item.append($("").addClass("name").append($name)); var $time = $("").attr("href", repo.html_url + "/commits").text(strftime("%h %e, %Y", repo.pushed_at)); @@ -132,22 +132,24 @@ var sizes = ["smaller", "small", "medium", "large", "fat"]; var sizeDimensions = { - "smaller": 20, - "small": 50, - "medium": 100, + "smaller": 50, + "small": 80, + "medium": 130, "large": 200, "fat": 300 }; - var speeds = ["slow", "medium", "fast"]; + function randomOpacity(threshold) { + var opacity = Math.random(); - var speedDurations = { - "slow": 45000, - "medium": 30000, - "fast": 20000 - }; + while (opacity < threshold) { + opacity = Math.random(); + } + + return opacity; + } - function makeLarry(sizeName, speedName) { + function makeLarry(sizeName, speed) { var size = sizeDimensions[sizeName]; var top = Math.floor((flyzone().height() - size) * Math.random()); @@ -158,7 +160,7 @@ .attr("height", size) .css({ position: "absolute", - opacity: Math.random(), + opacity: randomOpacity(0.4), top: top, left: -size }); @@ -166,7 +168,6 @@ $img.prependTo(flyzone()); var left = flyzone().width() + size; - var speed = speedDurations[speedName]; $img.animate({left: left}, speed, function () { $img.remove(); @@ -178,7 +179,7 @@ function makeRandomLarry() { var size = randomItem(sizes); - var speed = randomItem(speeds); + var speed = Math.floor(Math.random() * 20000) + 15000; return makeLarry(size, speed); } diff --git a/assets/style.css b/assets/style.css index 3d77a6b58..bb2a6ee45 100644 --- a/assets/style.css +++ b/assets/style.css @@ -222,17 +222,17 @@ li.repo h3 { @-ms-keyframes large-swing { 0% { margin-top: 0px } 50% { margin-top: -40px } 100% { margin-top: 0px } } .larry.size-smaller, .larry.size-small { - animation: small-swing 1.5s infinite ease-in-out; - -moz-animation: small-swing 1.5s infinite ease-in-out; - -webkit-animation: small-swing 1.5s infinite ease-in-out; - -ms-animation: small-swing 1.5s infinite ease-in-out; + animation: small-swing 0.5s infinite ease-in-out; + -moz-animation: small-swing 0.5s infinite ease-in-out; + -webkit-animation: small-swing 0.5s infinite ease-in-out; + -ms-animation: small-swing 0.5s infinite ease-in-out; } .larry.size-medium, .larry.size-large { - animation: medium-swing 1.5s infinite ease-in-out; - -moz-animation: medium-swing 1.5s infinite ease-in-out; - -webkit-animation: medium-swing 1.5s infinite ease-in-out; - -ms-animation: medium-swing 1.5s infinite ease-in-out; + animation: medium-swing 1.25s infinite ease-in-out; + -moz-animation: medium-swing 1.25s infinite ease-in-out; + -webkit-animation: medium-swing 1.25s infinite ease-in-out; + -ms-animation: medium-swing 1.25s infinite ease-in-out; } .larry.size-medium, .larry.size-fat {