I know that some time has passed since you asked the question, but I had the same problem, and I used your code as the basis for solving the problem. So thanks for the inspiration.
(Javascript + jQuery)
<script> var handleMove = function (e) { var scrollable = false; var items = $(e.target).parents(); $(items).each(function(i,o) { if($(o).hasClass("scrollable")) { scrollable = true; } }); if(!scrollable) e.preventDefault(); }; document.addEventListener('touchmove', handleMove, true); </script>
Or a less detailed, but ultimately the same result (credit by J. Griffiths):
<script> var handleMove = function (e) { if($(e.target).closest('.scrollable').length == 0) { e.preventDefault(); } } document.addEventListener('touchmove', handleMove, true); </script>
You must also include the following META tag.
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
Scott May 10 '12 at 17:39 2012-05-10 17:39
source share