From 253b8803c71c88a6f87fb1caccd42fa081fc6eca Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 15 May 2012 14:17:41 -0700 Subject: Fixing scrollbar syncing, including pan tool, for banner templates. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 17 +++++++++++------ js/tools/PanTool.js | 15 +++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index dc6444ff..e66c5b7b 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -464,8 +464,8 @@ exports.Stage = Montage.create(Component, { this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; } else { - this._scrollLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft; - this._scrollTop = this.application.ninja.currentDocument.documentRoot.scrollTop; + this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; + this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; this.userContentLeft = -this._scrollLeft; this.userContentTop = -this._scrollTop; @@ -512,11 +512,16 @@ exports.Stage = Montage.create(Component, { */ centerStage: { value: function() { - this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this._documentRoot.parentNode.offsetWidth)/2; - this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this._documentRoot.parentNode.offsetHeight)/2; + if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { + this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this._documentRoot.parentNode.offsetWidth)/2; + this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this._documentRoot.parentNode.offsetHeight)/2; - this._scrollLeft = this._iframeContainer.scrollLeft; - this._scrollTop = this._iframeContainer.scrollTop; + this._scrollLeft = this._iframeContainer.scrollLeft; + this._scrollTop = this._iframeContainer.scrollTop; + } else { + this._scrollLeft = this._userContentLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = 0; + this._scrollTop = this._userContentTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = 0; + } } }, diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 132ac0b1..5cfeec75 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -148,8 +148,7 @@ exports.PanTool = Montage.create(toolBase, delta = 10*event.wheelDelta/120; //console.log( "delta: " + delta ); - this.application.ninja.currentDocument.documentRoot.scrollLeft += delta; -// this.application.ninja.stage._scrollLeft += delta; + this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft += delta; delta *= zoom; @@ -330,8 +329,8 @@ exports.PanTool = Montage.create(toolBase, var limitX = false; var limitY = false; - var oldLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft, - oldTop = this.application.ninja.currentDocument.documentRoot.scrollTop, + var oldLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft, + oldTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop, newLeft = oldLeft - deltaGPt[0], newTop = oldTop - deltaGPt[1]; if((newLeft < 0) || (newLeft > this._maxHorizontalScroll)) @@ -342,10 +341,10 @@ exports.PanTool = Montage.create(toolBase, { limitY = true; } - this.application.ninja.currentDocument.documentRoot.scrollLeft -= deltaGPt[0]; - this.application.ninja.currentDocument.documentRoot.scrollTop -= deltaGPt[1]; - deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.documentRoot.scrollLeft; - deltaGPt[1] = oldTop - this.application.ninja.currentDocument.documentRoot.scrollTop; + this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft -= deltaGPt[0]; + this.application.ninja.currentDocument.model.views.design.document.body.scrollTop -= deltaGPt[1]; + deltaGPt[0] = oldLeft - this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; + deltaGPt[1] = oldTop - this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; gPt[0] -= deltaGPt[0]; gPt[1] -= deltaGPt[1]; -- cgit v1.2.3