/*
 * @Description: 禁止微信内置下拉事件
 * @Author: Napier
 * @LastEditors: Napier
 * @LastEditorTime:
 */

export default {
  fun: function () {
    var overscroll = function (el) {
      el.addEventListener('touchstart', function () {
        var top = el.scrollTop
        var totalScroll = el.scrollHeight
        var currentScroll = top + el.offsetHeight
        if (top === 0) {
          el.scrollTop = 1
        } else if (currentScroll === totalScroll) {
          el.scrollTop = top - 1
        }
      })
      el.addEventListener('touchmove', function (evt) {
        if (el.offsetHeight < el.scrollHeight) {
          evt._isScroller = true
        }
      })
    }
    overscroll(document.querySelector('.scroll'))
    document.body.addEventListener('touchmove', function (evt) {
      if (!evt._isScroller) {
        evt.preventDefault()
      }
    })
  }
}
