aboutsummaryrefslogtreecommitdiff
path: root/js/tools/PanTool.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-02 12:24:33 -0800
committerPushkar Joshi2012-03-02 12:24:33 -0800
commit4419209a1fd850ab468209b562b66b0242b42a9c (patch)
treebd7ca04f963f5a3aeb4b3c06db6f187903307d45 /js/tools/PanTool.js
parent1b68bb87c458877cb850a96d8a093d6064bc41dc (diff)
parentff0a956f33df034e9a009cfcb8999e469456a4b5 (diff)
downloadninja-4419209a1fd850ab468209b562b66b0242b42a9c.tar.gz
Merge branch 'master' into brushtool
Diffstat (limited to 'js/tools/PanTool.js')
-rwxr-xr-xjs/tools/PanTool.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js
index 71301d46..0537a27b 100755
--- a/js/tools/PanTool.js
+++ b/js/tools/PanTool.js
@@ -81,6 +81,14 @@ exports.PanTool = Montage.create(toolBase,
81 { 81 {
82 this._altKeyDown = true; 82 this._altKeyDown = true;
83 } 83 }
84 else if (event.shiftKey)
85 {
86 if (!this._shiftKeyDown)
87 {
88 this._shiftKeyDown = true;
89 this._shiftPt = this._lastGPt.slice();
90 }
91 }
84 } 92 }
85 }, 93 },
86 94
@@ -90,6 +98,10 @@ exports.PanTool = Montage.create(toolBase,
90 { 98 {
91 this._altKeyDown = false; 99 this._altKeyDown = false;
92 } 100 }
101 else if (event.keyCode === Keyboard.SHIFT)
102 {
103 this._shiftKeyDown = false;
104 }
93 } 105 }
94 }, 106 },
95 107
@@ -221,6 +233,7 @@ exports.PanTool = Montage.create(toolBase,
221 var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); 233 var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat );
222 234
223 this._lastGPt = this._globalPt.slice(); 235 this._lastGPt = this._globalPt.slice();
236 this._shiftPt = this._lastGPt.slice();
224 this._lastY = this._lastGPt[1]; 237 this._lastY = this._lastGPt[1];
225 238
226 // set up the matrices we will be needing 239 // set up the matrices we will be needing
@@ -285,6 +298,16 @@ exports.PanTool = Montage.create(toolBase,
285 this._globalPt[2] += dy; 298 this._globalPt[2] += dy;
286 gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; 299 gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]];
287 } 300 }
301 else if (this._shiftKeyDown)
302 {
303 var dx = Math.abs( this._shiftPt[0] - gPt[0] ),
304 dy = Math.abs( this._shiftPt[1] - gPt[1] );
305
306 if (dx >= dy)
307 gPt[1] = this._shiftPt[1];
308 else
309 gPt[0] = this._shiftPt[0];
310 }
288 311
289 // update the scrollbars 312 // update the scrollbars
290 var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); 313 var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt);