-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
151 lines (118 loc) · 4.82 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
document.addEventListener("DOMContentLoaded", function() {
// Hide the loader after the page has fully loaded
const loader = document.querySelector('.loader');
if (loader) {
window.addEventListener('load', function() {
loader.style.display = 'none';
});
}
// Dark theme toggle logic
const themeToggle = document.querySelector('.theme-toggle');
themeToggle.addEventListener('click', function() {
document.body.classList.toggle('dark-mode');
});
// Scroll down logic
const scrollDownButton = document.querySelector('.scroll-down');
if (scrollDownButton) {
scrollDownButton.addEventListener('click', function() {
window.scrollTo({
top: window.innerHeight,
behavior: 'smooth'
});
});
}
// Burger menu toggle logic
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', function() {
navLinks.classList.toggle('open');
hamburger.classList.toggle('toggle');
});
const toastContainer = document.getElementById('toast-container');
// Function to create and show a toast
function showToast() {
// Create toast elements
const toast = document.createElement('div');
toast.className = 'toast';
const toastBorder = document.createElement('div');
toastBorder.className = 'toast-border';
const toastContent = document.createElement('div');
toastContent.className = 'toast-content';
const toastHeader = document.createElement('div');
toastHeader.className = 'toast-header';
const toastTitle = document.createElement('h3');
toastTitle.className = 'toast-title';
toastTitle.textContent = 'Why this website Looks So Basic?';
const toastClose = document.createElement('div');
toastClose.className = 'toast-close';
toastClose.textContent = '×';
const toastMessage = document.createElement('p');
toastMessage.className = 'toast-message';
toastMessage.innerHTML = 'Whenever I learn something new, I feel like rebuilding my portfolio with it. Keeping it simple HTML just doesn\'t feel right <span class="emoji-icon">😄</span>';
const toastProgress = document.createElement('div');
toastProgress.className = 'toast-progress';
// Assemble the toast
toastHeader.appendChild(toastTitle);
toastHeader.appendChild(toastClose);
toastContent.appendChild(toastHeader);
toastContent.appendChild(toastMessage);
toast.appendChild(toastBorder);
toast.appendChild(toastContent);
toast.appendChild(toastProgress);
// Add toast to container
toastContainer.appendChild(toast);
// Show with animation
setTimeout(() => {
toast.classList.add('show');
}, 10);
// Animate progress bar
toastProgress.animate(
[
{ transform: 'scaleX(1)' },
{ transform: 'scaleX(0)' }
],
{
duration: 5000,
easing: 'linear',
fill: 'forwards'
}
);
// Auto dismiss after 5 seconds
const dismissTimeout = setTimeout(() => {
dismissToast(toast);
}, 5000);
// Close button event
toastClose.addEventListener('click', () => {
clearTimeout(dismissTimeout);
dismissToast(toast);
});
// Function to dismiss toast
function dismissToast(toastElement) {
toastElement.classList.remove('show');
setTimeout(() => {
toastContainer.removeChild(toastElement);
}, 400);
}
}
setTimeout(showToast, 1000);
});
// Create floating particles
function createParticles() {
const container = document.getElementById('particles');
const colors = ['#6366f1', '#a855f7', '#ec4899', '#f0abfc', '#c4b5fd'];
for (let i = 0; i < 20; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
const size = Math.random() * 40 + 10;
const color = colors[Math.floor(Math.random() * colors.length)];
particle.style.width = `${size}px`;
particle.style.height = `${size}px`;
particle.style.background = color;
particle.style.opacity = Math.random() * 0.1 + 0.05;
particle.style.left = `${Math.random() * 100}%`;
particle.style.top = `${Math.random() * 100}%`;
particle.style.animationDelay = `${Math.random() * 5}s`;
particle.style.animationDuration = `${Math.random() * 20 + 10}s`;
container.appendChild(particle);
}
}