-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
157 lines (132 loc) · 4.31 KB
/
script.js
File metadata and controls
157 lines (132 loc) · 4.31 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
$(document).ready(function () {
// Mobile menu toggle
$("#mobile-menu").click(function () {
$(".nav-links").toggleClass("active");
});
// Navbar scroll effect
$(window).scroll(function () {
if ($(window).scrollTop() > 50) {
$("#navbar").addClass("scrolled");
} else {
$("#navbar").removeClass("scrolled");
}
// Update active nav link
let scrollPos = $(window).scrollTop() + 100;
$(".nav-links a").each(function () {
let href = $(this).attr("href");
if (href.startsWith("#")) {
let section = $(href);
if (section.length) {
let sectionTop = section.offset().top;
let sectionBottom = sectionTop + section.outerHeight();
if (scrollPos >= sectionTop && scrollPos < sectionBottom) {
$(".nav-links a").removeClass("active");
$(this).addClass("active");
}
}
}
});
// Fade in animation
$(".fade-in").each(function () {
let elementTop = $(this).offset().top;
let windowBottom = $(window).scrollTop() + $(window).height() - 100;
if (elementTop < windowBottom) {
$(this).addClass("visible");
}
});
// Scroll progress indicator
const scrollTop = $(window).scrollTop();
const docHeight = $(document).height() - $(window).height();
const scrollPercent = (scrollTop / docHeight) * 100;
$(".scroll-progress").css("width", scrollPercent + "%");
});
// Smooth scrolling
$('a[href^="#"]').on("click", function (e) {
e.preventDefault();
let target = this.hash;
let $target = $(target);
if ($target.length) {
$("html, body").animate(
{
scrollTop: $target.offset().top - 80,
},
600,
"swing"
);
}
});
// Create floating particles
function createParticles() {
const particlesContainer = $(".particles");
const particleCount = 50;
for (let i = 0; i < particleCount; i++) {
const particle = $('<div class="particle"></div>');
particle.css({
left: Math.random() * 100 + "%",
top: Math.random() * 100 + "%",
animationDelay: Math.random() * 6 + "s",
animationDuration: Math.random() * 3 + 3 + "s",
});
particlesContainer.append(particle);
}
}
// Initialize particles
createParticles();
// Contact form submission
// $("form").on("submit", function (e) {
// e.preventDefault();
// // Get form data
// const formData = {
// name: $('input[name="name"]').val(),
// email: $('input[name="email"]').val(),
// subject: $('input[name="subject"]').val(),
// message: $('textarea[name="message"]').val(),
// };
// // Simple validation
// if (!formData.name || !formData.email || !formData.message) {
// alert("Please fill in all required fields.");
// return;
// }
// // Simulate form submission
// const submitBtn = $(this).find('button[type="submit"]');
// const originalText = submitBtn.text();
// submitBtn.text("Sending...").prop("disabled", true);
// // Simulate API call
// setTimeout(() => {
// alert("Thank you for your message! I'll get back to you soon.");
// this.reset();
// submitBtn.text(originalText).prop("disabled", false);
// }, 2000);
// });
// Trigger initial fade-in animation
setTimeout(() => {
$(".fade-in").each(function () {
let elementTop = $(this).offset().top;
let windowBottom = $(window).scrollTop() + $(window).height();
if (elementTop < windowBottom) {
$(this).addClass("visible");
}
});
}, 100);
// Add typing effect to hero title
function typeWriter(element, text, speed = 100) {
let i = 0;
element.text("");
function type() {
if (i < text.length) {
element.text(element.text() + text.charAt(i));
i++;
setTimeout(type, speed);
}
}
type();
}
// Initialize typing effect after a short delay
setTimeout(() => {
typeWriter($(".hero-title"), "Rithin Lehan", 150);
}, 1000);
// Add scroll progress indicator
$("body").prepend(
'<div class="scroll-indicator"><div class="scroll-progress"></div></div>'
);
});