使用IScroll,通过$(window).scrollTop()获取到的值一直为0

xuhuaiguang123 2015-08-27 10:41:04
$(function(){
if(navigator.userAgent.match('CriOS')){
// Wrap content in iScroll elements
$( 'body' ).wrap( '<div id="wrapper" style="background-color:red"><div id="scroller"></div></div>' );
// Start iScroll
myScroll = new IScroll('#wrapper', {
mouseWheel: true,
scrollbars: true
});

// Prevent default scroll
document.addEventListener('touchmove', function (e) {
var wrapper=document.getElementById("wrapper");
//alert($(window)..scrollTop); 此处获取的值在ios上一直是0
if( $(window).scrollTop() > 0 ){
$('nav').addClass('_translucent');
} else if( $('#menu > ul').css('display') == 'none' || window.innerWidth > 992 ) {
// Remove ._translucent if Menu List is hidden or on 992px & up devices.
$('nav').removeClass('_translucent');
}
}, false);


}
})
...全文
374 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧