diff --git a/src/js/controller/FramesListController.js b/src/js/controller/FramesListController.js index 14706d38..a65c4aba 100644 --- a/src/js/controller/FramesListController.js +++ b/src/js/controller/FramesListController.js @@ -1,6 +1,8 @@ (function () { var ns = $.namespace('pskl.controller'); + var RENDER_MINIMUM_DELAY = 1000; + var ACTION = { SELECT : 'select', CLONE : 'clone', @@ -13,6 +15,7 @@ this.container = container; this.refreshZoom_(); + this.lastRenderTime = 0; this.redrawFlag = true; this.cachedFrameProcessor = new pskl.model.frame.CachedFrameProcessor(); @@ -41,9 +44,10 @@ }; ns.FramesListController.prototype.render = function () { - if (this.redrawFlag) { + if (this.redrawFlag && (Date.now() - this.lastRenderTime > RENDER_MINIMUM_DELAY)) { this.createPreviews_(); this.redrawFlag = false; + this.lastRenderTime = Date.now(); } }; diff --git a/src/js/controller/preview/PreviewController.js b/src/js/controller/preview/PreviewController.js index f8cf79b4..63ef3ba2 100644 --- a/src/js/controller/preview/PreviewController.js +++ b/src/js/controller/preview/PreviewController.js @@ -3,6 +3,7 @@ // Preview is a square of PREVIEW_SIZE x PREVIEW_SIZE var PREVIEW_SIZE = 200; + var RENDER_MINIMUM_DELAY = 1000; var ONION_SKIN_SHORTCUT = 'alt+O'; var ORIGINAL_SIZE_SHORTCUT = 'alt+1'; @@ -17,6 +18,7 @@ this.onionSkinShortcut = pskl.service.keyboard.Shortcuts.MISC.ONION_SKIN; this.originalSizeShortcut = pskl.service.keyboard.Shortcuts.MISC.X1_PREVIEW; + this.lastRenderTime = 0; this.renderFlag = true; /** @@ -173,6 +175,7 @@ var frame = pskl.utils.LayerUtils.mergeFrameAt(this.piskelController.getLayers(), index); this.renderer.render(frame); this.renderFlag = false; + this.lastRenderTime = Date.now(); this.popupPreviewController.render(frame); } @@ -241,7 +244,7 @@ }; ns.PreviewController.prototype.shouldRender_ = function () { - return this.renderFlag || this.popupPreviewController.renderFlag; + return (this.renderFlag || this.popupPreviewController.renderFlag) && (Date.now() - this.lastRenderTime > RENDER_MINIMUM_DELAY); }; ns.PreviewController.prototype.toggleOnionSkin_ = function () {