incorporating the animated gif hack
This commit is contained in:
parent
177b94bd98
commit
620ffdbcd2
|
@ -275,6 +275,10 @@ var FileImage = function(src, rawImage) {
|
|||
var self = this;
|
||||
this.src = src;
|
||||
this.isLoaded = false;
|
||||
|
||||
// animationHack: see installHackToSupportAnimatedGifs() for details.
|
||||
this.animationHackImg = undefined;
|
||||
|
||||
if (rawImage && rawImage.complete) {
|
||||
this.img = rawImage;
|
||||
this.isLoaded = true;
|
||||
|
@ -321,7 +325,19 @@ FileImage.installBrokenImage = function(path) {
|
|||
|
||||
|
||||
FileImage.prototype.render = function(ctx, x, y) {
|
||||
ctx.drawImage(this.img, x, y);
|
||||
this.installHackToSupportAnimatedGifs();
|
||||
ctx.drawImage(this.animationHackImg, x, y);
|
||||
};
|
||||
|
||||
|
||||
// The following is a hack that we use to allow animated gifs to show
|
||||
// as animating on the canvas.
|
||||
FileImage.prototype.installHackToSupportAnimatedGifs = function() {
|
||||
if (this.animationHackImg) { return; }
|
||||
this.animationHackImg = this.img.cloneNode(true);
|
||||
document.body.appendChild(this.animationHackImg);
|
||||
this.animationHackImg.width = 0;
|
||||
this.animationHackImg.height = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user