From 9985efaa52ee9d3c09885753ef9ae8bc0412856c Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 9 Oct 2014 20:15:56 -0500 Subject: [PATCH] chore(listView): cleanup element references --- js/views/listView.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/js/views/listView.js b/js/views/listView.js index fd6d8727be..fa41febe59 100644 --- a/js/views/listView.js +++ b/js/views/listView.js @@ -171,7 +171,15 @@ // Kill the current drag + if(_this._lastDrag) { + _this._lastDrag.buttons = null; + _this._lastDrag.content = null; + } _this._lastDrag = _this._currentDrag; + if(_this._currentDrag) { + _this._currentDrag.buttons = null; + _this._currentDrag.content = null; + } _this._currentDrag = null; // We are done, notify caller @@ -207,6 +215,13 @@ this.el.style[ionic.CSS.TRANSFORM] = 'translate3d(0, '+y+'px, 0)'; }; + ReorderDrag.prototype.deregister = function() { + this.listEl = null; + this.el = null; + this.scrollEl = null; + this.scrollView = null; + }; + ReorderDrag.prototype.start = function(e) { var content; @@ -331,6 +346,10 @@ this.onReorder && this.onReorder(this.el, this._currentDrag.startIndex, finalIndex); + this._currentDrag = { + placeholder: null, + content: null + }; this._currentDrag = null; doneCallback && doneCallback(); }; @@ -376,13 +395,24 @@ // Start the drag states this._initDrag(); }, + + /** + * Be sure to cleanup references. + */ + deregister: function() { + this.el = null; + this.listEl = null; + this.scrollEl = null; + this.scrollView = null; + }, + /** * Called to tell the list to stop refreshing. This is useful * if you are refreshing the list and are done with refreshing. */ stopRefreshing: function() { var refresher = this.el.querySelector('.list-refresher'); - refresher.style.height = '0px'; + refresher.style.height = '0'; }, /** @@ -449,6 +479,7 @@ clearDragEffects: function() { if(this._lastDragOp) { this._lastDragOp.clean && this._lastDragOp.clean(); + this._lastDragOp.deregister && this._lastDragOp.deregister(); this._lastDragOp = null; } }, @@ -457,6 +488,9 @@ //ionic.views.ListView.__super__._initDrag.call(this); // Store the last one + if(this._lastDragOp) { + this._lastDragOp.deregister && this._lastDragOp.deregister(); + } this._lastDragOp = this._dragOp; this._dragOp = null;