Blame view

node_modules/better-scroll/src/scroll/pulldown.js 1.07 KB
aaac7fed   liuqimichale   add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  import { ease } from '../util/ease'
  import { DIRECTION_DOWN, PROBE_REALTIME } from '../util/const'
  
  export function pullDownMixin(BScroll) {
    BScroll.prototype._initPullDown = function () {
      // must watch scroll in real time
      this.options.probeType = PROBE_REALTIME
    }
  
    BScroll.prototype._checkPullDown = function () {
      const {threshold = 90, stop = 40} = this.options.pullDownRefresh
  
      // check if a real pull down action
      if (this.directionY !== DIRECTION_DOWN || this.y < threshold) {
        return false
      }
  
      if (!this.pulling) {
        this.pulling = true
        this.trigger('pullingDown')
      }
      this.scrollTo(this.x, stop, this.options.bounceTime, ease.bounce)
  
      return this.pulling
    }
  
    BScroll.prototype.finishPullDown = function () {
      this.pulling = false
      this.resetPosition(this.options.bounceTime, ease.bounce)
    }
  
    BScroll.prototype.openPullDown = function (config = true) {
      this.options.pullDownRefresh = config
      this._initPullDown()
    }
  
    BScroll.prototype.closePullDown = function () {
      this.options.pullDownRefresh = false
    }
  }