-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (17 loc) · 799 Bytes
/
main.js
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
$(function(){
//cache the window object
var $window = $(window);
//paralax background effect
$('section[data-type="background"]').each(function(){
var $bgobj = $(this);
$(window).scroll(function(){
//scroll the background at var speed
// the yPos is a negative value bcz we're scrolling it up!
var yPos = -($window.scrollTop() / $bgobj.data('speed'));
//put together our final background position
var coords = '50%' + yPos + 'px';
//move the background
$bgobj.css({backgroundPosition: coords })
}); // end windows scroll
});
});