-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathR-landing.js
185 lines (126 loc) · 4.94 KB
/
R-landing.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// remap jQuery to $
(function($){
//object for organizing code
var customApp = new Object;
$(window).resize(function(){
customApp.instagramBoxHeight();
});
$(document).ready(function(){
//fallback if javascript is disabled
if(!$('body').hasClass('mobile')){
$('.nojs').removeClass('nojs');
}
customApp.textureBackgrounds();
// customApp.sectionHoverColors();
//sliding in animated text on scroll in sections enter in number of text sections
customApp.animatedSections(3);
//fixing the boxHeights for the feed magnet section
customApp.instagramBoxHeight();
//replace instagram Logo
});//end document ready
customApp.instagramBoxHeight = function(){
if(!$('body').hasClass('mobile')){
boxHeight = function(){
var smallBoxWidth = $('#classic .feedBox.updateSmall').width();
var largeBoxWidth = $('#classic .feedBox.updateLarge').width();
$('#classic .feedBox.updateSmall').css('height', smallBoxWidth);
$('#classic .feedBox.updateLarge').css('height', largeBoxWidth);
$('#classic .feedMagnet').css('height', largeBoxWidth);
}
if($('#classic .feedBox.updateSmall').length > 0){
setTimeout(function(){
if($('#classic .feedBox.updateSmall').length > 0){
setTimeout(function(){
boxHeight();
}, 1000);
} else {
boxHeight();
}}, 1000);
} else{
boxHeight();
}
} //end if !body mobile class
}
customApp.textureBackgrounds = function(){
//changing the background color of the texture section from the data attribute hex color.
$('#classic .section').each(function(){
var textureColor = $(this).find('.texture').data('bgcolor');
var textColor = textureColor;
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
textureColor = hexToRgb(textureColor);
var red = textureColor.r;
var green = textureColor.g;
var blue = textureColor.b;
textureColor = "rgba(" + red +"," + green + "," + blue + ", .79)";
// alert(textureColor);
$texture = $(this).find('.texture-container');
if(textureColor){
$texture.find('h1').removeClass('nojs');
//change the background and the h1 color on the texture sections
$texture.css('background-color', textureColor);
$texture.find('h1').css('color', textColor);
}
});
}
customApp.sectionHoverColors = function(){
//change the text of the texture sections on hover
//needs the jquery.color.js to work
$('#classic .section').hover(function(){
$(this).find('.text-box h1').stop().removeAttr('style');
},function(){
var textureColor = $(this).find('.texture').data('bgcolor');
$(this).find('.text-box h1').stop().animate({color: textureColor}, 700);
});
}
customApp.animatedSections = function(numberofsections){
//animation on scroll disable if using a mobile device
var screenSize = $(window).width();
var ismobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
//add animate class if user is on a mobile/tablet device
// if(ismobile){
// $('.brain-wrapper, .sliding-text').addClass('animate');
// }
if (!ismobile){
if(!$('body').hasClass('mobile')){
// setting the variable for the animation for each section
var count = 0;
var pageHeight = $(document).height();
var windowHeight = $(window).height();
var bottomSection = $('.instagram-section').offset().top;
var currentScrollPosition = $(window).scrollTop();
bottomSection = bottomSection - ((windowHeight/4) * 3);
$(window).scroll(function(){
if(count < numberofsections){
//getting the height of the current window to set the animation at the proper scroll position
var windowHeight = $(window).height();
var currentScrollPosition = $(window).scrollTop();
//getting the scroll position of the next section
var sectionScroll = $('#classic .section').eq(count).offset().top;
//start the animation at the bottom 1/4th of the window on scroll
var animateStart = sectionScroll - ((windowHeight/5) * 4);
// currentScrollPosition = $(window).scrollTop();
if(currentScrollPosition >= animateStart){
$sectionToScroll = $('#classic .section').eq(count).find('.sliding-text');
//add the css class to animate
$sectionToScroll.closest('.section').find('.sliding-text').addClass('animate');
//change the count so the next section will animate
count += 1;
}
}
var pageHeight = $(document).height();
var windowHeight = $(window).height();
// var bottomSection = $('.brain-section').offset().top;
var currentScrollPosition = $(window).scrollTop();
bottomSection = bottomSection - ((windowHeight/4) * 3);
});//end window scroll
}//end screen size
} //end if is mobile
};
})(window.jQuery);