mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(listView): position dragged list item properly when list view's parent is offset. Closes #1583
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user