使用IScroll,通过$(window).scrollTop()获取到的值一直为0
$(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);
}
})