-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallax.js
101 lines (75 loc) · 2.25 KB
/
parallax.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Parallax Scrolling
* Created by C-Pres
* c-pr.es
*
* Originally for http://www.thedreamfly.org
*/
jQuery(document).ready(function ($) {
var glxy_site = 'http://example.com';
var GlxyParallax = {
enableScroll: function (options) {
// Cache the Window object
$window = $(window);
$('div[data-type="' + options.dtype + '"]').each(function () {
var $bgobj = $(this); // assigning the object
$window.scroll(function () {
/* Scroll the background at var speed
the yPos is a negative value because we're scrolling it UP! */
var yPos = -($window.scrollTop() / $bgobj.data('speed'));
// Put together our final background position
var coords = options.speed + '% ' + yPos + 'px';
// Move the background
$bgobj.css({
backgroundPosition: coords
});
}); // window scroll Ends
});
resetHeight = function (className, hght) {
if (this.document.hasClass(className)) {
yPos = yPos - hght;
}
}
},
// Header uses this
scrollHere: function (location) {
if (location) {
if ($(location).length == 0) { // no element found)
window.location = glxy_site +'?l='+ location;
}
$('html, body').animate({
scrollTop: $(location).offset().top
}, 1000)
}
},
setupHeader: function (navigation) {
for (var elem in navigation) {
$("a[title='"+ elem +"']").on("click", function() {
GlxyParallax.scrollHere(navigation[this.title])
})
}
}
};
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
} else {
GlxyParallax.enableScroll({
// data-type of element
'dtype': 'background',
'speed': 50
});
}
headerLinks = {
'our-dream': '#post-6',
'our-dreamers': '#post-8',
'around-the-world': '#post-19',
'get-involved': '#post-69',
'our-dream-makers': '#post-64',
'in-the-news': '#post-51'
}
GlxyParallax.setupHeader(headerLinks);
});
/*
* Create HTML5 elements for IE's sake
*/
document.createElement("article");
document.createElement("section");