aboutsummaryrefslogtreecommitdiff
path: root/js/stage/stage.reel/stage.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/stage/stage.reel/stage.js')
-rwxr-xr-xjs/stage/stage.reel/stage.js60
1 files changed, 28 insertions, 32 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 69cfa7ba..a3903ac7 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -235,14 +235,6 @@ exports.Stage = Montage.create(Component, {
235 this._context = this._canvas.getContext("2d"); 235 this._context = this._canvas.getContext("2d");
236 this._drawingContext= this._drawingCanvas.getContext("2d"); 236 this._drawingContext= this._drawingCanvas.getContext("2d");
237 237
238 this._scrollLeft = this._iframeContainer.scrollLeft;
239 this._scrollTop = this._iframeContainer.scrollTop;
240 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
241 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
242
243 // TODO: Fix the mouse wheel scroll
244 // this._canvas.addEventListener("mousewheel", this, false);
245
246 // Setup event listeners 238 // Setup event listeners
247 this._drawingCanvas.addEventListener("mousedown", this, false); 239 this._drawingCanvas.addEventListener("mousedown", this, false);
248 this._drawingCanvas.addEventListener("mouseup", this, false); 240 this._drawingCanvas.addEventListener("mouseup", this, false);
@@ -269,30 +261,38 @@ exports.Stage = Montage.create(Component, {
269 // Event details will contain the active document prior to opening a new one 261 // Event details will contain the active document prior to opening a new one
270 handleOpenDocument: { 262 handleOpenDocument: {
271 value: function(evt) { 263 value: function(evt) {
264 var designView = this.application.ninja.currentDocument.model.views.design;
265
272 this.hideCanvas(false); 266 this.hideCanvas(false);
273 267
274 // Recalculate the canvas sizes because of splitter resizing 268 // Recalculate the canvas sizes because of splitter resizing
275 this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; 269 this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ;
276 this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; 270 this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11;
277 271
278
279 this.userContentBorder = 0;
280
281 this._scrollLeft = 0;
282 this._scrollTop = 0;
283 this._userContentLeft = this._documentOffsetLeft;
284 this._userContentTop = this._documentOffsetTop;
285
286 this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; 272 this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11;
287 this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; 273 this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11;
288 this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addEventListener("scroll", this, false); 274 designView.iframe.contentWindow.addEventListener("scroll", this, false);
289
290 // TODO - We will need to modify this once we support switching between multiple documents
291 this.application.ninja.toolsData.selectedToolInstance._configure(true);
292 275
293 this.addPropertyChangeListener("appModel.show3dGrid", this, false); 276 this.addPropertyChangeListener("appModel.show3dGrid", this, false);
294 277
278 this.stageDeps.handleOpenDocument();
295 this.layout.handleOpenDocument(); 279 this.layout.handleOpenDocument();
280
281 if(designView._template) {
282 var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2);
283 var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2);
284 if(initialLeft > this.documentOffsetLeft) {
285 this.userPaddingLeft = -initialLeft;
286 }
287 if(initialTop > this.documentOffsetTop) {
288 this.userPaddingTop = -initialTop;
289 }
290 }
291
292 this.centerStage();
293
294 // TODO - We will need to modify this once we support switching between multiple documents
295 this.application.ninja.toolsData.selectedToolInstance._configure(true);
296 } 296 }
297 }, 297 },
298 298
@@ -485,10 +485,7 @@ exports.Stage = Montage.create(Component, {
485 // Need to clear the snap cache and set up the drag plane 485 // Need to clear the snap cache and set up the drag plane
486 //snapManager.setupDragPlaneFromPlane( workingPlane ); 486 //snapManager.setupDragPlaneFromPlane( workingPlane );
487 this.stageDeps.snapManager._isCacheInvalid = true; 487 this.stageDeps.snapManager._isCacheInvalid = true;
488 488 this.updatedStage = true;
489 this.needsDraw = true;
490 this.layout.draw();
491 //this._toolsList.action("DrawHandles");
492 } 489 }
493 }, 490 },
494 491
@@ -517,16 +514,15 @@ exports.Stage = Montage.create(Component, {
517 */ 514 */
518 centerStage: { 515 centerStage: {
519 value: function() { 516 value: function() {
520 if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { 517 var designView = this.application.ninja.currentDocument.model.views.design;
521 this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this.application.ninja.currentDocument.documentRoot.parentNode.offsetWidth)/2; 518 if(designView._template) {
522 this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this.application.ninja.currentDocument.documentRoot.parentNode.offsetHeight)/2; 519 designView.document.body.scrollLeft = this._documentOffsetLeft - parseInt((this.canvas.width - designView._template.size.width)/2);
523 520 designView.document.body.scrollTop = this._documentOffsetTop - parseInt((this.canvas.height - designView._template.size.height)/2);
524 this._scrollLeft = this._iframeContainer.scrollLeft;
525 this._scrollTop = this._iframeContainer.scrollTop;
526 } else { 521 } else {
527 this._scrollLeft = this._userContentLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = 0; 522 designView.document.body.scrollLeft = this._documentOffsetLeft;
528 this._scrollTop = this._userContentTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = 0; 523 designView.document.body.scrollTop = this._documentOffsetTop;
529 } 524 }
525 this.handleScroll();
530 } 526 }
531 }, 527 },
532 528