sourcebitsllc / chocolatechip-ui

Mobile Web App Framework
www.chocolatechip-ui.com
MIT License
617 stars 88 forks source link

Prevent iOS7 WebApp page from bouncing up and down #37

Closed nickGermi closed 10 years ago

nickGermi commented 10 years ago

Not sure where to put this or if there is a better way of doing this, in any case just putting this here, might be helpful

The only (easy) way I could fined to do this is to check current article's scroll position, if on top push it down by 1 pixel and if on bottom pull it up by 1 pixel, this will prevent the whole page from bouncing up and down when you swipe down/up while scroll position is on top/bottom.

$(document).on('touchstart', function(e){ var el = $(e.target).parents('article'); if(el.length) { var scrollPos = el.scrollTop(); if(scrollPos == 0) el.scrollTop(1); else if(el[0].scrollHeight-scrollPos == el[0].offsetHeight)el.scrollTop(scrollPos-1); } });

nickGermi commented 10 years ago

Never mind, see https://github.com/sourcebitsllc/chocolatechip-ui/commit/4b21b024fd6739399dbecee1c8dc79b36878b351