mirror of
https://github.com/manilarome/the-glorious-startpage.git
synced 2024-11-24 00:23:39 +01:00
toggle searchbox
This commit is contained in:
parent
c951d082fd
commit
bcbaabbe6c
@ -25,12 +25,11 @@
|
||||
transform: translate(-50%, -50%);
|
||||
transition: opacity var(--transition-speed),
|
||||
top var(--transition-speed),
|
||||
visibility var(--transition-speed),
|
||||
pointer-events var(--transition-speed) ;
|
||||
pointer-events var(--transition-speed);
|
||||
}
|
||||
|
||||
#searchBox.show {
|
||||
opacity: 1;
|
||||
top: 100%;
|
||||
pointer-events: initial;
|
||||
.showSearchBox {
|
||||
opacity: 1 !important;
|
||||
top: 100% !important;
|
||||
pointer-events: initial !important;
|
||||
}
|
||||
|
@ -59,5 +59,6 @@
|
||||
<script src="js/sites-list.js"></script>
|
||||
<script src="js/dock-buttons.js"></script>
|
||||
<script src="js/animate-profile-image.js"></script>
|
||||
<script src="js/show-search-box.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -33,5 +33,11 @@ profileContainer.addEventListener(
|
||||
|
||||
// Animate/Show searchbox if profile container was clicked
|
||||
profileContainer.onclick = () => {
|
||||
rotateProfile();
|
||||
if (profileAnimRunning) return;
|
||||
|
||||
// Rotate profile
|
||||
// rotateProfile();
|
||||
|
||||
// Toggle search box
|
||||
toggleSearchBox();
|
||||
};
|
||||
|
39
js/show-search-box.js
Normal file
39
js/show-search-box.js
Normal file
@ -0,0 +1,39 @@
|
||||
var searchBox = document.getElementById('searchBox');
|
||||
|
||||
let searchBoxVisility = false;
|
||||
|
||||
const showSearchBox = () => {
|
||||
searchBox.classList.add('showSearchBox');
|
||||
|
||||
// Focus
|
||||
searchBox.focus();
|
||||
|
||||
searchBoxVisility = !searchBoxVisility;
|
||||
}
|
||||
|
||||
const hideSearchBox = () => {
|
||||
searchBox.classList.remove('showSearchBox');
|
||||
|
||||
searchBoxVisility = !searchBoxVisility;
|
||||
}
|
||||
|
||||
const toggleSearchBox = () => {
|
||||
|
||||
// If profile anim is still running,
|
||||
// Return to avoid spam
|
||||
if (profileAnimRunning) return;
|
||||
|
||||
// Rotate profile
|
||||
rotateProfile();
|
||||
|
||||
if (searchBoxVisility) {
|
||||
// Hide search box
|
||||
hideSearchBox();
|
||||
|
||||
} else {
|
||||
// Show search box
|
||||
showSearchBox();
|
||||
}
|
||||
|
||||
console.log('toggle searchbox');
|
||||
}
|
Loading…
Reference in New Issue
Block a user