Added Logo and logo animation

This commit is contained in:
Yohan Boujon 2023-06-19 13:12:32 +02:00
parent 90db0d2460
commit 55413d8a54
7 changed files with 111 additions and 11 deletions

BIN
assets/Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -1,4 +1,9 @@
<nav id="navbar_component"> <nav id="navbar_component">
<p><bold>Saoul Bon Monsieur</bold></p> <div id="navbar_logo-container">
<img class="navbar_logo" src="../assets/Logo.png"><img>
</div>
<div id="navbar_text-container">
<p><bold>Saoul Bon Monsieur</bold></p>
</div>
</nav> </nav>
<div id="navbar_padding"></div> <div id="navbar_padding"></div>

View file

@ -67,7 +67,6 @@ p {
display: flex; display: flex;
box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px; box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px;
position: relative; position: relative;
z-index: 11;
} }
.description-text { .description-text {
@ -91,4 +90,5 @@ p {
max-width: 30rem; max-width: 30rem;
height: auto; height: auto;
float: right; float: right;
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
} }

View file

@ -10,6 +10,22 @@
z-index:2; z-index:2;
} }
#navbar_logo-container {
height: 5rem;
width: 5rem;
display: flex;
}
.navbar_logo {
height: inherit;
}
#navbar_text-container {
font-family: 'Josefin Sans', sans-serif;
position: fixed;
right: 5rem;
}
#navbar_padding{ #navbar_padding{
padding: 2.5rem; padding: 2.5rem;
} }

View file

@ -1,5 +1,23 @@
/****************************************/
/* functions */
/****************************************/
function load(url, element) { function load(urlHTML, elementHTML, urlJS, elementJS) {
fetch(urlHTML).then(res => {
return res.text();
}).then(htmltext => {
return elementHTML.innerHTML = htmltext;
}).then(loadedHTML => {
loadJS(urlJS, elementJS);
})
.catch(
function (err) {
console.warn('Could not load the Navbar.', err)
}
);
}
function loadHTML(url, element) {
fetch(url).then(res => { fetch(url).then(res => {
return res.text(); return res.text();
}).then(htmltext => { }).then(htmltext => {
@ -11,17 +29,27 @@ function load(url, element) {
); );
} }
window.addEventListener('load', function () { function loadJS(url, element) {
load("../components/navbar.html", document.getElementsByTagName("Navbar")[0]); var scriptTag = document.createElement('script');
}) scriptTag.src = url;
element.appendChild(scriptTag);
}
function ready(callback){ function ready(callback) {
// in case the document is already rendered // in case the document is already rendered
if (document.readyState!='loading') callback(); if (document.readyState != 'loading') callback();
// modern browsers // modern browsers
else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback); else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
// IE <= 8 // IE <= 8
else document.attachEvent('onreadystatechange', function(){ else document.attachEvent('onreadystatechange', function () {
if (document.readyState=='complete') callback(); if (document.readyState == 'complete') callback();
}); });
} }
/****************************************/
/* main */
/****************************************/
window.addEventListener('load', function () {
load("../components/navbar.html", document.getElementsByTagName("Navbar")[0],"js/navbar.js", this.document.getElementsByTagName("head")[0]);
})

View file

@ -1,3 +1,7 @@
/****************************************/
/* animjs */
/****************************************/
var saoulAnimation = anime({ var saoulAnimation = anime({
targets: '.photosaoul', targets: '.photosaoul',
easing: 'easeOutQuint', easing: 'easeOutQuint',
@ -33,6 +37,9 @@ var textAnimation = anime({
}, },
}) })
/****************************************/
/* main */
/****************************************/
saoulAnimation.reverse() saoulAnimation.reverse()
ready(function(){ ready(function(){
setTimeout(() => { setTimeout(() => {
@ -42,6 +49,10 @@ ready(function(){
}, 1000); }, 1000);
}); });
/****************************************/
/* functions */
/****************************************/
function superAnim() { function superAnim() {
saoulAnimation.play() saoulAnimation.play()
} }

40
js/navbar.js Normal file
View file

@ -0,0 +1,40 @@
var enterAnimation;
var logoRotate = anime({
targets: '.navbar_logo',
rotateY: 180,
duration: 1000,
easing: 'easeOutExpo',
autoplay: false,
direction: 'normal',
update: function(anim){
console.log(anim.progress+" : enter ? "+enterAnimation);
if(anim.progress >= 10 && enterAnimation)
{
document.getElementsByClassName("navbar_logo")[0].style.filter = "brightness(50%)";
}
if(anim.progress <= 10 && !enterAnimation)
{
document.getElementsByClassName("navbar_logo")[0].style.filter = "";
}
}
});
document.getElementById("navbar_logo-container").addEventListener("mouseenter", function () {
enterAnimation = true;
logoRotate.play();
logoRotate.finished.then(() => {
enterAnimation = false;
})
});
document.getElementById("navbar_logo-container").addEventListener("mouseleave", function () {
console.log("leave")
enterAnimation = false;
logoRotate.reverse();
logoRotate.play();
logoRotate.finished.then(() => {
logoRotate.reverse();
enterAnimation = true;
})
});