diff options
author | Jose Antonio Marquez | 2012-05-01 10:13:35 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-01 10:13:35 -0700 |
commit | 7812925f6864a6f3a01e4a76924dc5c71706ff37 (patch) | |
tree | cc4be068b5de74fb8b1ff28fd6b556fe2c115e97 /js/stage | |
parent | 7bdcab084d1991361ba8d37a7435efd229648630 (diff) | |
parent | fb47c04b0a4d65f53d975311754aa0dd8a8a3f69 (diff) | |
download | ninja-7812925f6864a6f3a01e4a76924dc5c71706ff37.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/stage')
-rwxr-xr-x | js/stage/layout.js | 2 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 73 |
2 files changed, 45 insertions, 30 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js index a096848e..0a76dbe5 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js | |||
@@ -174,7 +174,7 @@ exports.Layout = Montage.create(Component, { | |||
174 | var tmpMat = viewUtils.getLocalToGlobalMatrix( item ); | 174 | var tmpMat = viewUtils.getLocalToGlobalMatrix( item ); |
175 | 175 | ||
176 | var zoomFactor = 1; | 176 | var zoomFactor = 1; |
177 | if (this.stage._viewport.style && this.stage._viewport.style.zoom) { | 177 | if (this.stage._viewport && this.stage._viewport.style && this.stage._viewport.style.zoom) { |
178 | zoomFactor = Number(this.stage._viewport.style.zoom); | 178 | zoomFactor = Number(this.stage._viewport.style.zoom); |
179 | } | 179 | } |
180 | 180 | ||
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 1ea14d64..515165bf 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -231,33 +231,43 @@ exports.Stage = Montage.create(Component, { | |||
231 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; | 231 | this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; |
232 | 232 | ||
233 | this._documentRoot = this.application.ninja.currentDocument.documentRoot; | 233 | this._documentRoot = this.application.ninja.currentDocument.documentRoot; |
234 | this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode; | ||
235 | |||
236 | this.documentOffsetLeft = this._viewport.offsetLeft; | ||
237 | this.documentOffsetTop = this._viewport.offsetTop; | ||
238 | |||
239 | // Center the stage | ||
240 | this.centerStage(); | ||
241 | |||
242 | this._scrollLeft = this._iframeContainer.scrollLeft; | ||
243 | this._scrollTop = this._iframeContainer.scrollTop; | ||
244 | this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft; | ||
245 | this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop; | ||
246 | 234 | ||
247 | // Hardcode this value so that it does not fail for the new stage architecture | 235 | // Hardcode this value so that it does not fail for the new stage architecture |
248 | // TODO: Remove marker for old template: NINJA-STAGE-REWORK | 236 | // TODO: Remove marker for old template: NINJA-STAGE-REWORK |
249 | if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { | 237 | if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { |
250 | this.userContentBorder = 1; //parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); | 238 | this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode; |
239 | |||
240 | this.documentOffsetLeft = this._viewport.offsetLeft; | ||
241 | this.documentOffsetTop = this._viewport.offsetTop; | ||
242 | |||
243 | // Center the stage | ||
244 | this.centerStage(); | ||
245 | |||
246 | this._scrollLeft = this._iframeContainer.scrollLeft; | ||
247 | this._scrollTop = this._iframeContainer.scrollTop; | ||
248 | this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft; | ||
249 | this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop; | ||
250 | |||
251 | this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); | ||
252 | |||
253 | this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; | ||
254 | this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; | ||
255 | |||
256 | this._iframeContainer.addEventListener("scroll", this, false); | ||
257 | |||
258 | this.application.ninja.currentDocument.iframe.style.opacity = 1.0; | ||
251 | } else { | 259 | } else { |
252 | this.userContentBorder = 0; | 260 | this.userContentBorder = 0; |
253 | } | ||
254 | 261 | ||
255 | this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; | 262 | this._scrollLeft = 0; |
256 | this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; | 263 | this._scrollTop = 0; |
264 | this._userContentLeft = 0; | ||
265 | this._userContentTop = 0; | ||
266 | |||
267 | this.application.ninja.currentDocument._window.addEventListener("scroll", this, false); | ||
268 | } | ||
257 | 269 | ||
258 | this.application.ninja.currentDocument.iframe.style.opacity = 1.0; | ||
259 | 270 | ||
260 | this._iframeContainer.addEventListener("scroll", this, false); | ||
261 | 271 | ||
262 | // TODO - We will need to modify this once we support switching between multiple documents | 272 | // TODO - We will need to modify this once we support switching between multiple documents |
263 | this.application.ninja.toolsData.selectedToolInstance._configure(true); | 273 | this.application.ninja.toolsData.selectedToolInstance._configure(true); |
@@ -415,13 +425,10 @@ exports.Stage = Montage.create(Component, { | |||
415 | handleSelectionChange: { | 425 | handleSelectionChange: { |
416 | value: function(event) { | 426 | value: function(event) { |
417 | // TODO - this is a hack for now because some tools depend on selectionDrawn event for some logic | 427 | // TODO - this is a hack for now because some tools depend on selectionDrawn event for some logic |
418 | if(this.drawNow) | 428 | if(this.drawNow) { |
419 | { | ||
420 | this.draw(); | 429 | this.draw(); |
421 | this.drawNow = false; | 430 | this.drawNow = false; |
422 | } | 431 | } else { |
423 | else | ||
424 | { | ||
425 | this.needsDraw = true; | 432 | this.needsDraw = true; |
426 | } | 433 | } |
427 | } | 434 | } |
@@ -444,11 +451,20 @@ exports.Stage = Montage.create(Component, { | |||
444 | */ | 451 | */ |
445 | handleScroll: { | 452 | handleScroll: { |
446 | value: function() { | 453 | value: function() { |
447 | this._scrollLeft = this._iframeContainer.scrollLeft; | 454 | // TODO: Remove marker for old template: NINJA-STAGE-REWORK |
448 | this._scrollTop = this._iframeContainer.scrollTop; | 455 | if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { |
456 | this._scrollLeft = this._iframeContainer.scrollLeft; | ||
457 | this._scrollTop = this._iframeContainer.scrollTop; | ||
449 | 458 | ||
450 | this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; | 459 | this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; |
451 | this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; | 460 | this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; |
461 | } else { | ||
462 | this._scrollLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft; | ||
463 | this._scrollTop = this.application.ninja.currentDocument.documentRoot.scrollTop; | ||
464 | |||
465 | this.userContentLeft = -this._scrollLeft; | ||
466 | this.userContentTop = -this._scrollTop; | ||
467 | } | ||
452 | 468 | ||
453 | // Need to clear the snap cache and set up the drag plane | 469 | // Need to clear the snap cache and set up the drag plane |
454 | //snapManager.setupDragPlaneFromPlane( workingPlane ); | 470 | //snapManager.setupDragPlaneFromPlane( workingPlane ); |
@@ -457,7 +473,6 @@ exports.Stage = Montage.create(Component, { | |||
457 | this.needsDraw = true; | 473 | this.needsDraw = true; |
458 | this.layout.draw(); | 474 | this.layout.draw(); |
459 | //this._toolsList.action("DrawHandles"); | 475 | //this._toolsList.action("DrawHandles"); |
460 | |||
461 | } | 476 | } |
462 | }, | 477 | }, |
463 | 478 | ||
@@ -687,7 +702,7 @@ exports.Stage = Montage.create(Component, { | |||
687 | // } | 702 | // } |
688 | 703 | ||
689 | var zoomFactor = 1; | 704 | var zoomFactor = 1; |
690 | if (this._viewport.style && this._viewport.style.zoom) { | 705 | if (this._viewport && this._viewport.style && this._viewport.style.zoom) { |
691 | zoomFactor = Number(this._viewport.style.zoom); | 706 | zoomFactor = Number(this._viewport.style.zoom); |
692 | } | 707 | } |
693 | 708 | ||