diff --git a/css/search-box.css b/css/search-box.css index cbc6b67..54f3ed5 100644 --- a/css/search-box.css +++ b/css/search-box.css @@ -23,14 +23,13 @@ -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); - transition: opacity var(--transition-speed), - top var(--transition-speed), - visibility var(--transition-speed), - pointer-events var(--transition-speed) ; + transition: opacity var(--transition-speed), + top 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; } diff --git a/index.html b/index.html index ea21768..de20d38 100644 --- a/index.html +++ b/index.html @@ -59,5 +59,6 @@ + \ No newline at end of file diff --git a/js/animate-profile-image.js b/js/animate-profile-image.js index 2de8e35..cc0ac58 100644 --- a/js/animate-profile-image.js +++ b/js/animate-profile-image.js @@ -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(); }; diff --git a/js/show-search-box.js b/js/show-search-box.js new file mode 100644 index 0000000..5ed4a1c --- /dev/null +++ b/js/show-search-box.js @@ -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'); +} \ No newline at end of file