aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js32
-rwxr-xr-xjs/tools/modifier-tool-base.js7
2 files changed, 38 insertions, 1 deletions
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 372be345..596ba56a 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -40,6 +40,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
40 40
41 // keep a reference to the most recent hitRecord. Used for drawing feedback on the stage 41 // keep a reference to the most recent hitRecord. Used for drawing feedback on the stage
42 _lastHit : { value: null, writable: true }, 42 _lastHit : { value: null, writable: true },
43 _hitRecords : { value: [], writable: true },
43 44
44 // keep a list of objects to avoid snapping to 45 // keep a list of objects to avoid snapping to
45 _avoidList : { value: [], writable: true }, 46 _avoidList : { value: [], writable: true },
@@ -274,6 +275,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
274 } //if (hitRecArray.length == 0) 275 } //if (hitRecArray.length == 0)
275 276
276 var rtnHit; 277 var rtnHit;
278
279 // Save reference to hit records to verify last hit record's element matches browser's elementFromPoint
280 this._hitRecords.length = 0;
281 this._hitRecords = hitRecArray;
282
277 if (hitRecArray.length > 0) 283 if (hitRecArray.length > 0)
278 { 284 {
279 this.sortHitRecords( hitRecArray ); 285 this.sortHitRecords( hitRecArray );
@@ -2246,6 +2252,30 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
2246 drawUtils.setDrawingSurfaceElement(saveContext); 2252 drawUtils.setDrawingSurfaceElement(saveContext);
2247 } 2253 }
2248 } 2254 }
2249 } 2255 },
2256
2257 findHitRecordForElement: {
2258 value: function(elt) {
2259 var rtnHit;
2260
2261 if (!this._hitRecords) return;
2262 var nHits = this._hitRecords.length;
2263
2264 for (var i=0; i<nHits; i++)
2265 {
2266 var hi = this._hitRecords[i];
2267 if(hi.getElement() === elt)
2268 {
2269 rtnHit = hi;
2270 break;
2271 }
2272 }
2273 // catch-all to turn off drag plane snapping
2274 this.deactivateDragPlane();
2275
2276 this.setLastHit( rtnHit );
2277 return rtnHit;
2278 }
2279 }
2250 2280
2251}); 2281});
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 7d946cb0..7892d015 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -133,6 +133,13 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
133 // a snap on the mouse down 133 // a snap on the mouse down
134 var hitRec = snapManager.snap(point.x, point.y, do3DSnap); 134 var hitRec = snapManager.snap(point.x, point.y, do3DSnap);
135 135
136 // TODO - Check that hitRec's element matches element that browser says we clicked on
137 var elt = this.application.ninja.stage.GetElement(event);
138 if(elt !== hitRec.getElement())
139 {
140 hitRec = snapManager.findHitRecordForElement(elt);
141 }
142
136 // we don't want to snap to selected objects during the drag 143 // we don't want to snap to selected objects during the drag
137 var len = this._targets.length; 144 var len = this._targets.length;
138 for(var i=0; i<len; i++) 145 for(var i=0; i<len; i++)