简体   繁体   English

ionic 4 pull 刷新文本,在拉动时显示在内容上

[英]ionic 4 pull to refresh text showing over content while pulling

Hi using ionic 4 / angular7嗨,使用 ionic 4 / angular7

I want to inplement pull to refresh and i have done it this way:我想实现 pull 刷新,我是这样做的:

  <ion-refresher slot="start"
             (ionRefresh)="ionRefresh($event)"
             (ionPull)="ionPull($event)"
             (ionStart)="ionStart($event)">
<ion-refresher-content
        pullingIcon="arrow-dropdown"
        pullingText="Pull to refresh"
        refreshingSpinner="circles"
        refreshingText="Refreshing...">
</ion-refresher-content>

and in controller并在控制器中

 ionRefresh(event) {
    console.log('Pull Event Triggered!');
    setTimeout(() => {
      console.log('Async operation has ended');

  //complete()  signify that the refreshing has completed and to close 
  the refresher
      event.target.complete();
    }, 2000);
  }
  ionPull(event){
    //Emitted while the user is pulling down the content and exposing the 
  refresher.
    console.log('ionPull Event Triggered!');
  }
  ionStart(event){
    //Emitted when the user begins to start pulling down.
    console.log('ionStart Event Triggered!');
  }

this works but it shows some weird effects.这有效,但它显示了一些奇怪的效果。 While pulling down the text pull to refresh hovers over the content also when closing the refresher the text refreshing stays shown for a second or 2. This all makes it look bad.当拉下文本下拉刷新时,在关闭刷新器时也会将鼠标悬停在内容上,文本刷新会保持显示一秒或两秒。这一切都让它看起来很糟糕。 How can i fix this?我怎样才能解决这个问题?

I also had to add styles to the refresher otherwise the refresher had a black background with no text showing so i added this:我还必须为复习添加样式,否则复习有黑色背景,没有显示文本,所以我添加了这个:

<style>
  ion-content {
    background-color: #efefef;
    color:#555;
  }
  ion-refresher {
    z-index:1;
  }

i have made a gif showing the behavior我制作了一个 gif 显示行为

这就是发生的事情

i fixed it (thanks Paresh) is was because the background of the content was transparent.我修复了它(感谢 Paresh)是因为内容的背景是透明的。 also had to set the z-index higher then the refreshher.还必须将 z-index 设置为高于 refreshher。 For some reason no z-index on the refresher did not show text由于某种原因,复习中没有 z-index 没有显示文本

this is the fix:这是修复:

<ion-content style="background:#efefef;color:#555;z-index:1;">

  <ion-refresher slot="fixed" style=""
                 (ionRefresh)="ionRefresh($event)"
                 (ionPull)="ionPull($event)"
                 (ionStart)="ionStart($event)">
    <ion-refresher-content style=""
            pullingIcon="arrow-dropdown"
            pullingText="Pull to refresh"
            refreshingSpinner="circles"
            refreshingText="Refreshing...">
    </ion-refresher-content>
  </ion-refresher>


  <div class="ion-padding" style="background:#fff;z-index:2">
    content here
  </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM