diff options
Diffstat (limited to 'js/tools/ZoomTool.js')
-rw-r--r-- | js/tools/ZoomTool.js | 39 |
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 | { |