-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjQuery-1.js
81 lines (71 loc) · 2.09 KB
/
jQuery-1.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
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
function paralaxBg(element) {
var p = {
scrollTop: $(window).scrollTop(),
windowHeight: $(window).height(),
contentTop: $(element).position().top,
contentHeight: $(element).height()
};
// determine scrollTop's bounds where content enters & exits the window
p.lowerBound = p.contentTop - p.windowHeight;
p.upperBound = p.contentTop + p.contentHeight;
// determine scrollTop's position percentage in relation to bounds
p.percent = 25+((p.scrollTop - p.lowerBound) / (p.upperBound - p.lowerBound) * 100) * 0.50;
$(element).css({
"background-position": "50% " + p.percent +"%"
});
}
function Move() {
paralaxBg('#bg1');
paralaxBg('#bg2');
paralaxBg('#bg3');
}
function scrolling(){
var scrollTop = $(window).scrollTop();
if( scrollTop > 300 ){
$('body').addClass('scrolling');
} else {
$('body').removeClass('scrolling');
}
}
$(document).ready(function(){
$('.scroll').click(function(){
var target = ($(this).attr('href') =='') ? $(this).data('href') : $(this).attr('href'),
offset = $(this).data('offset'),
speed = $(this).data('speed'),
offsetTop = $(target).offset().top,
totalScroll = offsetTop - offset;
$('body,html').animate({
scrollTop: totalScroll
}, speed);
return false;
});
$('[data-mixpanel-action]').click(function(){
var action = $(this).data('mixpanel-action');
mixpanel.track(action);
});
$(window).resize(function () {
Move();
});
$(window).bind('scroll', function () {
Move();
scrolling();
});
$('.destination').each(function(i) {
var position = $(this).position();
$(this).scrollspy({
min: position.top - 250,
max: position.top + $(this).height(),
onEnter: function(element, position) {
$(".top-bar a").removeClass('active')
$(".top-bar a[href='#"+element.id+"']").addClass('active');
},
onLeave: function(element, position) {
$(".top-bar a[href='#"+element.id+"']").removeClass('active');
}
});
});
$(document).foundation();
}); // end docready
$(window).load(function () {
$('#loading').fadeOut('slow');
});