forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(angular): virtual-scroll (ionic-team#16729)
fixes ionic-team#16725 fixes ionic-team#16432 fixes ionic-team#16023 fixes ionic-team#14591 fixes ionic-team#16050 fixes ionic-team#15587
- Loading branch information
1 parent
d4e4b52
commit f05c7d6
Showing
10 changed files
with
174 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
angular/test/test-app/src/app/virtual-scroll-detail/virtual-scroll-detail.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-back-button></ion-back-button> | ||
</ion-buttons> | ||
<ion-title>virtual-scroll page</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content padding> | ||
<h1>Item {{itemNu}}</h1> | ||
<p>ngOnInit: <span id="ngOnInit">{{onInit}}</span></p> | ||
<p>ionViewWillEnter: <span id="ionViewWillEnter">{{willEnter}}</span></p> | ||
<p>ionViewDidEnter: <span id="ionViewDidEnter">{{didEnter}}</span></p> | ||
<p>ionViewWillLeave: <span id="ionViewWillLeave">{{willLeave}}</span></p> | ||
<p>ionViewDidLeave: <span id="ionViewDidLeave">{{didLeave}}</span></p> | ||
</ion-content> |
45 changes: 45 additions & 0 deletions
45
angular/test/test-app/src/app/virtual-scroll-detail/virtual-scroll-detail.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Component, NgZone, OnInit } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app-virtual-scroll-detail', | ||
templateUrl: './virtual-scroll-detail.component.html', | ||
}) | ||
export class VirtualScrollDetailComponent implements OnInit { | ||
|
||
onInit = 0; | ||
willEnter = 0; | ||
didEnter = 0; | ||
willLeave = 0; | ||
didLeave = 0; | ||
|
||
itemNu = 'none'; | ||
|
||
constructor(private route: ActivatedRoute) {} | ||
|
||
ngOnInit() { | ||
this.itemNu = this.route.snapshot.paramMap.get('itemId'); | ||
NgZone.assertInAngularZone(); | ||
this.onInit++; | ||
} | ||
|
||
ionViewWillEnter() { | ||
if (this.onInit !== 1) { | ||
throw new Error('ngOnInit was not called'); | ||
} | ||
NgZone.assertInAngularZone(); | ||
this.willEnter++; | ||
} | ||
ionViewDidEnter() { | ||
NgZone.assertInAngularZone(); | ||
this.didEnter++; | ||
} | ||
ionViewWillLeave() { | ||
NgZone.assertInAngularZone(); | ||
this.willLeave++; | ||
} | ||
ionViewDidLeave() { | ||
NgZone.assertInAngularZone(); | ||
this.didLeave++; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
angular/test/test-app/src/app/virtual-scroll-inner/virtual-scroll-inner.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p> | ||
[{{onInit}}] Item {{value}} | ||
</p> |
17 changes: 17 additions & 0 deletions
17
angular/test/test-app/src/app/virtual-scroll-inner/virtual-scroll-inner.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, OnInit, NgZone, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-virtual-scroll-inner', | ||
templateUrl: './virtual-scroll-inner.component.html', | ||
}) | ||
export class VirtualScrollInnerComponent implements OnInit { | ||
|
||
@Input() value: string; | ||
onInit = 0; | ||
|
||
ngOnInit() { | ||
NgZone.assertInAngularZone(); | ||
this.onInit++; | ||
console.log('created'); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
angular/test/test-app/src/app/virtual-scroll/virtual-scroll.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title> | ||
Virtual Scroll Test | ||
</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content> | ||
<ion-virtual-scroll [items]="items" [headerFn]="myHeaderFn" [footerFn]="myFooterFn"> | ||
<ion-item-divider *virtualHeader="let header">{{ header }}</ion-item-divider> | ||
<ion-item-divider *virtualFooter="let footer">-- {{ footer }}</ion-item-divider> | ||
<ion-item *virtualItem="let item" [routerLink]="['/', 'virtual-scroll-detail', item]"> | ||
<ion-label> | ||
<app-virtual-scroll-inner [value]="item"></app-virtual-scroll-inner> | ||
</ion-label> | ||
<ion-icon *ngIf="(item % 2) === 0" name="airplane" slot="start"></ion-icon> | ||
<ion-toggle slot="end" [checked]="(item % 2) === 1"></ion-toggle> | ||
</ion-item> | ||
</ion-virtual-scroll> | ||
</ion-content> |
23 changes: 23 additions & 0 deletions
23
angular/test/test-app/src/app/virtual-scroll/virtual-scroll.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { HeaderFn } from '@ionic/core'; | ||
|
||
@Component({ | ||
selector: 'app-virtual-scroll', | ||
templateUrl: './virtual-scroll.component.html', | ||
}) | ||
export class VirtualScrollComponent { | ||
|
||
items = Array.from({length: 1000}, (_, i) => i); | ||
|
||
myHeaderFn: HeaderFn = (_, index) => { | ||
if ((index % 10) === 0) { | ||
return `Header ${index}`; | ||
} | ||
} | ||
|
||
myFooterFn: HeaderFn = (_, index) => { | ||
if ((index % 5) === 0) { | ||
return `Footer ${index}`; | ||
} | ||
} | ||
} |