From 99d50a7dc1403d1d918a8e4a6f7876c559d5e3a9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 21 Jun 2012 17:34:37 -0700 Subject: Reclaim negative padding when moving items back into positive direction. Note that we only do this on elementChange and not elementChanging since it is a potentially slow routine. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 42 +++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 8ddd0d52..42b759b5 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -73,6 +73,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // Properties that require element planes to be updated _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, + _recalculateScrollOffsets : { value: false }, /////////////////////////////////////////////////////////////////////// // Property accessors @@ -117,7 +118,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { }, initializeFromDocument:{ - value:function(adjustScrollOffsets){ + value:function(adjustScrollOffsets, useStageValues){ var i, documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true), stage = this.application.ninja.stage, @@ -141,6 +142,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { t, plane, elt; + if(useStageValues) { + initL = stage.userPaddingLeft; + initT = stage.userPaddingTop; + this._recalculateScrollOffsets = false; + } for(i=0; i minLeft)) { + this._recalculateScrollOffsets = true; } + if(t < minTop) { minTop = t; + stage.minTopElement = elt; + } else if((elt === stage.minTopElement) && (t > minTop)) { + this._recalculateScrollOffsets = true; } } } } if(adjustStagePadding) { - if(minLeft !== stage.userPaddingLeft) { - stage.userPaddingLeft = minLeft; - changed = true; - } - if(minTop !== stage.userPaddingTop) { - stage.userPaddingTop = minTop; + if(this._recalculateScrollOffsets && !isChanging) { + this.initializeFromDocument(true, true); changed = true; + } else { + if(minLeft !== stage.userPaddingLeft) { + stage.userPaddingLeft = minLeft; + changed = true; + } + if(minTop !== stage.userPaddingTop) { + stage.userPaddingTop = minTop; + changed = true; + } } } -- cgit v1.2.3