window scroll function var document height 1873 big false if big true

 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
$(window).scroll(function(){
var N=$(document).height()/1873;
big=false;
if(N>2){
big=true;
var K=N;
}else{
var K=2
}
if(!big){
var t=$("body").scrollTop()/K;
$("body").css('background-position', '50% '+ t + "px");
}else{
var d=$(document).height()-1873;
var maxScroll=$('body')[0].scrollHeight-$(window).height();
var _cf=d/maxScroll;
var t=document.body.scrollTop*_cf;
$("body").css('background-position', '50% '+ t + "px");
}
});