mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
enhance(slideBox): use element.$destroy for slide
This commit is contained in:
16
js/angular/directive/slide.js
vendored
16
js/angular/directive/slide.js
vendored
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}]);
|
||||
|
||||
5
js/angular/service/slideBoxDelegate.js
vendored
5
js/angular/service/slideBoxDelegate.js
vendored
@@ -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',
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user