From 9c7f7c69495175a4a5a093aeb78f078d0cb7835d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 16 Mar 2012 17:14:54 -0700 Subject: Fixed snap-manager to stop snapping after first level children. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/snap-manager.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 1caacd00..a755e9e2 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -471,7 +471,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { value: function( plane ) { this._elementCache = new Array; - var stage = this.getStage(); +// var stage = this.getStage(); + var stage = this.application.ninja.currentSelectedContainer || this.getStage(); this.hLoadElementCache( stage, plane, 0 ); this._isCacheInvalid = false; @@ -570,6 +571,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hLoadElementCache : { value: function( elt, plane, depth ) { + if(depth > 1) + { + return; + } + if (depth > 0) { // check if the element is on the specified plane @@ -590,8 +596,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { elt.elementModel.isIn2DSnapCache = false; } - // TODO - Don't traverse components' children -// if(elt.elementModel && elt.elementModel.isComponent) + // TODO - Don't traverse svg and components' children if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) { return; @@ -964,7 +969,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { snapToElements : { value: function( screenPt, hitRecs ) { // start at the stage. - var stage = this.getStage(); +// var stage = this.getStage(); + var stage = this.application.ninja.currentSelectedContainer || this.getStage(); // the root should be the 'view' canvas, so the first matrix is the camera viewUtils.setViewportObj( stage ); @@ -980,6 +986,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { { value: function( elt, hitRecs, depth, globalScrPt ) { + if(depth > 1) + { + return; + } // hit test the current object var hit; if (depth > 0) // don't snap to the root @@ -1001,8 +1011,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { } } - // TODO - Don't traverse components' children -// if(elt.elementModel && elt.elementModel.isComponent) + // TODO - Don't traverse svg and components' children if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) { return; -- cgit v1.2.3