diff --git a/js/angular/directive/collectionRepeat.js b/js/angular/directive/collectionRepeat.js index 14452415f70..abb5250b21c 100644 --- a/js/angular/directive/collectionRepeat.js +++ b/js/angular/directive/collectionRepeat.js @@ -300,8 +300,8 @@ function CollectionRepeatDirective($ionicCollectionManager, $parse, $window, $$r parsedValue = $parse(attrValue); } - var withoutQuotes = attrValue.replace(/(\'|\"|px|%)/g, '').trim(); - var isConstant = withoutQuotes.length && !/([a-zA-Z]|\$|:|\?)/.test(withoutQuotes); + var constantAttrValue = attrValue.replace(/(\'|\"|px|%)/g, '').trim(); + var isConstant = constantAttrValue.length && !/([a-zA-Z]|\$|:|\?)/.test(constantAttrValue); dimensionData.attrValue = attrValue; // If it's a constant, it's either a percent or just a constant pixel number. @@ -560,7 +560,6 @@ function RepeatManagerFactory($rootScope, $window, $$rAF) { delete itemsShownMap[i]; itemsLeaving.push(item); item.isShown = false; - item.scope.$broadcast('$collectionRepeatChange'); } } @@ -669,6 +668,7 @@ function RepeatManagerFactory($rootScope, $window, $$rAF) { if (item.isShown) { count--; if (!rootScopePhase) item.scope.$digest(); + item.scope.$broadcast('$collectionRepeatLeave'); } } $$rAF(process); diff --git a/js/angular/directive/item.js b/js/angular/directive/item.js index fa68be5c38e..421f3fbc042 100644 --- a/js/angular/directive/item.js +++ b/js/angular/directive/item.js @@ -28,7 +28,7 @@ var ITEM_TPL_CONTENT = * ``` */ IonicModule -.directive('ionItem', function() { +.directive('ionItem', ['$$rAF', function($$rAF) { var nextId = 0; return { restrict: 'E', @@ -66,12 +66,18 @@ IonicModule var content = $element[0].querySelector('.item-content'); if (content) { - $scope.$on('$collectionRepeatChange', function() { - content && (content.style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)'); + $scope.$on('$collectionRepeatLeave', function() { + if (content) { + content.style[ionic.CSS.TRANSFORM] = ''; + content.style[ionic.CSS.TRANSITION] = 'none'; + $$rAF(function() { + content.style[ionic.CSS.TRANSITION] = ''; + }); + } }); } }; } }; -}); +}]); diff --git a/js/angular/directive/itemDeleteButton.js b/js/angular/directive/itemDeleteButton.js index d00882ab4bc..007f12d420d 100644 --- a/js/angular/directive/itemDeleteButton.js +++ b/js/angular/directive/itemDeleteButton.js @@ -33,7 +33,7 @@ IonicModule .directive('ionDeleteButton', function() { return { restrict: 'E', - require: ['^ionItem', '^?ionList'], + require: ['^^ionItem', '^?ionList'], //Run before anything else, so we can move it before other directives process //its location (eg ngIf relies on the location of the directive in the dom) priority: Number.MAX_VALUE, @@ -48,8 +48,13 @@ IonicModule container.append($element); itemCtrl.$element.append(container).addClass('item-left-editable'); - if (listCtrl && listCtrl.showDelete()) { - container.addClass('visible active'); + init(); + $scope.$on('$ionic.reconnectScope', init); + function init() { + listCtrl = listCtrl || $element.controller('ionList'); + if (listCtrl && listCtrl.showDelete()) { + container.addClass('visible active'); + } } }; } diff --git a/test/html/collection-repeat/basic-list.html b/test/html/collection-repeat/basic-list.html index c81a121b9ec..f808022d265 100644 --- a/test/html/collection-repeat/basic-list.html +++ b/test/html/collection-repeat/basic-list.html @@ -13,12 +13,15 @@