-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvptest.html
More file actions
82 lines (73 loc) · 1.77 KB
/
vptest.html
File metadata and controls
82 lines (73 loc) · 1.77 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Simple Vertical Paralax</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.ba-throttle-debounce.min.js"></script>
<script>
$(document).ready(function () {
//hardcoded sizes of top and bottom, matching the css for #top and #bottom
var topHeight = (2800);
var bottomHeight = (1200);
$(window).scroll($.throttle(60, moveMe));
$(window).resize($.debounce(1000 , moveMe));
function moveMe() {
var windowHeight = $(window).height();
var winPos = $(window).scrollTop();
var maxScroll = (topHeight - windowHeight);
var delta = ((windowHeight - bottomHeight));
var bottomCalculation = ((winPos / maxScroll) * delta);
//bottomCalculation = (bottomCalculation ) - ((bottomCalculation )*2);
/*console.log("winPos:"+winPos);
console.log(winPos+"//"+Math.round(winPos) );
console.log(bottomCalculation);*/
$('#bottom').stop().animate({
top: bottomCalculation
}, {
duration: 60,
specialEasing: {
top: 'linear'
}
});
};
});
</script>
<style>
body {
text-align:center;
margin-top:0;
margin-bottom:0;
}
#outer {
width:900px;
margin-left:auto;
margin-right:auto;
position:relative;
}
#top {
position:absolute;
z-index:2;
width:100%;
height:2800px;
background-image:url(2800.png);
background-repeat:no-repeat;
}
#bottom {
position:fixed;
z-index:1;
width:100%;
height:1200px;
background-image:url(1200.png);
background-repeat:no-repeat;
background-color:#F3DFA3;
}
</style>
</head>
<body>
<div id="outer">
<div id="top"></div>
<div id="bottom"></div>
</div>
</body>
</html>