Browse Source

Fix issue when loading images in Chrome

pull/40/head
8chan 10 years ago
committed by Fredrick Brennan
parent
commit
5a02cd61db
  1. 12
      js/no-animated-gif.js

12
js/no-animated-gif.js

@ -13,7 +13,17 @@ function unanimate_gif(e) {
$(e).parent().prepend(c);
c.attr('width', $(e).width());
c.attr('height',$(e).height());
c[0].getContext('2d').drawImage(e, 0, 0, $(e).width(), $(e).height());
function draw_image() {
c[0].getContext('2d').drawImage(e, 0, 0, $(e).width(), $(e).height())
};
// Fix drawing image before loaded. Note that Chrome needs to check .complete because load() is NOT called if loaded from cache.
if (!e.complete) {
e.onload = draw_image;
} else {
draw_image();
}
$(e).hide();
}

Loading…
Cancel
Save