aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ZoomTool.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-03 12:20:10 -0800
committerValerio Virgillito2012-02-03 12:20:10 -0800
commite6e539f345f5e1ac36a595db5d1a1c3700715e88 (patch)
tree39846bf1570f9b5a4057b726c54905de9e9e1c02 /js/tools/ZoomTool.js
parent7950424cf704bb221971f4645406b01e6979db18 (diff)
parentc630ead20487c3948fa36448d3e7d5f7b5cba782 (diff)
downloadninja-e6e539f345f5e1ac36a595db5d1a1c3700715e88.tar.gz
Merge branch 'master' into components
Conflicts: node_modules/montage/ui/bluemoon/progress.reel/progress.html node_modules/montage/ui/image2.reel/image2.html node_modules/ninja-components/effect/desaturate-effect.js node_modules/ninja-components/effect/effect.js node_modules/ninja-components/effect/invert-effect.js node_modules/ninja-components/effect/kaliedoscope-effect.js node_modules/ninja-components/effect/multiply-effect.js node_modules/ninja-components/effect/sepia-effect.js node_modules/ninja-components/flow-controller.reel/flow-controller.html node_modules/ninja-components/flow-controller.reel/flow-controller.js node_modules/ninja-components/flow-offset.js node_modules/ninja-components/hottext.reel/hottext.css node_modules/ninja-components/hottext.reel/hottext.html node_modules/ninja-components/hottext.reel/hottext.js node_modules/ninja-components/hottextunit.reel/hottextunit.css node_modules/ninja-components/hottextunit.reel/hottextunit.html node_modules/ninja-components/hottextunit.reel/hottextunit.js node_modules/ninja-components/image2.reel/image2.html node_modules/ninja-components/image2.reel/image2.js node_modules/ninja-components/image3d.reel/image3d.html node_modules/ninja-components/image3d.reel/image3d.js node_modules/ninja-components/photo-editor.reel/photo-editor.css node_modules/ninja-components/photo-editor.reel/photo-editor.html node_modules/ninja-components/photo-editor.reel/photo-editor.js node_modules/ninja-components/slider-base.js user-document-templates/montage-application-cloud/appdelegate.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
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 {