From 8174405924fde12488b73dbf58a70ceef4f57665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 12 Apr 2015 15:23:24 +0200 Subject: [PATCH] Include force parameter in View#update() Closes #675. --- src/view/CanvasView.js | 12 ++++++++---- src/view/View.js | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/view/CanvasView.js b/src/view/CanvasView.js index eb184aef..4874b804 100644 --- a/src/view/CanvasView.js +++ b/src/view/CanvasView.js @@ -109,13 +109,17 @@ var CanvasView = View.extend(/** @lends CanvasView# */{ }, /** - * Updates the view if there are changes. + * Updates the view if there are changes. Note that when using built-in + * event hanlders for interaction, animation and load events, this method is + * invoked for you automatically at the end. * - * @function + * @param {Boolean} [force=false] {@true if the view should be updated even + * if no change has happened} + * @return {Boolean} {@true if the view was updated} */ - update: function() { + update: function(force) { var project = this._project; - if (!project || !project._needsUpdate) + if (!project || !force && !project._needsUpdate) return false; // Initial tests conclude that clearing the canvas using clearRect // is always faster than setting canvas.width = canvas.width diff --git a/src/view/View.js b/src/view/View.js index c6c3f8f4..3f955749 100644 --- a/src/view/View.js +++ b/src/view/View.js @@ -457,8 +457,11 @@ var View = Base.extend(Emitter, /** @lends View# */{ * * @name View#update * @function + * @param {Boolean} [force=false] {@true if the view should be updated even + * if no change has happened} + * @return {Boolean} {@true if the view was updated} */ - // update: function() { + // update: function(force) { // }, /**