-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlearnpage.js
52 lines (42 loc) · 1.58 KB
/
learnpage.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
// Shrink effect of the navbar
document.addEventListener('DOMContentLoaded', function () {
var header = document.getElementById('header');
window.onscroll = function () {
// Add or remove the "shrink" class based on scroll position
if (window.pageYOffset > 50) {
header.classList.add('shrink');
} else {
header.classList.remove('shrink');
}
};
});
distance.oninput = e => {
wrap.style.setProperty('--distance', e.target.value + '%')
}
thickness.oninput = e => {
wrap.style.setProperty('--border', e.target.value + 'px')
}
function toggleNavItems() {
const navItems = document.getElementById('nav-items');
navItems.classList.toggle('nav-show');
}
//-----------------------------------------------------------------------------------------
// Image slider
document.addEventListener('DOMContentLoaded', function () {
const gallery = document.querySelector('.gallery');
const images = document.querySelectorAll('.gallery img');
let counter = 1;
const slideWidth = images[0].clientWidth;
setInterval(() => {
gallery.style.transition = 'transform 0.5s ease-in-out';
gallery.style.transform = `translateX(${-counter * slideWidth}px)`;
counter++;
if (counter === images.length - 1) {
counter = 1;
setTimeout(() => {
gallery.style.transition = 'none';
gallery.style.transform = 'translateX(0)';
}, 500);
}
}, 3000); // Adjust the interval as needed
});