Fixed Loading picture width on bigger screen. Added an animation on mobile. Added menuOpened and navbarAnimation variables
This commit is contained in:
parent
822f866ec4
commit
3c9765f090
3 changed files with 49 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
<nav id="navbar_component">
|
<nav id="navbar_component">
|
||||||
<div id="navbar_menu">
|
<div id="navbar_menu">
|
||||||
<a class="navbar_menu-click" href="javascript:openMenu()">
|
<a class="navbar_menu-click" href="javascript:openMenu(true)">
|
||||||
<svg width="1em" height="1em" viewBox="0 0 24 24"
|
<svg width="1em" height="1em" viewBox="0 0 24 24"
|
||||||
style="vertical-align: -0.125em; transform: rotate(360deg);">
|
style="vertical-align: -0.125em; transform: rotate(360deg);">
|
||||||
<polygon
|
<polygon
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="navbar_text-container">
|
<div id="navbar_text-container">
|
||||||
<div class="navbar_menu-close">
|
<div class="navbar_menu-close">
|
||||||
<a class="navbar_menu-close-btn" href="javascript:closeMenu()">
|
<a class="navbar_menu-close-btn" href="javascript:closeMenu(true)">
|
||||||
<span class="iconify" data-icon="mdi-close"></span>
|
<span class="iconify" data-icon="mdi-close"></span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -96,7 +96,7 @@ p {
|
||||||
.loading-content img{
|
.loading-content img{
|
||||||
margin: 0.5rem;
|
margin: 0.5rem;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 30%;
|
max-width: 15rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
50
js/navbar.js
50
js/navbar.js
|
@ -8,6 +8,8 @@ var mobileMode = false
|
||||||
var enterAnimation = false;
|
var enterAnimation = false;
|
||||||
//same but for menu
|
//same but for menu
|
||||||
var enterMenuAnimation = false;
|
var enterMenuAnimation = false;
|
||||||
|
//when menu is opened or not
|
||||||
|
var menuOpened = false;
|
||||||
//each <li> tag of the navbar_text-container
|
//each <li> tag of the navbar_text-container
|
||||||
var dropdownList = document.getElementById("navbar_text-container").children[1].children;
|
var dropdownList = document.getElementById("navbar_text-container").children[1].children;
|
||||||
//each <a> tag in the navbar
|
//each <a> tag in the navbar
|
||||||
|
@ -55,6 +57,16 @@ var menuAnimation = anime({
|
||||||
autoplay: false,
|
autoplay: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var navbarAnimation = anime({
|
||||||
|
targets: '#navbar_text-container',
|
||||||
|
translateX: [
|
||||||
|
{ value: "", duration: 0, delay: 0 },
|
||||||
|
{ value: "-20rem", duration: 300, delay: 0 }
|
||||||
|
],
|
||||||
|
easing: 'easeOutExpo',
|
||||||
|
autoplay: false
|
||||||
|
})
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
/* functions */
|
/* functions */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -94,12 +106,30 @@ function resetNavbar() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openMenu() {
|
function openMenu(playAnimation) {
|
||||||
|
menuOpened=true;
|
||||||
|
if (playAnimation) {
|
||||||
|
document.getElementById("navbar_text-container").style.display = "block";
|
||||||
|
navbarAnimation.reverse();
|
||||||
|
navbarAnimation.restart();
|
||||||
|
}
|
||||||
|
else {
|
||||||
document.getElementById("navbar_text-container").style.display = "block";
|
document.getElementById("navbar_text-container").style.display = "block";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function closeMenu() {
|
function closeMenu(playAnimation) {
|
||||||
|
menuOpened=false;
|
||||||
|
if (playAnimation) {
|
||||||
|
navbarAnimation.reverse();
|
||||||
|
navbarAnimation.restart();
|
||||||
|
navbarAnimation.finished.then(() => {
|
||||||
document.getElementById("navbar_text-container").style.display = "none";
|
document.getElementById("navbar_text-container").style.display = "none";
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.getElementById("navbar_text-container").style.display = "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
|
@ -195,14 +225,20 @@ window.addEventListener('click', function (e) {
|
||||||
|
|
||||||
//When changing the window size
|
//When changing the window size
|
||||||
window.addEventListener('resize', function (e) {
|
window.addEventListener('resize', function (e) {
|
||||||
if((window.innerWidth > 800) && mobileMode)
|
if ((window.innerWidth > 800) && mobileMode) {
|
||||||
|
//when switching from mobile to computer
|
||||||
|
document.getElementById("navbar_text-container").style.transform = "";
|
||||||
|
openMenu(false);
|
||||||
|
if(menuOpened)
|
||||||
{
|
{
|
||||||
openMenu();
|
navbarAnimation.reverse();
|
||||||
|
}
|
||||||
mobileMode = false;
|
mobileMode = false;
|
||||||
}
|
}
|
||||||
if((window.innerWidth < 800) && !mobileMode)
|
if ((window.innerWidth < 800) && !mobileMode) {
|
||||||
{
|
//when switching from computer to mobile
|
||||||
closeMenu();
|
console.log("computer to mobile");
|
||||||
|
closeMenu(false);
|
||||||
mobileMode = true;
|
mobileMode = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue