最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable iOS Overscroll but allow body scrolling - Stack Overflow

programmeradmin3浏览0评论

I would like to disable the iOS overscroll in a webapp but still allow the body to be scrolled.

$(document).on('touchmove', function(e) {
    e.preventDefault();
});

disables scrolling altogether (as one would expect).

Is there a way to do what I want to do?

I would like to disable the iOS overscroll in a webapp but still allow the body to be scrolled.

$(document).on('touchmove', function(e) {
    e.preventDefault();
});

disables scrolling altogether (as one would expect).

Is there a way to do what I want to do?

Share Improve this question asked May 11, 2012 at 6:59 Michael BatesMichael Bates 1,9342 gold badges30 silver badges43 bronze badges 2
  • It is an answer to a related question, though it covers this issue as well, stackoverflow./questions/2890361/…. – Gajus Commented Nov 11, 2014 at 0:02
  • I have found this script which fix this problem! :) github./lazd/iNoBounce – Jan Šafránek Commented Nov 15, 2015 at 10:26
Add a ment  | 

2 Answers 2

Reset to default 7

I had pretty much the same issue. This should help you:

// Disable overscroll / viewport moving on everything but scrollable divs
 $('body').on('touchmove', function (e) {
         if (!$('.scrollable').has($(e.target)).length) e.preventDefault();
 });
document.body.addEventListener('touchmove',function(e){
     if(!$(e.target).hasClass("scrollable")) {
       e.preventDefault();
     }
 });

Try this i just got in via google

发布评论

评论列表(0)

  1. 暂无评论