From d105a574ba527271cf1f8ae90b2ddaaf342fb5a4 Mon Sep 17 00:00:00 2001 From: Yaroslav Sivakov Date: Sat, 27 Dec 2014 01:35:57 +0300 Subject: [PATCH] Update DisplayObject.js Fix: case setBounds(null) (don't do "this._bounds = new createjs.Rectangle" after "this._bounds = null"). Maybe we need also always create new rectangle, not using old _bounds (or always return cloned rectangle from getBounds())? In my project I got several bugs related to next code: var boundsToUseLater = myObj.getBounds(); // save current bounds // some code (change myObj then call getBounds()) // use boundsToUseLater - properties x/y/widht/height not the same as they were the save moment --- src/easeljs/display/DisplayObject.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/easeljs/display/DisplayObject.js b/src/easeljs/display/DisplayObject.js index 3ce9e90c3..c156ac224 100644 --- a/src/easeljs/display/DisplayObject.js +++ b/src/easeljs/display/DisplayObject.js @@ -1163,8 +1163,8 @@ this.createjs = this.createjs||{}; * @param {Number} height The height of the bounds. **/ p.setBounds = function(x, y, width, height) { - if (x == null) { this._bounds = x; } - this._bounds = (this._bounds || new createjs.Rectangle()).setValues(x, y, width, height); + if (x == null) { this._bounds = null; } + else { this._bounds = (this._bounds || new createjs.Rectangle()).setValues(x, y, width, height); } }; /**