-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
49 lines (42 loc) · 1.77 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
document.addEventListener('DOMContentLoaded', function () {
const backToTopButton = document.getElementById('backToTop');
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', function () {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
backToTopButton.classList.add('show');
navbar.classList.add('transparent');
} else {
backToTopButton.classList.remove('show');
navbar.classList.remove('transparent');
}
});
backToTopButton.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
const navLinks = document.querySelectorAll('.navbar a');
navLinks.forEach(link => {
link.addEventListener('click', function (e) {
e.preventDefault(); // Prevent default anchor click behavior
const targetId = this.getAttribute('href'); // Get the target section ID
const targetSection = document.querySelector(targetId); // Select the target section
// Scroll to the target section smoothly
targetSection.scrollIntoView({
behavior: 'smooth'
});
});
});
const skills = document.querySelectorAll('.skills li');
skills.forEach(skill => {
skill.addEventListener('click', function () {
const description = this.querySelector('.skill-description');
const isVisible = description.style.display === 'block';
document.querySelectorAll('.skill-description').forEach(desc => {
desc.style.display = 'none';
});
description.style.display = isVisible ? 'none' : 'block';
});
});
});