diff --git a/CHANGES b/CHANGES index b19ea4d..39edd07 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ Glow Changelog +1.7.0-exoweb + +* glow.dragdrop - Added position detection for float:left elements. + 1.7.0 * glow.widgets.Autosuggest - Fixed bug that sometimes caused the suggestion list to be position off by 1 pixel diff --git a/build.properties b/build.properties index ff796ff..9d3a635 100644 --- a/build.properties +++ b/build.properties @@ -1,3 +1,3 @@ LINE=1.7 -VERSION=1.7.0 +VERSION=1.7.0-exoweb CSSVERSION=170 diff --git a/src/dragdrop/dragdrop.js b/src/dragdrop/dragdrop.js index 1f07f9d..df06907 100644 --- a/src/dragdrop/dragdrop.js +++ b/src/dragdrop/dragdrop.js @@ -236,6 +236,27 @@ }, /* + PrivateMethod: offsetParentPageLeft + + Get the number of pixels from the left of nearest element with absolute, relative or fixed position to the + left of the page. + + Returns: + An integer number of pixels. + */ + offsetParentPageLeft: function () { + var el = this.el[0], pos, left; + while (el = el.offsetParent) { + if ( $(el).css('position') != 'static' ) { + break; + } + } + return el ? + $(el).offset().left : + 0; + }, + + /* PrivateMethod: offsetTop This gets what CSS 'top' would be if the element were position "absolute" @@ -1269,14 +1290,18 @@ childBoxes = activeTarget._childBoxes, children = activeTarget._children; box.resetPosition(); - var totalHeight = activeTarget._box.innerTopPos(); - var draggablePosition = mousePos.y - box.offsetParentPageTop(); + var currTop = lastTop = baseTop = activeTarget._box.innerTopPos(); + var currTop = lastTop = baseLeft = activeTarget._box.innerLeftPos(); + var draggablePositionY = mousePos.y - box.offsetParentPageTop(); + var draggablePositionX = mousePos.x - box.offsetParentPageLeft(); var placed = 0; for (var i = 0, l = childBoxes.length; i < l; i++) { if (children[i] == this.element[0]) continue; childBox = childBoxes[i]; - totalHeight += childBox.outerHeight(); - if (draggablePosition <= totalHeight) { + currTop = baseTop + childBox.offsetTop(); + currLeft = baseLeft + childBox.offsetLeft(); + + if (draggablePositionY <= currTop && draggablePositionX <= currLeft) { if (activeTarget._dropIndicatorAt != i) { $(childBox.el).before(activeTarget._dropIndicator); activeTarget._dropIndicatorAt = i; @@ -1284,6 +1309,8 @@ placed = 1; break; } + lastTop = currTop; + lastLeft = currLeft; } if (! placed) { if (childBox) {