-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
27 lines (22 loc) · 883 Bytes
/
scripts.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
function changePageTitle(newtitle) {
document.title = newtitle + " - Souple";
}
const interactiveButtons = document.querySelectorAll('.interactiveButtons img');
// Function to swap image on hover
function swapImageOnHover(imageElement, hoverImagePath) {
imageElement.addEventListener('mouseover', () => {
imageElement.src = hoverImagePath;
});
imageElement.addEventListener('mouseout', () => {
imageElement.src = imageElement.dataset.originalSrc; // Restore original image on mouseout
});
}
// Loop through nav buttons and attach hover event listeners
interactiveButtons.forEach(button => {
const originalSrc = button.src;
const hoverImagePath = originalSrc.replace('.png', '-hovered.png');
// Construct hover image path
button.dataset.originalSrc = originalSrc;
// Store original source for restoration
swapImageOnHover(button, hoverImagePath);
});