aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/snap-manager.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D/snap-manager.js')
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js33
1 files changed, 9 insertions, 24 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 97901d50..069c6022 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -21,7 +21,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
21 /////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////
22 // Instance variables 22 // Instance variables
23 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
24 currentStage: { value: null, writable: true },
25 drawingCanvas: { value: null, writable: true}, 24 drawingCanvas: { value: null, writable: true},
26 25
27 // we keep a stack of working planes to facilitate working on other planes temporarily 26 // we keep a stack of working planes to facilitate working on other planes temporarily
@@ -84,14 +83,14 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
84 popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, 83 popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }},
85 84
86 getStageWidth : { value: function () { 85 getStageWidth : { value: function () {
87 return parseInt(this.currentStage.offsetWidth); 86 return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetWidth);
88 }}, 87 }},
89 88
90 getStageHeight : { value: function () { 89 getStageHeight : { value: function () {
91 return parseInt(this.currentStage.offsetHeight); 90 return parseInt(this.application.ninja.currentDocument.model.documentRoot.offsetHeight);
92 }}, 91 }},
93 92
94 getStage : { value: function() { return this.currentStage; }}, 93 getStage : { value: function() { return this.application.ninja.currentDocument.model.documentRoot; }},
95 94
96 getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, 95 getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }},
97 getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, 96 getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }},
@@ -130,10 +129,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
130 129
131 bindSnap: { 130 bindSnap: {
132 value: function() { 131 value: function() {
133 this.addEventListener("change@appModel.snap", this.toggleSnap, false); 132 this.addPropertyChangeListener("appModel.snap", this.toggleSnap, false);
134 this.addEventListener("change@appModel.snapGrid", this.toggleSnapGrid, false); 133 this.addPropertyChangeListener("appModel.snapGrid", this.toggleSnapGrid, false);
135 this.addEventListener("change@appModel.snapObjects", this.toggleSnapObjects, false); 134 this.addPropertyChangeListener("appModel.snapObjects", this.toggleSnapObjects, false);
136 this.addEventListener("change@appModel.snapAlign", this.toggleSnapAlign, false); 135 this.addPropertyChangeListener("appModel.snapAlign", this.toggleSnapAlign, false);
137 } 136 }
138 }, 137 },
139 138
@@ -185,12 +184,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
185 } 184 }
186 }, 185 },
187 186
188 setCurrentStage: {
189 value: function(stage) {
190 this.currentStage = stage;
191 }
192 },
193
194 snap : { 187 snap : {
195 value: function (xScreen, yScreen, snap3D, quadPt) 188 value: function (xScreen, yScreen, snap3D, quadPt)
196 { 189 {
@@ -1631,11 +1624,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1631 if (x > y) { 1624 if (x > y) {
1632 if (x > z) { 1625 if (x > z) {
1633 plane[0] = 1; 1626 plane[0] = 1;
1634 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { 1627 plane[3] = this.getStageWidth() / 2.0;
1635 plane[3] = stage.scrollWidth / 2.0;
1636 } else {
1637 plane[3] = this.getStageWidth() / 2.0;
1638 }
1639 if (dir[0] > 0) plane[3] = -plane[3]; 1628 if (dir[0] > 0) plane[3] = -plane[3];
1640 change = !drawUtils.drawYZ; 1629 change = !drawUtils.drawYZ;
1641 drawUtils.drawXY = drawUtils.drawXZ = false; 1630 drawUtils.drawXY = drawUtils.drawXZ = false;
@@ -1653,11 +1642,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1653 else { 1642 else {
1654 if (y > z) { 1643 if (y > z) {
1655 plane[1] = 1; 1644 plane[1] = 1;
1656 if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { 1645 plane[3] = this.getStageHeight() / 2.0;
1657 plane[3] = stage.scrollHeight / 2.0;
1658 } else {
1659 plane[3] = this.getStageHeight() / 2.0;
1660 }
1661 if (dir[1] > 0) plane[3] = -plane[3]; 1646 if (dir[1] > 0) plane[3] = -plane[3];
1662 change = !drawUtils.drawXZ; 1647 change = !drawUtils.drawXZ;
1663 drawUtils.drawXY = drawUtils.drawYZ = false; 1648 drawUtils.drawXY = drawUtils.drawYZ = false;