From 38b8c6e4b1626db22f1d1b54b31c9b78ab55f54b Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 14 Oct 2013 12:05:25 -0500 Subject: [PATCH] List item reordering! --- dist/js/ionic.js | 14 +++++--------- js/views/listView.js | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/dist/js/ionic.js b/dist/js/ionic.js index bad4eafe8d..1f5bb7afe0 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -1990,7 +1990,7 @@ window.ionic = { // Grab the starting Y point for the item - var offsetY = this.el.style.top;//parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[1]) || 0; + var offsetY = this.el.offsetTop;//parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[1]) || 0; var placeholder = this.el.cloneNode(true); @@ -2002,8 +2002,7 @@ window.ionic = { this._currentDrag = { - startOffsetY: offsetY, - startOffsetTop: this.el.offsetTop, + startOffsetTop: offsetY, placeholder: placeholder }; }; @@ -2019,18 +2018,15 @@ window.ionic = { // Check if we should start dragging. Check if we've dragged past the threshold, // or we are starting from the open state. - if(!_this._isDragging && - ((Math.abs(e.gesture.deltaY) > _this.dragThresholdY) || - (Math.abs(_this._currentDrag.startOffsetY) > 0))) - { + if(!_this._isDragging && Math.abs(e.gesture.deltaY) > _this.dragThresholdY) { _this._isDragging = true; } if(_this._isDragging) { - var newY = _this._currentDrag.startOffsetTop + e.gesture.deltaY; //Math.min(0, _this._currentDrag.startOffsetY + e.gesture.deltaY); + var newY = _this._currentDrag.startOffsetTop + e.gesture.deltaY; console.log(newY); - _this.el.style.top = newY + 'px';//webkitTransform = 'translate3d(0, ' + newY + 'px, 0)'; + _this.el.style.top = newY + 'px'; _this._currentDrag.currentY = newY; diff --git a/js/views/listView.js b/js/views/listView.js index 0c5b033552..3035a282ee 100644 --- a/js/views/listView.js +++ b/js/views/listView.js @@ -149,7 +149,7 @@ // Grab the starting Y point for the item - var offsetY = this.el.style.top;//parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[1]) || 0; + var offsetY = this.el.offsetTop;//parseFloat(this.el.style.webkitTransform.replace('translate3d(', '').split(',')[1]) || 0; var placeholder = this.el.cloneNode(true); @@ -161,8 +161,7 @@ this._currentDrag = { - startOffsetY: offsetY, - startOffsetTop: this.el.offsetTop, + startOffsetTop: offsetY, placeholder: placeholder }; }; @@ -178,18 +177,15 @@ // Check if we should start dragging. Check if we've dragged past the threshold, // or we are starting from the open state. - if(!_this._isDragging && - ((Math.abs(e.gesture.deltaY) > _this.dragThresholdY) || - (Math.abs(_this._currentDrag.startOffsetY) > 0))) - { + if(!_this._isDragging && Math.abs(e.gesture.deltaY) > _this.dragThresholdY) { _this._isDragging = true; } if(_this._isDragging) { - var newY = _this._currentDrag.startOffsetTop + e.gesture.deltaY; //Math.min(0, _this._currentDrag.startOffsetY + e.gesture.deltaY); + var newY = _this._currentDrag.startOffsetTop + e.gesture.deltaY; console.log(newY); - _this.el.style.top = newY + 'px';//webkitTransform = 'translate3d(0, ' + newY + 'px, 0)'; + _this.el.style.top = newY + 'px'; _this._currentDrag.currentY = newY;