fix item destroy

This commit is contained in:
Adam Bradley
2015-06-30 21:19:35 -05:00
parent c5b7e1d6ef
commit 5e00b40fa4

View File

@@ -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);
}