-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyScripts.js
More file actions
222 lines (172 loc) · 5 KB
/
myScripts.js
File metadata and controls
222 lines (172 loc) · 5 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
var mns = "main-nav-scrolled";
//var win_height = $(window).height();
//var nav_height = $(".main-nav").height();
//var win_width = $(window).width();
(function( $){
$.fn.header_adjust = function(){
var win_h = $(window).height();
var nav_h = $(".main-nav").height();
var win_w = $(window).width();
//true == nav means that nav does exsist(it's visible/should be) & therefore it's height should be taken into account
if (win_h - nav_h > 950 || win_h > 950){
this.height(950);
}
else if ( win_w > 430 ){
this.height(win_h - nav_h);
}
else{
this.height(win_h);
}
return this;
};
})(jQuery);
(function( $){
$.fn.content_adjust = function(){
var win_h = $(window).height();
var nav_h = $(".main-nav").height();
var win_w = $(window).width();
var head_h = $("header").height();
if (this.height() < win_h && $(".main-nav").is(":visible")){
this.height(win_h - nav_h);
}
else if(this.height() < win_h && win_w < 430){
this.height(win_h);
}
return this;
};
})(jQuery);
(function( $){
$.fn.header_fix = function(){
var head_size = ($(window).height())/3;
//fix up the header size to be 1/3 of the screen size and
//once it reaches 400px height it hides.
if ($(window).height()> 400){
if (!this.is(":visible")){
this.show();
}
this.height(head_size);
}
else{
this.hide();
}
return this;
};
})(jQuery);
$( window ).scroll(function() {
if(!$("header").is(":visible")){ /* when the header isnt visible, this happens on a proj page*/
$(".main-nav").addClass("main-nav-scrolled");
}
else if( $(this).scrollTop() > $('header').height() + $('.main-nav').height() && $(window).width() > 430){
$(".main-nav").addClass("main-nav-scrolled");
} else if($(window).width() > 430){
$(".main-nav").removeClass(mns);
}
//Here is where we take care of width 430: have the menu NOT stay when scrolling
else if($(window).width() <= 430){
//$(".main-nav").addClass("main-nav-scrolled"); //(Have it stay)
$(".main-nav").hide();
$(".cross").hide();
$(".hamburger").show();
}
else {
//$(".main-nav").removeClass(mns);
}
});
$(window).resize(function(){
if($(window).width() > 430){
//so the height of header is the size of the window even when resized :D
$(".cross").hide();
$(".hamburger").hide();
if($(".main-nav").is(":visible")){
//so the header doesn't get stuck ontop when resized(mns is fixed postion)
$(".main-nav").removeClass(mns);
}
$(".main-nav").show();
}
else {
if ($(".main-nav").is(":visible")&& !$(".hamburger").is(":visible")){
$(".main-nav").hide();
}
$(".cross").hide();
$(".hamburger").show();
}
});
$(window).ready(function(){
if($(window).width() > 430){
$(".cross").hide();
$(".hamburger").hide();
$(".main-nav").show();
}
else{
$(".cross").hide();
$(".main-nav").hide();
$(".hamburger").show();
}
$(document).on("click", ".hamburger", function(event){
$(".main-nav").slideToggle("slow", function() {
$(".main-nav").addClass("main-nav-scrolled");
$(".hamburger").hide();
$(".cross").show();
});
});
$(document).on("click", ".cross", function(event){
$(".main-nav").slideToggle("slow", function(){
$(".cross").hide();
$(".hamburger").show();
});
});
});
/*
################### Some Code for timeline
@author Chris Coyier
published: on march 27 3013
Code location: https://css-tricks.com/slide-in-as-you-scroll-down-boxes/
*/
(function($) {
/**
* Copyright 2012, Digital Fusion
* Licensed under the MIT license.
* http://teamdf.com/jquery-plugins/license/
*
* @author Sam Sehnert
* @desc A small plugin that checks whether elements are within
* the user visible viewport of a web browser.
* only accounts for vertical position, not horizontal.
*/
$.fn.visible = function(partial) {
var $t = $(this),
$w = $(window),
viewTop = $w.scrollTop(),
viewBottom = viewTop + $w.height(),
_top = $t.offset().top,
_bottom = _top + $t.height(),
compareTop = partial === true ? _bottom : _top,
compareBottom = partial === true ? _top : _bottom;
return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
};
})(jQuery);
$(window).scroll(function(event) {
$(".timeline-item").each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass("come-in");
}
});
});
var win = $(window);
var allMods = $(".timeline-item");
// Already visible modules
allMods.each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass("already-visible");
}
});
win.scroll(function(event) {
allMods.each(function(i, el) {
var el = $(el);
if (el.visible(true)) {
el.addClass("come-in");
}
});
});