aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ZoomTool.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-02 18:04:37 -0800
committerJose Antonio Marquez2012-02-02 18:04:37 -0800
commit7959d2ecc6e8b1799307de1ceab1112b8ab58e8d (patch)
treece4e32578e1af4d49b8375933a6b7edd0a095b0f /js/tools/ZoomTool.js
parent83ac41dd75ec551cdb03252e0bf3081182517d05 (diff)
parentc630ead20487c3948fa36448d3e7d5f7b5cba782 (diff)
downloadninja-7959d2ecc6e8b1799307de1ceab1112b8ab58e8d.tar.gz
Merge branch 'refs/heads/NinjaInternal' into Color
Conflicts: js/controllers/elements/shapes-controller.js js/data/pi/pi-data.js js/panels/properties/content.reel/content.js
Diffstat (limited to 'js/tools/ZoomTool.js')
-rw-r--r--js/tools/ZoomTool.js39
1 files changed, 10 insertions, 29 deletions
diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js
index cabf3a3d..4b6705c1 100644
--- a/js/tools/ZoomTool.js
+++ b/js/tools/ZoomTool.js
@@ -74,10 +74,12 @@ exports.ZoomTool = Montage.create(DrawingTool, {
74 if(wasSelected) { 74 if(wasSelected) {
75 this.AddCustomFeedback(); 75 this.AddCustomFeedback();
76 this.eventManager.addEventListener( "toolDoubleClick", this, false); 76 this.eventManager.addEventListener( "toolDoubleClick", this, false);
77 this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false);
77 78
78 } else { 79 } else {
79 this.RemoveCustomFeedback(); 80 this.RemoveCustomFeedback();
80 this.eventManager.removeEventListener( "toolDoubleClick", this, false); 81 this.eventManager.removeEventListener( "toolDoubleClick", this, false);
82 this.application.ninja.stage.drawingCanvas.removeEventListener("mousewheel", this, false);
81 } 83 }
82 } 84 }
83 }, 85 },
@@ -138,9 +140,11 @@ exports.ZoomTool = Montage.create(DrawingTool, {
138 { 140 {
139 value : function (event) 141 value : function (event)
140 { 142 {
141 // check for some reasonable amount of mouse movement 143 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
142 var dx = Math.abs(event.layerX - this.downPoint.x), 144 new WebKitPoint(event.pageX, event.pageY));
143 dy = Math.abs(event.layerY - this.downPoint.y); 145 // check for some reasonable amount of mouse movement
146 var dx = Math.abs(point.x - this.downPoint.x),
147 dy = Math.abs(point.y - this.downPoint.y);
144 148
145 if ((dx >= 4) || (dy >= 4)) 149 if ((dx >= 4) || (dy >= 4))
146 { 150 {
@@ -238,19 +242,6 @@ exports.ZoomTool = Montage.create(DrawingTool, {
238 var p1 = [this._layerX, this._layerY, 0]; 242 var p1 = [this._layerX, this._layerY, 0];
239 globalPt = vecUtils.vecAdd(3, p0, p1); 243 globalPt = vecUtils.vecAdd(3, p0, p1);
240 vecUtils.vecScale(3, globalPt, 0.5); 244 vecUtils.vecScale(3, globalPt, 0.5);
241
242 var hitRec = snapManager.snap( globalPt[0], globalPt[1], true );
243 if (hitRec)
244 {
245 var elt = hitRec.getElement();
246 if (elt)
247 {
248// console.log( "hit: " + hitRec.getElement().id );
249 var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt );
250 var localPt = hitRec.calculateElementPreTransformScreenPoint();
251 globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat );
252 }
253 }
254 } 245 }
255 else if (this._mode === "doubleClickReset") 246 else if (this._mode === "doubleClickReset")
256 { 247 {
@@ -270,19 +261,9 @@ exports.ZoomTool = Montage.create(DrawingTool, {
270 } 261 }
271 else if (this._mode === "mouseWheelZoom") 262 else if (this._mode === "mouseWheelZoom")
272 { 263 {
273 if (userContent) 264 var w = this.application.ninja.stage._canvas.width,
274 { 265 h = this.application.ninja.stage._canvas.height;
275 var w = userContent.offsetWidth, 266 globalPt = [w/2, h/2, 0];
276 h = userContent.offsetHeight;
277 if(userContent.width)
278 w = userContent.width;
279 if(userContent.height)
280 h = userContent.height;
281 var localPt = [ w/2, h/2, 0];
282 globalPt = viewUtils.localToGlobal( localPt, userContent );
283 }
284 else
285 globalPt = [0,0,0];
286 } 267 }
287 else 268 else
288 { 269 {