fix(listView): position dragged list item properly when list view's parent is offset. Closes #1583

This commit is contained in:
Perry Govier
2014-06-06 15:14:52 -05:00
parent 40392c0da3
commit afdf0ad764

View File

@@ -186,6 +186,15 @@
this.el = opts.el;
this.scrollEl = opts.scrollEl;
this.scrollView = opts.scrollView;
// Get the True Top of the list el http://www.quirksmode.org/js/findpos.html
this.listEl.trueTop = 0;
if (this.listEl.offsetParent) {
var obj = this.listEl;
do {
this.listEl.trueTop += obj.offsetTop;
obj = obj.offsetParent;
} while (obj);
}
};
ReorderDrag.prototype = new DragOp();
@@ -193,9 +202,8 @@
ReorderDrag.prototype._moveElement = function(e) {
var y = e.gesture.center.pageY +
this.scrollView.getValues().top -
this.scrollView.__container.offsetTop -
(this._currentDrag.elementHeight / 2) -
this.listEl.offsetTop;
this.listEl.trueTop;
this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(0, '+y+'px, 0)';
};
@@ -231,7 +239,7 @@
var scrollY = 0;
var pageY = e.gesture.center.pageY;
var offset = this.listEl.offsetTop + this.scrollView.__container.offsetTop;
var offset = this.listEl.trueTop;
//If we have a scrollView, check scroll boundaries for dragged element and scroll if necessary
if (this.scrollView) {