这是我使用scroll function
事件的HTML文件。
<ion-content (ionScroll)="scrollFunction($event)">
<ion-card *ngFor="let product of products" no-padding>
<ion-item class="bigclass">
<ion-thumbnail item-height="100px" item-start>
<img-loader *ngIf="product.images" src="{{product.images[0].src}}" useImg></img-loader>
</ion-thumbnail>
</ion-card>
<ion-infinite-scroll (ionInfinite)="loadMoreProducts($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>
<ion-footer>
<button class="proceed" *ngIf="isShown" ion-button full (click)="proceedPayment()">Proceed</button>
</ion-footer>
这是我的.ts
文件。它在向下滚动事件时隐藏按钮但未显示。当我向上或向下滚动时,我希望它能够正常工作。按钮。它应该隐藏,当ion-content
的滚动停止时,按钮应该可见。
public isShown:bolean=false;
constructor(public navCtrl:NavController){
this.WooCommerce.getAsync('products?
consumer_key=ck&consumer_secret=cs').then((result) => {
console.log(JSON.parse(result.toJSON().body));
this.products = JSON.parse(result.toJSON().body);
console.log(this.products);
this.products.forEach(product => { product.quantity = 1,
product.disabled=false;});
return JSON.parse(result.toJSON().body);
}, (err) => {
console.log(err)
})
}
public scrollFunction = (event: any) => {
let dimensions = this.content.getContentDimensions();
let bottomPosition = dimensions.contentHeight + dimensions.scrollTop;
let screenSize = dimensions.scrollHeight;
this.isShown = screenSize - bottomPosition <= 10 ? true : false;
}
答案 0 :(得分:0)
您可以在ion-content
<强> ionScrollEnd 强>
<ion-content (ionScrollStart)="scrollStart($event)" (ionScrollEnd)="scrollStart($event)
并通过更新isShown
scrollStart(event) {
this.isShown = false;
}
scrollStop(event) {
this.isShown = true;
}