-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
218 lines (180 loc) · 5.13 KB
/
app.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
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
/**GSAP animations */
var tl = gsap.timeline()
tl.to(".brand", {
y: 20,
opacity:1,
duration: 1.2,
delay: 1,
})
tl.to(".nav-item a", {
y: -40,
opacity: 1,
// stagger: 0.5,
duration: 1.2,
});
/**Typing */
document.addEventListener("DOMContentLoaded", function () {
var options = {
strings: ["a MERN Stack Developer", "an Explorer", "a Tech-Savvy", "an Astrophile🌙"],
typeSpeed: 50,
backSpeed: 25,
loop: true
};
var typed = new Typed("#typing", options);
});
/*Project-slider */
const carousel = document.querySelector('.carousel');
let isDown = false;
let startX;
let scrollLeft;
carousel.addEventListener('mousedown', (e) => {
isDown = true;
startX = e.pageX - carousel.offsetLeft;
scrollLeft = carousel.scrollLeft;
});
carousel.addEventListener('mouseleave', () => {
isDown = false;
});
carousel.addEventListener('mouseup', () => {
isDown = false;
});
carousel.addEventListener('mousemove', (e) => {
if (!isDown) return;
e.preventDefault();
const x = e.pageX - carousel.offsetLeft;
const walk = (x - startX) * 2;
carousel.scrollLeft = scrollLeft - walk;
});
/*dark mode */
// const btn = document.querySelector(".dark");
// const nav = document.querySelector(".navbar");
// const navItem = document.getElementsByClassName("nav-link");
// btn.addEventListener("click", () => {
// const displaypage = document.querySelector("body");
// nav.style.backgroundColor = "#fff";
// displaypage.style.backgroundColor = "#fff";
// displaypage.style.color = "#000";
// });
// const hamburger = document.querySelector(".hamburger");
// hamburger.addEventListener("click", () => {
// for (nav of navItem) {
// if (nav.style.display != "inline") {
// info.style.display = "inline";
// } else {
// nav.style.display = "none";
// }
// }
// });
// $(document).ready(function () {
// $(window).scroll(function () {
// // sticky navbar on scroll script //
// if (this.scrollY > 20) {
// $(".navbar").addClass("sticky");
// } else {
// $(".navbar").removeClass("sticky");
// }
// // scroll-up button show/hide script //
// if (this.scrollY > 500) {
// $(".scroll-up-btn").addClass("show");
// } else {
// $(".scroll-up-btn").removeClass("show");
// }
// });
// // slide-up script //
// $(".scroll-up-btn").click(function () {
// $("html").animate({ scrollTop: 0 });
// // removing smooth scroll on slide-up button click //
// $("html").css("scrollBehavior", "auto");
// });
// $(".navbar .menu li a").click(function () {
// // Smooth scroll on Menu Items click //
// $("html").css("scrollBehavior", "smooth");
// });
// // Toggle Navbar //
// $(".menu-btn").click(function () {
// $(".navbar .menu").toggleClass("active");
// $(".menu-btn i").toggleClass("active");
// });
// // Typing Text Animation //
// var typed = new Typed("#typing", {
// strings: [
// "Full Stack Web Developer",
// "Programmer",
// "Tech-Savvy",
// "Astrophile",
// "Coder",
// ],
// typeSpeed: 100,
// backSpeed: 60,
// loop: true,
// });
// // Owl Carousel //
// $(".carousel").owlCarousel({
// margin: 20,
// loop: true,
// autoplay: true,
// autoplayTimeOut: 2000,
// autoplayHoverPause: true,
// responsive: {
// 0: {
// items: 1,
// nav: false,
// },
// 600: {
// items: 2,
// nav: false,
// },
// 1000: {
// items: 3,
// nav: false,
// },
// 2000: {
// items: 4,
// nav: false,
// },
// },
// });
// });
/*contact form */
const msgbtn = document.querySelector("#contact-btn");
msgbtn.addEventListener('click', (e)=>{
e.preventDefault();
const name = document.querySelector("#name").value.trim();
const email = document.querySelector("#email").value.trim();
const msg = document.querySelector("#msg").value.trim();
let formData={
username: name,
email: email,
message: msg,
}
if(formData.username !== "" && formData.email !== "" && formData.message !== ""){
emailjs.send('service_k6r5bm9', 'template_5zvwmti', formData)
.then(function(response) {
alert('Email sent successfully! Will Catch up to you soon!', response.status, response.text);
document.querySelector("#name").value = '';
document.querySelector("#email").value = '';
document.querySelector("#msg").value = '';
}, function(error) {
alert('Failed to send email. Please try again later.', error);
});
}
else {
alert('Please fill out all fields before submitting.');
}
})
const shareData = {
title: "MDN",
text: "Learn web development on MDN!",
url: "https://developer.mozilla.org",
};
const butn = document.querySelector("buttons");
const resultPara = document.querySelector(".result");
// Share must be triggered by "user activation"
// butn.addEventListener("click", async () => {
// try {
// await navigator.share(shareData);
// resultPara.textContent = "MDN shared successfully";
// } catch (err) {
// resultPara.textContent = `Error: ${err}`;
// }
// });