You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
815 B

4 years ago
  1. // bounce: iOS橡皮筋,Android半月弧,h5浏览器下拉背景等效果, 适用于h5和renderjs (下拉刷新时禁止)
  2. const bounce = {
  3. // false: 禁止bounce; true:允许bounce
  4. setBounce: function(isBounce){
  5. window.$isMescrollBounce = isBounce
  6. }
  7. }
  8. // 引入即自动初始化 (仅初始化一次)
  9. if(window && window.$isMescrollBounce == null){
  10. // 是否允许bounce, 默认允许
  11. window.$isMescrollBounce = true
  12. // 每次点击时重置bounce
  13. window.addEventListener('touchstart', function(){
  14. window.$isMescrollBounce = true
  15. }, {passive: true})
  16. // 滑动中标记是否禁止bounce (如:下拉刷新时禁止)
  17. window.addEventListener('touchmove', function(e){
  18. !window.$isMescrollBounce && e.preventDefault() // 禁止bounce
  19. }, {passive: false})
  20. }
  21. export default bounce;