我正在使用下面的代码来隐藏滚动上的导航栏,但它似乎在我正在测试的iPad上不起作用。
jQuery(document).ready(function($) {
var previousScroll = 0,
headerOrgOffset = $('.hide-nav').height();
$('.sq-header-nav').height($('.hide-nav').height());
$(window).scroll(function () {
var currentScroll = $(this).scrollTop();
if (currentScroll > headerOrgOffset) {
if (currentScroll > previousScroll) {
$('.sq-header-nav').slideUp();
} else {
$('.sq-header-nav').slideDown();
}
}
previousScroll = currentScroll;
});
});发布于 2013-12-27 21:08:27
IOS使用onscroll事件
document.onscroll = function scroll() {
// on scroll
}发布于 2013-12-27 22:21:46
请参阅Safari Developer Library Handling Events。在iOS上,onscroll事件不会在滚动时触发,而是在用户停止平移(一根或两根手指)且页面停止移动后触发。
您可以在使用touchmove事件滚动时处理:
document.addEventListener('touchmove', function() {/*handleMove*/}, false);参考:。
https://stackoverflow.com/questions/20801156
复制相似问题