}
if(y<0&&(aboveY<(-(documentHeight-wapperHeight)))){//当滑动到最底部时候不能再网下滑动
// inner.style.top=-(documentHeight-wapperHeight)+"px";
$("#inner").animate({top:-(documentHeight-wapperHeight)},200);
aboveY=-(documentHeight-wapperHeight);
}
}//
document.getElementById("outer").addEventListener(‘touchstart’, touchStart,false);
document.getElementById("outer").addEventListener(‘touchmove’, touchMove,false);
document.getElementById("outer").addEventListener(‘touchend’, touchEnd,false);
</script>
</body>
</html>
上面是demo的完整代码,这次使用的jquery,因为用到了animate 可以让滑动到最上面和最下面有点弹性
下面是demo效果,你也可以将代码copy用手机访问看看,代码比较简陋只是实现了效果还没有考虑到兼容性和健壮性

原文:http://www.cnblogs.com/leinov/p/3707197.html









