From e80a79bff57fecf3aa9b869d8ed2de5fd815287c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 14 Feb 2012 14:37:42 -0800 Subject: Fix for not being able to select an element in Top/Side view. Fall back to use SnapManager code if elementFromPoint returns the viewport. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 6d9a7355..9cf97e09 100644 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -510,12 +510,37 @@ exports.Stage = Montage.create(Component, { */ GetElement: { value: function(pos) { - var point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(pos.pageX, pos.pageY)); - return this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop); + var point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(pos.pageX, pos.pageY)), + elt = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop); + + // workaround Chrome 3d bug + if(elt === this._viewport) + { + return this._getElementUsingSnapping(point); + } else { + return elt; + } } }, - + /** + * _getElementUsingSnapping: Returns the object at point using snap manager + * + * @param: point + * @return: Returns the Object in the user document under the point + */ + _getElementUsingSnapping: { + value: function(point) { + this.stageDeps.snapManager.enableElementSnap( true ); + var hitRec = this.stageDeps.snapManager.snap(point.x, point.y, true); + this.stageDeps.snapManager.enableElementSnap( this.stageDeps.snapManager.elementSnapEnabledAppLevel() ); + if (hitRec) { + return hitRec.getElement(); + } else { + return null; + } + } + }, draw: { -- cgit v1.2.3