mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
test(nav): create nav memory test
This commit is contained in:
86
ionic/components/nav/test/memory/index.ts
Normal file
86
ionic/components/nav/test/memory/index.ts
Normal file
@ -0,0 +1,86 @@
|
||||
import {App, Page, NavController} from '../../../../../ionic/ionic';
|
||||
|
||||
|
||||
let delay = 100;
|
||||
let animate = false;
|
||||
let count = 0;
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-content padding text-center>
|
||||
<p>Page 1</p>
|
||||
<button (click)="stop()">Stop</button>
|
||||
<button (click)="play()">Play</button>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
class Page1 {
|
||||
tmr;
|
||||
|
||||
constructor(private nav: NavController) {}
|
||||
|
||||
play() {
|
||||
this.tmr = setTimeout(() => {
|
||||
count++;
|
||||
console.log('push', count);
|
||||
|
||||
this.nav.push(Page2, null, {
|
||||
animate: animate
|
||||
});
|
||||
}, delay);
|
||||
}
|
||||
|
||||
onPageDidEnter() {
|
||||
this.play();
|
||||
}
|
||||
|
||||
stop() {
|
||||
clearTimeout(this.tmr);
|
||||
}
|
||||
}
|
||||
|
||||
@Page({
|
||||
template: `
|
||||
<ion-content padding text-center>
|
||||
<p>Page 2</p>
|
||||
<button (click)="stop()">Stop</button>
|
||||
<button (click)="play()">Play</button>
|
||||
</ion-content>
|
||||
`
|
||||
})
|
||||
class Page2 {
|
||||
tmr;
|
||||
|
||||
constructor(private nav: NavController) {}
|
||||
|
||||
play() {
|
||||
this.tmr = setTimeout(() => {
|
||||
count++;
|
||||
console.log('pop', count);
|
||||
|
||||
this.nav.pop({
|
||||
animate: animate
|
||||
});
|
||||
}, delay);
|
||||
}
|
||||
|
||||
onPageDidEnter() {
|
||||
this.play();
|
||||
}
|
||||
|
||||
stop() {
|
||||
clearTimeout(this.tmr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@App({
|
||||
template: `<ion-nav [root]="root"></ion-nav>`
|
||||
})
|
||||
class E2EApp {
|
||||
root;
|
||||
|
||||
constructor() {
|
||||
this.root = Page1;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user