Refactor dom initialize flag

This commit is contained in:
Dávid Szabó 2016-09-23 13:00:10 +02:00 committed by Julian Descottes
parent 5577c3ab5a
commit 0f404d2b25

View File

@ -11,10 +11,10 @@
ns.FramesListController = function (piskelController, container) { ns.FramesListController = function (piskelController, container) {
this.piskelController = piskelController; this.piskelController = piskelController;
this.container = container; this.container = container;
this.domInitialized = false;
this.refreshZoom_(); this.refreshZoom_();
this.redrawFlag = true; this.redrawFlag = true;
this.regenerateDomFlag = true;
this.cachedFrameProcessor = new pskl.model.frame.CachedFrameProcessor(); this.cachedFrameProcessor = new pskl.model.frame.CachedFrameProcessor();
this.cachedFrameProcessor.setFrameProcessor(this.frameToPreviewCanvas_.bind(this)); this.cachedFrameProcessor.setFrameProcessor(this.frameToPreviewCanvas_.bind(this));
@ -35,11 +35,11 @@
this.updateScrollerOverflows(); this.updateScrollerOverflows();
}; };
ns.FramesListController.prototype.flagForRedraw_ = function (reinitializeDom) { ns.FramesListController.prototype.flagForRedraw_ = function (regenerateDom) {
this.redrawFlag = true; this.redrawFlag = true;
if (reinitializeDom) { if (regenerateDom) {
this.domInitialized = false; this.regenerateDomFlag = true;
} }
}; };
@ -49,10 +49,12 @@
ns.FramesListController.prototype.render = function () { ns.FramesListController.prototype.render = function () {
if (this.redrawFlag) { if (this.redrawFlag) {
if (!this.domInitialized) { if (this.regenerateDomFlag) {
this.tiles = []; this.tiles = [];
this.addFrameTile = null; this.addFrameTile = null;
this.createPreviews_(); this.createPreviews_();
this.regenerateDomFlag = false;
} }
this.updatePreviews_(); this.updatePreviews_();
@ -177,7 +179,6 @@
this.addFrameTile = newFrameButton; this.addFrameTile = newFrameButton;
this.updateScrollerOverflows(); this.updateScrollerOverflows();
this.domInitialized = true;
}; };
/** /**