Created
June 4, 2010 22:12
-
-
Save paulirish/426012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// here's a rewrite of the amelie.js to avoid global variables and eval via setTimeout(string.. | |
// http://icant.co.uk/ie6-amelie/ | |
if (document.all && !window.XMLHttpRequest){(function(){ | |
var x = 1, | |
when = 0, | |
str, dir, fil; | |
function amelie() { | |
if (x == 2) { | |
x = 0; | |
} | |
if (x == 0) { | |
str = 0; | |
dir = 0; | |
when = Math.floor(Math.random() * 10*1000) + 2000; | |
setTimeout(amelie, when); | |
} else { | |
str = Math.floor(Math.random() * 2) + 2; | |
dir = Math.floor(Math.random() * 360); | |
setTimeout(amelie, 500); | |
} | |
var fil = "progid:DXImageTransform.Microsoft.MotionBlur(strength=" + str + ",direction=" + dir + ",enabled='true')"; | |
document.body.style.filter = fil; | |
x++; | |
} | |
setTimeout(amelie, 1000); | |
})()} |
@math, var str = dir = 0 globalizes dir
@phiggins42: Even when it's called from inside an anonymous function? Also note that in this case it’s not exactly var str = dir = 0;
but str = dir = 0
— the variables str
and dir
have already been declared.
@math - you are totally right. I thought the gist has changed since your initial comment and the 0's were in the var declaration for str && dir ... /me stands corrected.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why
if (x == 0) {}
and notif (!x)
?Why
str = 0; dir = 0;
instead of juststr = dir = 0;
?Why
x * 10 * 1000
and notx * 1e4
?THINK OF THE IE6 PERFORMANCE MAN