mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix item destroy
This commit is contained in:
@@ -163,6 +163,9 @@ export class ViewController extends Ion {
|
||||
for (let j = 0; j < newBeforeItems.length; j++) {
|
||||
component = newBeforeItems[j];
|
||||
viewItem = new ViewItem(this, component.component || component, component.params);
|
||||
viewItem.state = CACHED_STATE;
|
||||
viewItem.shouldDestroy = false;
|
||||
viewItem.shouldCache = false;
|
||||
|
||||
// add the item to the stack
|
||||
this.add(viewItem);
|
||||
@@ -362,12 +365,12 @@ export class ViewController extends Ion {
|
||||
}
|
||||
|
||||
transitionComplete() {
|
||||
let destroys = [];
|
||||
|
||||
this.items.forEach((item) => {
|
||||
this.items.forEach(item => {
|
||||
if (item) {
|
||||
if (item.shouldDestroy) {
|
||||
this.remove(item);
|
||||
item.destroy();
|
||||
destroys.push(item);
|
||||
|
||||
} else if (item.state === CACHED_STATE && item.shouldCache) {
|
||||
item.shouldCache = false;
|
||||
@@ -375,6 +378,11 @@ export class ViewController extends Ion {
|
||||
}
|
||||
});
|
||||
|
||||
destroys.forEach(item => {
|
||||
this.remove(item);
|
||||
item.destroy();
|
||||
});
|
||||
|
||||
// allow clicks again
|
||||
ClickBlock(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user