[关闭]
@windchimes 2018-08-08T08:30:12.000000Z 字数 422 阅读 238

移动端ios阻止橡皮筋效果

开发技巧


  1. var startY,endY;
  2. $('body').on('touchstart', function(e {
  3. startY = e.touches[0].pageY;
  4. });
  5. $('body').on('touchmove', function(e){
  6. endY = e.touches[0].pageY;
  7. // 手指下滑,页面到达顶端不能继续下滑
  8. if(endY > startY && $(window).scrollTop() <=0 ) {
  9. e.preventDefault();
  10. }
  11. // 手指上滑,页面到达底部能继续上滑
  12. if(endY< startY && $(window).scrollTop()+$(window).height()>=$('body')[0].scrollHeight) {
  13. e.preventDefault();
  14. }
  15. })

参考链接:https://www.cnblogs.com/cuncunjun/p/7493782.html

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注