嗨,请有人指出我正确的方向,我需要传递height
到我的窗口滚动功能
$(window).scroll(function() {
var scrolled = $(window).scrollTop();
//Content
if(scrolled >= 0 && scrolled < 342) {
$('#intro h2, #intro .down').stop().animate({ opacity: 1 }, {queue: true, duration:250, easing:"easeOutQuad"});
} else if (scrolled >= 342 && scrolled < 560) {
$('#intro h2, #intro .down').stop().animate({ opacity: 0 }, {queue: true, duration:250, easing:"easeOutQuad"});
} else if (scrolled >= 560) {
$('#intro h2, #intro .down').stop().css({ opacity: 0 });
}
//Navigation
if(scrolled >= 0 && scrolled < 342) {
$('#header h1 a:link').stop().css({ width: 101 });
$('#header li .service').stop().css({ background: 'none', color: '#ccc'}, {queue: true, duration:50, easing:"easeOutQuad"});
} else if (scrolled >= 342 && scrolled < 560) {
$('#header h1 a:link').stop().css({ width: 42 });
$('#header li .service').stop().css({background: '#54C2D9', color: '#fff'}, {queue: true, duration:50, easing:"easeOutQuad"});
} else if (scrolled >= 560) {
$('#header h1 a:link ').stop().css({ width: 42 });
}
console.log(scrolled);
});
function jqUpdateSize(){
// Get the dimensions of the viewport
var height = $(window).height();
$('#intro').css({height: height});
console.log(height);// Display the height
};
$(document).ready(jqUpdateSize); // When the page first loads
$(window).resize(jqUpdateSize); // When the browser changes size