Permalink
Browse files

Fixes #2276 - drag logic wasn't dealing with an original unassigned

value for top/left properties.
  • Loading branch information...
1 parent 636685c commit 1a49e507751a880ffc3153b9a558d82b95285835 @JonFerraiolo JonFerraiolo committed May 16, 2012
@@ -1,4 +1,5 @@
-define(["dojo/_base/declare",
+define(["dojo/_base/declare",
+ "dojo/dom-geometry",
"davinci/Workbench",
"davinci/workbench/Preferences",
"davinci/ve/tools/_Tool",
@@ -16,6 +17,7 @@ define(["dojo/_base/declare",
"davinci/ve/commands/ResizeCommand",
"davinci/ve/utils/GeomUtils"], function(
declare,
+ domGeom,
Workbench,
Preferences,
tool,
@@ -167,9 +169,18 @@ return declare("davinci.ve.tools.SelectTool", tool, {
}
var marginBoxPageCoords = GeomUtils.getMarginBoxPageCoords(selection[i].domNode);
this._moverStartLocations.push(marginBoxPageCoords);
- var l = parseFloat(userDojo.style(selection[i].domNode, 'left'), 10);
- var t = parseFloat(userDojo.style(selection[i].domNode, 'top'), 10);
- this._moverStartLocationsRel.push({l:l, t:t});
+ var relativeLeft, relativeTop;
+ var offsetParent = selection[i].domNode.offsetParent;
+ if(offsetParent && offsetParent.tagName != 'BODY'){
+ var parentBorderBoxPageCoordinates = GeomUtils.getBorderBoxPageCoords(offsetParent);
+ var parentBorderExtents = domGeom.getBorderExtents(offsetParent);
+ relativeLeft = marginBoxPageCoords.l - (parentBorderBoxPageCoordinates.l + parentBorderExtents.l);
+ relativeTop = marginBoxPageCoords.t - (parentBorderBoxPageCoordinates.t + parentBorderExtents.t);
+ }else{
+ relativeLeft = marginBoxPageCoords.l;
+ relativeTop = marginBoxPageCoords.t;
+ }
+ this._moverStartLocationsRel.push({l:relativeLeft, t:relativeTop});
}
var n = moverWidget.domNode;
var moverWidgetMarginBoxPageCoords = GeomUtils.getMarginBoxPageCoords(n);
@@ -19,7 +19,7 @@ return /** @scope davinci.ve.utils.GeomUtils */ {
getMarginBoxPageCoords: function(node){
var MarginBoxPageCoords;
win.withDoc(node.ownerDocument, function(){
- var BorderBoxPageCoords = this.getBorderBoxPageCoordinates(node);
+ var BorderBoxPageCoords = this.getBorderBoxPageCoords(node);
var MarginExtents = domGeom.getMarginExtents(node);
MarginBoxPageCoords = {
l:BorderBoxPageCoords.l - MarginExtents.l,
@@ -36,7 +36,7 @@ return /** @scope davinci.ve.utils.GeomUtils */ {
* are all based on CSS box model (margins, borders, padding, left/top)
* not the actual screen locations resulting after applying transforms.
*/
- getBorderBoxPageCoordinates: function(/*DomNode*/node){
+ getBorderBoxPageCoords: function(/*DomNode*/node){
var o;
win.withDoc(node.ownerDocument, function(){
var l = node.offsetLeft;

0 comments on commit 1a49e50

Please sign in to comment.