-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
167 lines (130 loc) · 4.08 KB
/
script.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
$(document).ready(function(){
$('#menu').click(function(){
$(this).toggleClass('fa-times');
$('.navbar').toggleClass('nav-toggle');
});
$(window).on('scroll load',function(){
$('#menu').removeClass('fa-times');
$('.navbar').removeClass('nav-toggle');
if(window.scrollY>60){
document.querySelector('#scroll-top').classList.add('active');
}else{
document.querySelector('#scroll-top').classList.remove('active');
}
// scroll spy
$('section').each(function(){
let height = $(this).height();
let offset = $(this).offset().top - 200;
let top = $(window).scrollTop();
let id = $(this).attr('id');
if(top>offset && top<offset+height){
$('.navbar ul li a').removeClass('active');
$('.navbar').find(`[href="#${id}"]`).addClass('active');
}
});
});
// smooth scrolling
$('a[href*="#"]').on('click',function(e){
e.preventDefault();
$('html, body').animate({
scrollTop : $($(this).attr('href')).offset().top,
},500, 'linear')
})
});
document.addEventListener('visibilitychange',
function(){
if(document.visibilityState === "visible"){
document.title = "Portfolio | Mahi Mittal";
$("#favicon").attr("href","mahi.jpg");
}
else {
document.title = "Come Back To Portfolio";
}
});
// <!-- typed js effect starts -->
var typed = new Typed(".typing-text", {
strings: ["AI-ML ","Web development", "Competitive Programming"],
loop: true,
typeSpeed: 50,
backSpeed: 25,
backDelay: 500,
});
// <!-- typed js effect ends -->
// <!-- tilt js effect starts -->
VanillaTilt.init(document.querySelectorAll(".tilt"), {
max: 15,
});
// <!-- tilt js effect ends -->
// <!-- emailjs to mail contact form data -->
$("#contact-form").submit(function (event) {
//event.preventdefault();
event.preventDefault();
console.log("form submitted");
.then(function (response) {
console.log('SUCCESS!', response.status, response.text);
document.getElementById("contact-form").reset();
alert("Form Submitted Successfully");
}, function (error) {
console.log('FAILED...', error);
alert("Form Submission Failed! Try Again");
});
});
/* ===== SCROLL REVEAL ANIMATION ===== */
const srtop = ScrollReveal({
origin: 'top',
distance: '80px',
duration: 1000,
reset: true
});
async function fetchData(type = "skills") {
let response
type === "skills" ?
response = await fetch("skills.json")
:
response = await fetch("./projects/projects.json")
const data = await response.json();
return data;
}
function showSkills(skills) {
let skillsContainer = document.getElementById("skillsContainer");
let skillHTML = "";
skills.forEach(skill => {
skillHTML += `
<div class="bar">
<div class="info">
<img src=${skill.icon} alt="skill" />
<span>${skill.name}</span>
</div>
</div>`
});
skillsContainer.innerHTML = skillHTML;
}
fetchData().then(data => {
showSkills(data);
});
/* SCROLL HOME */
srtop.reveal('.home .content h3',{delay: 200});
srtop.reveal('.home .content p',{delay: 200});
srtop.reveal('.home .content .btn',{delay: 200});
srtop.reveal('.home .image',{delay: 400});
srtop.reveal('.home .linkedin',{interval: 600});
srtop.reveal('.home .github',{interval: 800});
srtop.reveal('.home .twitter',{interval: 1000});
srtop.reveal('.home .telegram',{interval: 600});
srtop.reveal('.home .instagram',{interval: 600});
/* SCROLL ABOUT */
srtop.reveal('.about .content h3',{delay: 300});
srtop.reveal('.about .content .tag',{delay: 400});
srtop.reveal('.about .content p',{delay: 300});
srtop.reveal('.about .content .box-container',{delay: 300});
srtop.reveal('.about .content .resumebtn',{delay: 300});
/* SCROLL EDUCATION */
srtop.reveal('.education .box',{interval: 200});
/* SCROLL PROJECTS */
srtop.reveal('.work .box',{interval: 200});
/* SCROLL EXPERIENCE */
srtop.reveal('.experience .timeline',{delay: 400});
srtop.reveal('.experience .timeline .container',{interval: 400});
/* SCROLL CONTACT */
srtop.reveal('.contact .container',{delay: 400});
srtop.reveal('.contact .container .form-group',{delay: 400});