enhance(slideBox): use element.$destroy for slide

This commit is contained in:
Andrew
2014-10-09 09:57:31 -06:00
parent d9cc7894d5
commit 5621fe1ffd
2 changed files with 4 additions and 17 deletions

View File

@@ -34,23 +34,9 @@ IonicModule
element.addClass('slider-slide');
slideBoxCtrl.add(slideCtrl);
scope.$on('$destroy', function() {
element.on('$destroy', function() {
slideBoxCtrl.remove(slideCtrl);
});
// Move with ng-repeat if this slide is part of ng-repeat.
// scope.$index only appears after the first time ng-repaet inserts the element.
function watchNgRepeatIndexOnInsertElement() {
if (angular.isNumber(scope.$index)) {
scope.$watch('$index', function(newIndex, oldIndex) {
if (!isDefined(oldIndex)) return;
var difference = newIndex - oldIndex;
var currentIndex = slideBoxCtrl.indexOf(slideCtrl);
slideBoxCtrl.move(slideCtrl, currentIndex + difference);
});
}
}
}
}]);

View File

@@ -93,9 +93,10 @@ IonicModule
* @ngdoc method
* @name $ionicSlideBoxDelegate#update
* @description Causes the slidebox to re-scan all of the child slide
* elements and reorganize itself again.
* elements and reorganize itself again. This will rarely be needed.
* You only need to call update if you are moving slides around in the DOM
* (for example, ng-repeat moving an element from the middle to the end).
* (for example, ng-repeat moving an element from the middle to the end of
* the list).
*/
'update',
/**