Skip to content

Commit 39e1dce

Browse files
committed
fix(img): ensure scroll has been initialized
1 parent aec8f51 commit 39e1dce

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/components/content/content.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ export class Content extends Ion implements OnDestroy, OnInit {
777777
* @private
778778
*/
779779
imgsUpdate() {
780-
if (this._imgs.length && this.isImgsUpdatable()) {
780+
if (this._scroll.initialized && this._imgs.length && this.isImgsUpdatable()) {
781781
updateImgs(this._imgs, this.scrollTop, this.scrollHeight, this.directionY, IMG_REQUESTABLE_BUFFER, IMG_RENDERABLE_BUFFER);
782782
}
783783
}

src/components/tabs/test/basic/app-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class Tab2 {
187187
<button ion-button (click)="appNavPop()">App Nav Pop</button>
188188
</p>
189189
190-
<ion-list [virtualScroll]="items" [headerFn]="headerFn">
190+
<ion-list [virtualScroll]="items">
191191
192192
<ion-item *virtualItem="let item">
193193
Item: {{item}}

src/components/virtual-scroll/test/cards/main.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
<div [virtualScroll]="items" approxItemHeight="320px">
1010

11-
<ion-card *virtualItem="let item">
11+
<ion-card *virtualItem="let item; let itemBounds = bounds;">
1212

1313
<div>
14-
<ion-img [src]="item.imgSrc" [height]="item.imgHeight" [alt]="item.name"></ion-img>
14+
<ion-img [src]="item.imgSrc" [height]="item.imgHeight" [alt]="item.name" [bounds]="itemBounds"></ion-img>
1515
</div>
1616

1717
<ion-item>
1818
<ion-avatar item-left>
19-
<ion-img [src]="item.avatarSrc" height="40" width="40"></ion-img>
19+
<ion-img [src]="item.avatarSrc" height="40" width="40" [bounds]="itemBounds"></ion-img>
2020
</ion-avatar>
2121
<h2>{{ item.name }}</h2>
2222
</ion-item>

src/util/scroll-view.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class ScrollView {
1111
scrollStart = new Subject<ScrollEvent>();
1212
scroll = new Subject<ScrollEvent>();
1313
scrollEnd = new Subject<ScrollEvent>();
14+
initialized: boolean;
1415

1516
private _el: HTMLElement;
1617
private _js: boolean;
@@ -28,7 +29,9 @@ export class ScrollView {
2829
constructor(private _dom: DomController) {}
2930

3031
init(ele: HTMLElement, contentTop: number, contentBottom: number) {
31-
if (!this._el) {
32+
if (!this.initialized) {
33+
this.initialized = true;
34+
3235
assert(ele, 'scroll-view, element can not be null');
3336
this._el = ele;
3437

0 commit comments

Comments
 (0)