servo/src/test/html/longcat.js
Brian Anderson 0db96944e6 Longcat improvements
This fixes layout under Firefox and increases the frame rate for smoother animation.
2013-09-12 13:12:51 -07:00

24 lines
640 B
JavaScript

var longcats = window.document.getElementsByTagName("img");
var longcat_top = longcats[0];
var longcat_mid = longcats[1];
var longcat_bot = longcats[2];
function wait_for_img_load(f) {
if (longcat_top.width != 0 && longcat_mid.width != 0 && longcat_bot.width != 0) {
f();
} else {
window.setTimeout(function() { wait_for_img_load(f) }, 1);
}
}
wait_for_img_load(function() {
var count = 0;
function elongate() {
var height = Math.round((Math.cos(count + Math.PI) + 1) * 100 + 20);
count += 0.2;
longcat_mid.height = height;
longcat_mid.width = 600;
window.setTimeout(function() { elongate() }, 50);
}
elongate();
});