-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
58 lines (48 loc) · 2.19 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
// sidepanel
document.addEventListener('DOMContentLoaded', () => {
const menuButton = document.getElementById('menu-button');
const sidePanel = document.getElementById('side-panel');
const mainContent = document.getElementById('main-content');
const photoContent = document.getElementById('photo');
// Open/Close Side Panel on Menu Button Click
menuButton.addEventListener('click', (e) => {
sidePanel.classList.toggle('-translate-x-full'); // Toggle panel slide-in/out
// mainContent.classList.toggle('blur-lg'); // Toggle blur effect on main content
e.stopPropagation(); // Prevent click from propagating to the document
});
// Close Side Panel if Clicking on Main Content
mainContent.addEventListener('click', () => {
if (!sidePanel.classList.contains('-translate-x-full')) { // Only close if panel is open
sidePanel.classList.add('-translate-x-full'); // Close panel
mainContent.classList.remove('blur-lg'); // Remove blur effect from main content
}
});
photoContent.addEventListener('click', () => {
if (!sidePanel.classList.contains('-translate-x-full')) { // Only close if panel is open
sidePanel.classList.add('-translate-x-full'); // Close panel
photoContent.classList.remove('blur-lg');
}
});
});
//searchbar
const searchBtn = document.getElementById('search-btn');
const searchInput = document.getElementById('search-input');
// Toggle search bar visibility on hover
searchBtn.addEventListener('mouseenter', () => {
searchInput.classList.remove('hidden');
searchInput.classList.add('translate-x-0');
});
searchBtn.addEventListener('mouseleave', () => {
setTimeout(() => {
searchInput.classList.add('hidden');
}, 1000); // Delay hiding after leaving the button
});
// Handle search functionality (e.g., perform search operation on pressing Enter)
searchInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
const query = searchInput.value;
// Implement the search logic here
console.log('Searching for:', query);
searchInput.classList.add('hidden'); // Hide the input after search
}
});