Skip to content

Commit

Permalink
Merge pull request #276 from blacktea1105/master
Browse files Browse the repository at this point in the history
resolve flickering cells
  • Loading branch information
TonyGermaneri committed Jun 19, 2020
2 parents 74c6ff6 + 4221a82 commit 7c6a613
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ define([], function () {
function drawOnAllImagesLoaded() {
var loaded = true;
Object.keys(self.htmlImageCache).forEach(function (html) {
if (!self.htmlImageCache[html].complete) {
if (!self.htmlImageCache[html].img.complete) {
loaded = false;
}
});
Expand All @@ -63,8 +63,8 @@ define([], function () {
x = cell.x + self.canvasOffsetLeft,
y = cell.y + self.canvasOffsetTop;
if (self.htmlImageCache[cacheKey]) {
img = self.htmlImageCache[cacheKey];
if (img.height !== cell.height || img.width !== cell.width) {
img = self.htmlImageCache[cacheKey].img;
if (self.htmlImageCache[cacheKey].height !== cell.height || self.htmlImageCache[cacheKey].width !== cell.width) {
// height and width of the cell has changed, invalidate cache
self.htmlImageCache[cacheKey] = undefined;
} else {
Expand All @@ -77,7 +77,7 @@ define([], function () {
cachedImagesDrawn = false;
}
img = new Image(cell.width, cell.height);
self.htmlImageCache[cacheKey] = img;
self.htmlImageCache[cacheKey] = { img, width: cell.width, height: cell.height };
img.onload = function () {
self.ctx.drawImage(img, x, y);
drawOnAllImagesLoaded();
Expand Down

0 comments on commit 7c6a613

Please sign in to comment.