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 +++++++++++++++++++++++++++++--------- js/stage/stage.reel/stage.js | 4 ++++ 2 files changed, 36 insertions(+), 10 deletions(-) (limited to 'js') 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; + } } } diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index fce73882..3552935d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -279,6 +279,10 @@ exports.Stage = Montage.create(Component, { _userPaddingLeft: { value: 0 }, _userPaddingTop: { value: 0 }, + // keep track of the elements that determine the minimum left and top scrollable amount + minLeftElement: { value: null }, + minTopElement: { value: null }, + userPaddingLeft: { get: function() { return this._userPaddingLeft; }, set: function(value) { -- cgit v1.2.3 From 3b5e824faf4b7fa685498b45477cb85e9eec31a1 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 25 Jun 2012 09:47:11 -0700 Subject: When reclaiming stage's negative scroll padding, we need to use the template's left and top padding as the minimum values when switching between documents. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 2 ++ js/stage/stage.reel/stage.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 42b759b5..5d210d41 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -145,6 +145,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { if(useStageValues) { initL = stage.userPaddingLeft; initT = stage.userPaddingTop; + minLeft = stage.templateLeft; + minTop = stage.templateTop; this._recalculateScrollOffsets = false; } for(i=0; i this.documentOffsetLeft) { this.userPaddingLeft = -initialLeft; + this.templateLeft = -initialLeft; } if(initialTop > this.documentOffsetTop) { this.userPaddingTop = -initialTop; + this.templateTop = -initialTop; } } -- cgit v1.2.3