有一些js
$(document).ready(function(){
var winHeight = window.innerHeight ?
function() {
return window.innerHeight;
} :
function() {
return document.documentElement.clientHeight;
};
$('.first-block').height(winHeight);
$(window).scroll(function(){
var firstBlockHeight = winHeight();
var scrollTop= $('body').scrollTop();
if (scrollTop > 0 && scrollTop < firstBlockHeight/2 && $('body').hasClass('scrolled') === false) {
$("body")
.animate({ scrollTop: firstBlockHeight+10 }, 600)
.addClass('scrolled');
} else if (scrollTop==0) {
$("body")
.animate({ scrollTop: 0 }, 600)
.removeClass('scrolled');
}
});
});
通过单个鼠标滚轮滚动第一个块100%的高度。这段代码不能在firefox中工作。如果玩滚动也会有bug。请帮助解决这个问题,并添加跨浏览器支持。请参阅JsFiddle
谢谢。
我使用mouswheel.js,我做到了!:)可能对某人有用
$(document).ready(function(){
var winHeight = window.innerHeight ?
function() {
return window.innerHeight;
} :
function() {
return document.documentElement.clientHeight;
};
$('.first-block').height(winHeight);
var BlockHeight = $('.first-block').height();
$.browser = {};
$.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
if($.browser.mozilla)
{
var ScrollType = 'html';
}
else
{
var ScrollType = 'body';
}
$('.first-block').mousewheel(function(event, delta, deltaX, deltaY) {
if((delta<0) && ($(ScrollType).scrollTop()==0)) $(ScrollType).animate({ scrollTop: BlockHeight- 104 }, 600);
});
$(ScrollType).keydown(function(event){
if((event.keyCode==40) && ($(ScrollType).scrollTop()==0)) $(ScrollType).animate({ scrollTop: BlockHeight-104 }, 600);
})
});
谢谢我)