aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-31 17:13:04 -0700
committerValerio Virgillito2012-05-31 17:13:04 -0700
commit6ae2ff1ce956e518918f65099d052bb42186dc94 (patch)
tree35251bf7babbdd76faf22c74d8ec31b869143594
parent163e977e5819b4bf7029be0562ee7f31045f05c4 (diff)
parent294baf576986adb139406e516d8461070fdfd695 (diff)
downloadninja-6ae2ff1ce956e518918f65099d052bb42186dc94.tar.gz
Merge pull request #5 from mqg734/dom-architecture-pentool
Fixing stage's scroll offsets when switching between documents.
-rwxr-xr-xjs/stage/stage.reel/stage.js37
1 files changed, 16 insertions, 21 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index cd08c55d..087606d0 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -179,6 +179,11 @@ exports.Stage = Montage.create(Component, {
179 this.hideCanvas(false); 179 this.hideCanvas(false);
180 } 180 }
181 181
182 if(this.currentDocument && (this.currentDocument.currentView === "design")) {
183 this.currentDocument.model.scrollLeft = this._scrollLeft;
184 this.currentDocument.model.scrollTop = this._scrollTop;
185 }
186
182 this._currentDocument = value; 187 this._currentDocument = value;
183 188
184 if(!value) { 189 if(!value) {
@@ -193,7 +198,7 @@ exports.Stage = Montage.create(Component, {
193 this.showRulers(); 198 this.showRulers();
194 199
195 this.clearAllCanvas(); 200 this.clearAllCanvas();
196 this.initWithDocument(false); 201 this.initWithDocument();
197 } else { 202 } else {
198 this.showCodeViewBar(true); 203 this.showCodeViewBar(true);
199 this.collapseAllPanels(); 204 this.collapseAllPanels();
@@ -299,8 +304,14 @@ exports.Stage = Montage.create(Component, {
299 }, 304 },
300 305
301 initWithDocument: { 306 initWithDocument: {
302 value: function(didSwitch) { 307 value: function() {
303 var designView = this.application.ninja.currentDocument.model.views.design; 308 var model = this.currentDocument.model,
309 designView = this.currentDocument.model.views.design,
310 didSwitch = false;
311
312 if(model.scrollLeft != null) {
313 didSwitch = true;
314 }
304 315
305 // Recalculate the canvas sizes because of splitter resizing 316 // Recalculate the canvas sizes because of splitter resizing
306 this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this._gridCanvas.width = this.element.offsetWidth - 11 ; 317 this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this._gridCanvas.width = this.element.offsetWidth - 11 ;
@@ -336,8 +347,8 @@ exports.Stage = Montage.create(Component, {
336 } 347 }
337 348
338 if(didSwitch) { 349 if(didSwitch) {
339 this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = this.application.ninja.currentDocument.model.scrollLeft; 350 this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = this.currentDocument.model.scrollLeft;
340 this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = this.application.ninja.currentDocument.model.scrollTop; 351 this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = this.currentDocument.model.scrollTop;
341 this.handleScroll(); 352 this.handleScroll();
342 } else { 353 } else {
343 this.centerStage(); 354 this.centerStage();
@@ -1040,22 +1051,6 @@ exports.Stage = Montage.create(Component, {
1040 } 1051 }
1041 }, 1052 },
1042 1053
1043 saveScroll:{
1044 value: function(){
1045 this.application.ninja.documentController.activeDocument.savedLeftScroll = this._iframeContainer.scrollLeft;
1046 this.application.ninja.documentController.activeDocument.savedTopScroll = this._iframeContainer.scrollTop;
1047 }
1048 },
1049
1050 restoreScroll:{
1051 value: function(){
1052 this._iframeContainer.scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll;
1053 this._scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll;
1054 this._iframeContainer.scrollTop = this.application.ninja.documentController.activeDocument.savedTopScroll;
1055 this._scrollTop = this.application.ninja.documentController.activeDocument.savedTopScroll;
1056 }
1057 },
1058
1059 showRulers:{ 1054 showRulers:{
1060 value:function(){ 1055 value:function(){
1061 this.application.ninja.rulerTop.style.display = "block"; 1056 this.application.ninja.rulerTop.style.display = "block";