Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么下拉刷新没效果啊? #4

Open
KXwonderful opened this issue Mar 26, 2018 · 8 comments
Open

怎么下拉刷新没效果啊? #4

KXwonderful opened this issue Mar 26, 2018 · 8 comments

Comments

@KXwonderful
Copy link

如题,下拉刷新无效

@ssyzh
Copy link

ssyzh commented Apr 4, 2018

请用手机测试,不要用开发工具。

@KXwonderful
Copy link
Author

demo在手机上测试了下拉刷新还是无效,上拉加载更多是没问题

@MisterDeng
Copy link

同问

@MisterDeng
Copy link

安卓上没有反应,苹果的可以

@ssyzh
Copy link

ssyzh commented Apr 10, 2018

原因是scroll-view在iOS上有橡皮筋效果,scrollTop可以为负值,在安卓上没有橡皮筋效果,scrollTop最小为0。可做以下下修改,暂时用着,待 @ianho 想出更好的办法。

<!--components/xing/x-scroll-view/x-scroll-view.wxml-->
<scroll-view class="scroll-view {{pullDownStatus === 3 ? 'refresh' : ''}} {{pullDownStatus === 4 ? 'finish' : ''}}" scroll-y scroll-with-animation enable-back-to-top scroll-into-view='{{topview}}' bindscroll="_onScroll" bindtouchend="_onTouchEnd" bindscrolltolower="_onLoadmore">
  <view class='con'></view>
  <view id='topview' class='con'></view>
  <view class="pulldown">
    <block wx:if="{{pullDownStatus === 0 || pullDownStatus === 1}}">
      <text class="iconfont icon-pull-down" space="nbsp"></text><text> {{pullText}}</text>
    </block>
    <block wx:if="{{pullDownStatus === 2}}">
      <text class="iconfont icon-release-up" space="nbsp"></text><text> {{releaseText}}</text>
    </block>
    <block wx:if="{{pullDownStatus === 3}}">
      <text class="iconfont icon-loading loading" space="nbsp"></text><text> {{loadingText}}...</text>
    </block>
    <block wx:if="{{pullDownStatus === 4}}">
      <text class="iconfont icon-complete" space="nbsp"></text><text> {{finishText}}</text>
    </block>
  </view>
  <slot></slot>
  <view class="loadmore">
    <block wx:if="{{nomore}}">
      <text>{{nomoreText}}</text>
    </block>
    <block wx:else>
      <text class="iconfont icon-loading loading" space="nbsp"></text><text> {{loadmoreText}}</text>
    </block>
  </view>
</scroll-view>

增加

 ready: function () {
    this.setData({
      pullDownStatus: 0,
      topview: 'topview'
    })
  },

修改

_onScroll: function (e) {
      this.triggerEvent('scroll', e.detail);
      const status = this.data.pullDownStatus;
      if (status === 3 || status == 4) return;
      const height = this.properties.pullDownHeight;
      const scrollTop = e.detail.scrollTop;
      console.log(scrollTop)
      let targetStatus;
      if (scrollTop < 1) {
        targetStatus = 2;
      } else {
        targetStatus = 0;
      }
      // if (scrollTop < -1 * height) {
      //   targetStatus = 2;
      // } else if (scrollTop < 0) {
      //   targetStatus = 1;
      // } else {
      //   targetStatus = 0;
      // }
      if (status != targetStatus) {
        this.setData({
          pullDownStatus: targetStatus,
        })
      }
    },

@MisterDeng
Copy link

@ssyzh 谢了,安卓不支持回弹确实麻烦

@wangliguang
Copy link

@ssyzh 没有很明白你指的解决方式,比如改动xml的哪一块,ready方法指的是什么

@JsAaron
Copy link

JsAaron commented Nov 15, 2018

确实如此,但是scrollTop也不准,scrollTop的值,应该是松手后,但是会有惯性滑动,所以不太灵敏。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants