Vux: Scroller不能正确刷新

Created on 18 Apr 2016  ·  4Comments  ·  Source: airyland/vux

Version 0.0.105

PC chrome

Reproduce

下拉scroller,在pulldown:reset完成之前迅速上拉,滚动条不能正确刷新。

<scroller
  v-ref:scroller
  lock-x scrollbar-y
  use-pulldown
  :pulldown-config={...}
  @pulldown:loading="load">
  <div>
    <div v-for="item in list">...</div>
  </div>
</scroller>
load(uuid){
  this.$http.get(...)
    .then(({data:{list}}})=>{
      this.list = list
        this.$nextTick(()=>{
          this.$broadcast('pulldown:reset',uuid)
        })
      }
    })
}

另外,手动push数据到list后,有没有方法刷新滚动条,目前的方法是调用scroller._xscroll.render(),总感觉不是很好。

to be repro

Most helpful comment

图片最好预留占位高度,多个图片多次reset也是挺麻烦的。
现在增加了scroller:reset事件了,你也可以取得component的ref来调用reset方法。

All 4 comments

"下拉scroller,在pulldown:reset完成之前迅速上拉,滚动条不能正确刷新" 这个操作我无法重现。可能是我理解不对?

主动刷新确实不好优雅地解决,如果直接在scroller上加一个render方法呢,调用时在scroller上加上ref,然后调用 render方法。

gif
下拉刷新的时候,迅速向上滑动,数据加载出来之后,滚动条就不会刷新了。

pulldown:reset和pullup:reset只有在下拉或者上拉刷新操作才调用,再添加一个scroller:reset之类的事件用于主动刷新,妥当否?尤其适用于那些本身没有pulldown或者pullup的scroller。

还有一个图片加载的问题,图片加载出来之后,scroller不能根据图片高度刷新滚动条,同样需要手动刷新,或者预留图片高度。

图片最好预留占位高度,多个图片多次reset也是挺麻烦的。
现在增加了scroller:reset事件了,你也可以取得component的ref来调用reset方法。

多个图片可以做一个监听所有图片加载完成了再 reset 一次。可以看看我这个小工具:https://github.com/bammoo/load-image/blob/master/index.js

实际场景:

loadAllImages(imgurlList, null, () => {
  // this.$refs.scroller.reset() 
  this.$broadcast('pullup:reset', uuid)
})

或者,也可能用上面这个工具预加载所有图片,加载完成后,再把数据添加到 v-for 循环的数组中。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

skyshirt picture skyshirt  ·  4Comments

chengjs picture chengjs  ·  4Comments

FlyArtist picture FlyArtist  ·  3Comments

lkangd picture lkangd  ·  5Comments

airyland picture airyland  ·  5Comments