From 4f46850b376b2d428a3d9415b1dc69b36b875a2c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 13:06:34 -0700 Subject: Automatically add scrollbars when moving content to negative space. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 125155d8..05376527 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -187,6 +187,33 @@ exports.Stage = Montage.create(Component, { enumerable : false }, + _userPaddingLeft: { value: 0 }, + _userPaddingTop: { value: 0 }, + + userPaddingLeft: { + get: function() { return this._userPaddingLeft; }, + set: function(value) { + this._userPaddingLeft = value; + this._documentOffsetLeft = -value; + this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], + "padding-left", -value + "px", true); + this.userContentLeft = this._documentOffsetLeft; + this.updatedStage = true; + } + }, + + userPaddingTop: { + get: function() { return this._userPaddingTop; }, + set: function(value) { + this._userPaddingTop = value; + this._documentOffsetTop = -value; + this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], + "padding-top", -value + "px", true); + this.userContentTop = this._documentOffsetTop; + this.updatedStage = true; + } + }, + willDraw: { value: function() { if(this.resizeCanvases) { @@ -490,8 +517,8 @@ exports.Stage = Montage.create(Component, { 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; + this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; + this.userContentTop = this._documentOffsetTop - this._scrollTop; // TODO - scroll events are not dependable. We may need to use a timer to simulate // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values -- cgit v1.2.3 From 96c92ab93bdb6eb2dd42ef275b84d83aef8254bf Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 14:36:47 -0700 Subject: Fixing selection bugs in new templates. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 05376527..854b5a2d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -609,7 +609,7 @@ exports.Stage = Montage.create(Component, { var point, element, docView = this.application.ninja.currentDocument.model.views.design; - point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset, position.pageY - docView.iframe.contentWindow.pageYOffset)); + point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop)); element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); if(!element) debugger; -- cgit v1.2.3 From 727ad95f6828821f0682aa98104783e4bbda78b4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 15:56:54 -0700 Subject: Inline style for html's padding for content in negative space to guarantee highest specificity. Also, set up scrollbars when opening files with content in negative space. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 854b5a2d..28356d1a 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -195,8 +195,10 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingLeft = value; this._documentOffsetLeft = -value; - this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], - "padding-left", -value + "px", true); + if(!this._documentRoot) { + this._documentRoot = this.application.ninja.currentDocument.documentRoot; + } + this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; this.userContentLeft = this._documentOffsetLeft; this.updatedStage = true; } @@ -207,8 +209,10 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingTop = value; this._documentOffsetTop = -value; - this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], - "padding-top", -value + "px", true); + if(!this._documentRoot) { + this._documentRoot = this.application.ninja.currentDocument.documentRoot; + } + this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; this.userContentTop = this._documentOffsetTop; this.updatedStage = true; } @@ -314,8 +318,8 @@ exports.Stage = Montage.create(Component, { this._scrollLeft = 0; this._scrollTop = 0; - this._userContentLeft = 0; - this._userContentTop = 0; + this._userContentLeft = this._documentOffsetLeft; + this._userContentTop = this._documentOffsetTop; this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; -- cgit v1.2.3