1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
//function to be called whenever the window is scrolled or resized
function Move(){
var pos = $window.scrollTop(); //position of the scrollbar
//if the first section is in view...
if($firstBG.hasClass("inview")){
//call the newPos function and change the background position
$firstBG.css({'backgroundPosition': newPos(50, windowHeight, pos, 900, 0.3)});
}
//if the second section is in view...
if($secondBG.hasClass("inview")){
//call the newPos function and change the background position
$secondBG.css({'backgroundPosition': newPos(50, windowHeight, pos, 1250, 0.3)});
//call the newPos function and change the secnond background position
trainers.css({'backgroundPosition': newPos(50, windowHeight, pos, 1900, 0.6)});
}
//if the third section is in view...
if($thirdBG.hasClass("inview")){
//call the newPos function and change the background position
$thirdBG.css({'backgroundPosition': newPos(50, windowHeight, pos, 2850, 0.3)});
}
//if the fourth section is in view...
if($fourthBG.hasClass("inview")){
//call the newPos function and change the background position for CSS3 multiple backgrounds
$fourthBG.css({'backgroundPosition': newPos(0, windowHeight, pos, 200, 0.9) + ", " + newPos(50, windowHeight, pos, 0, 0.7) + ", " + newPos(50, windowHeight, pos, 0, 0.5) + ", " + newPos(50, windowHeight, pos, 700, 0.3)});
}
$('#pixels').html(pos); //display the number of pixels scrolled at the bottom of the page
} |
Partager