Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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);
})()}
@mathiasbynens

This comment has been minimized.

Copy link

mathiasbynens commented Jun 5, 2010

Why if (x == 0) {} and not if (!x)?
Why str = 0; dir = 0; instead of just str = dir = 0;?
Why x * 10 * 1000 and not x * 1e4?

THINK OF THE IE6 PERFORMANCE MAN

@phiggins42

This comment has been minimized.

Copy link

phiggins42 commented Jun 7, 2010

@math, var str = dir = 0 globalizes dir

@mathiasbynens

This comment has been minimized.

Copy link

mathiasbynens commented Jun 7, 2010

@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.

@phiggins42

This comment has been minimized.

Copy link

phiggins42 commented Jun 7, 2010

@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
You can’t perform that action at this time.