mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
fix(img): ensure scroll has been initialized
This commit is contained in:
@ -777,7 +777,7 @@ export class Content extends Ion implements OnDestroy, OnInit {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
imgsUpdate() {
|
imgsUpdate() {
|
||||||
if (this._imgs.length && this.isImgsUpdatable()) {
|
if (this._scroll.initialized && this._imgs.length && this.isImgsUpdatable()) {
|
||||||
updateImgs(this._imgs, this.scrollTop, this.scrollHeight, this.directionY, IMG_REQUESTABLE_BUFFER, IMG_RENDERABLE_BUFFER);
|
updateImgs(this._imgs, this.scrollTop, this.scrollHeight, this.directionY, IMG_REQUESTABLE_BUFFER, IMG_RENDERABLE_BUFFER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ export class Tab2 {
|
|||||||
<button ion-button (click)="appNavPop()">App Nav Pop</button>
|
<button ion-button (click)="appNavPop()">App Nav Pop</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ion-list [virtualScroll]="items" [headerFn]="headerFn">
|
<ion-list [virtualScroll]="items">
|
||||||
|
|
||||||
<ion-item *virtualItem="let item">
|
<ion-item *virtualItem="let item">
|
||||||
Item: {{item}}
|
Item: {{item}}
|
||||||
|
@ -8,15 +8,15 @@
|
|||||||
|
|
||||||
<div [virtualScroll]="items" approxItemHeight="320px">
|
<div [virtualScroll]="items" approxItemHeight="320px">
|
||||||
|
|
||||||
<ion-card *virtualItem="let item">
|
<ion-card *virtualItem="let item; let itemBounds = bounds;">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<ion-img [src]="item.imgSrc" [height]="item.imgHeight" [alt]="item.name"></ion-img>
|
<ion-img [src]="item.imgSrc" [height]="item.imgHeight" [alt]="item.name" [bounds]="itemBounds"></ion-img>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-avatar item-left>
|
<ion-avatar item-left>
|
||||||
<ion-img [src]="item.avatarSrc" height="40" width="40"></ion-img>
|
<ion-img [src]="item.avatarSrc" height="40" width="40" [bounds]="itemBounds"></ion-img>
|
||||||
</ion-avatar>
|
</ion-avatar>
|
||||||
<h2>{{ item.name }}</h2>
|
<h2>{{ item.name }}</h2>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
@ -11,6 +11,7 @@ export class ScrollView {
|
|||||||
scrollStart = new Subject<ScrollEvent>();
|
scrollStart = new Subject<ScrollEvent>();
|
||||||
scroll = new Subject<ScrollEvent>();
|
scroll = new Subject<ScrollEvent>();
|
||||||
scrollEnd = new Subject<ScrollEvent>();
|
scrollEnd = new Subject<ScrollEvent>();
|
||||||
|
initialized: boolean;
|
||||||
|
|
||||||
private _el: HTMLElement;
|
private _el: HTMLElement;
|
||||||
private _js: boolean;
|
private _js: boolean;
|
||||||
@ -28,7 +29,9 @@ export class ScrollView {
|
|||||||
constructor(private _dom: DomController) {}
|
constructor(private _dom: DomController) {}
|
||||||
|
|
||||||
init(ele: HTMLElement, contentTop: number, contentBottom: number) {
|
init(ele: HTMLElement, contentTop: number, contentBottom: number) {
|
||||||
if (!this._el) {
|
if (!this.initialized) {
|
||||||
|
this.initialized = true;
|
||||||
|
|
||||||
assert(ele, 'scroll-view, element can not be null');
|
assert(ele, 'scroll-view, element can not be null');
|
||||||
this._el = ele;
|
this._el = ele;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user