【发布时间】:2017-08-01 01:09:22
【问题描述】:
我在我的 html 中使用 ion-infinite-scroll,如下所示:
<div class ='contentone' #contentone [@moveList]='moveState'>
<ion-list class="marginstatus" no-padding>
<ion-item *ngFor="let i of items" no-padding no-lines>
<div class="feedtoptextcontainer">
<div class="imageparent">
<img class="postprofilepic" src="{{i.url}}">
</div>
<div class="usernamecontainer">
<h4 class="postusername">{{i.username}}</h4><br>
<h4 class="poststudio">Ed's Studio</h4>
</div>
<div class="postprofilelink">
<div class="book">{{i.title}}<!--</div><div style="display: inline-block">@edbundyhair--></div>
</div>
</div>
<img class="imagepost" src="{{i.url}}">
<div class='caption'>
{{i.caption}}
</div>
<br>
</ion-item>
</ion-list>
<ion-infinite-scroll (ionInfinite)="$event.waitFor(doInfinite())">
<ion-infinite-scroll-content
loadingSpinner="bubbles"
loadingText="Loading more data..."
threshold="1%">
</ion-infinite-scroll-content>
</ion-infinite-scroll>
</div>
我的控制器代码如下所示:
doInfinite(): Promise<any> {
console.log('Begin async operation');
return new Promise((resolve, reject) => {
setTimeout(() => {
this.list = this.af.list('/promos', {
query: {
orderByKey: true,
startAt: this.startAtKey,
}});
this.list.subscribe(items => {
items.forEach(item => {
console.log(JSON.stringify(item.customMetadata));
console.log(this.startAtKey + " " + item.$key);
if(this.startAtKey == item.$key) {
//
}
else {
this.startAtKey = item.$key;
this.items.push(item.customMetadata);
}
});
resolve();
})
}, 500);
})
}
奇怪的是,不久前一切正常,但为了显示无限滚动,我必须像这样添加 css:
ion-infinite-scroll {
position: relative;
bottom: 30px;
background-color: white;
}
问题是,当我向上滚动时,doInfinite 方法只会在您向下滚动时触发。我正在使用离子刷新器来处理向上滚动。感谢您的帮助,谢谢。
【问题讨论】:
标签: html css angular ionic-framework scroll