-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
166 lines (145 loc) · 4.12 KB
/
Copy pathscript.js
File metadata and controls
166 lines (145 loc) · 4.12 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
// close responsive menu after click event
$('.navbar-collapse ul li a').click(function(){
$('.navbar-toggle:visible').click();
});
$(function () {
$(document).scroll(function () {
var $nav = $(".navbar-fixed-top");
var blackHeight = $(".img-container").height() + $("#about").height();
$nav.toggleClass('scrolled', $(this).scrollTop() > blackHeight); //$nav.height());
});
});
// contact form -> send message and display thank you alert
var message = "";
$("#sendMessage").on("click", function() {
message = $("#contactform").serialize();
$.ajax({
url: "//formspree.io/dynamicrealities@gmail.com",
method: "POST",
data: {message: message},
dataType: "json"
});
alert('Thanks for the email, we\'ll be in touch promptly.');
return false;
});
// --- typewriter effect for about section
// --- called in document.ready()
// --- adding different code colors
function getColor(fldName, i, character) {
const codeColor = {
codeGreen: '#96B382',
codeWhite: '#fff',
codeYellow: '#D0B95F',
codeBlue: '#759BBC',
codePurple: '#807591'
}
let newColor = codeColor.codeGreen;
const tempString = "=;.{}:";
if (tempString.includes(character)) {
newColor = codeColor.codeWhite;
return newColor;
};
if (i<5 && fldName != '#text1'){
newColor = codeColor.codeYellow;
return newColor;
}
switch (fldName) {
case "#text1":
if (i<3) {
newColor = codeColor.codeYellow;
} else if (i<9){
newColor = codeColor.codeBlue;
} else if ((i>12 && i<22) || (i>31 && i<40)){
newColor = codeColor.codePurple;
}
break;
case "#text2":
if (i<8) {
newColor = codeColor.codePurple;
}
break;
case "#text3":
if (i<12) {
newColor = codeColor.codePurple;
}
break;
case "#text4":
if (i<11) {
newColor = codeColor.codePurple;
}
break;
case "#text5":
if (i<15) {
newColor = codeColor.codePurple;
}
break;
}
return newColor;
}
let totalCount = 0;
function typeText(fldName) {
let content = $(fldName).text();
$(fldName).text('');
var ele = '<span>' + content.split('').join('</span><span>') + '</span>';
var eleColor = 'white';
$(ele).hide().appendTo(fldName).each(function (i) {
eleColor = getColor(fldName, i, this.innerHTML);
$(this).delay(40 * totalCount).css({
color: eleColor,
display: 'inline',
opacity: 0
}).animate({
opacity: 1
}, 100);
totalCount++;
});
};
$(document).ready(function(){
// ---typewriter effect for about section
// ---animate in loop
function looping() {
typeText('#text1');
typeText('#text2');
typeText('#text3');
typeText('#text4');
typeText('#text5');
setTimeout(function(){
looping();
}, 30000);
// reset totalCount before next loop
totalCount = 0;
}
looping();
// ----Add smooth scrolling to all links
$("a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
} // End if
});
// ===== Scroll to Top ====
$(window).scroll(function() {
if ($(this).scrollTop() >= 100) { // If page is scrolled more than 100px
$('#scroll-top').fadeIn(200); // Fade in the arrow
} else {
$('#scroll-top').fadeOut(200); // Else fade out the arrow
}
});
$('#scroll-top').click(function() { // When arrow is clicked
$('body,html').animate({
scrollTop : 0 // Scroll to top of body
}, 500);
return false;
});
});