personal-site/scripts/main.js

182 lines
5.3 KiB
JavaScript
Raw Normal View History

var faceWrapper = document.getElementById("my-face-wrapper");
lottie.setQuality("low");
var myFaceContainer = document.getElementById("my-face");
2021-05-26 13:16:53 +00:00
var morphShape1Container = document.getElementById("morph-shape-1");
var morphShape2Container = document.getElementById("morph-shape-2");
var morphShape3Container = document.getElementById("morph-shape-3");
var myFace = lottie.loadAnimation({
container: myFaceContainer,
path: "scripts/face.json",
renderer: "svg",
loop: false,
autoplay: false,
});
2021-05-26 13:16:53 +00:00
var morphShape1 = lottie.loadAnimation({
container: morphShape1Container,
path: "scripts/morphing-shape-1.json",
renderer: "svg",
loop: true,
autoplay: true,
});
var morphShape2 = lottie.loadAnimation({
container: morphShape2Container,
path: "scripts/morphing-shape-1.json",
renderer: "svg",
loop: true,
autoplay: true,
});
morphShape1.setSpeed(1.5);
var morphShape3 = lottie.loadAnimation({
container: morphShape3Container,
path: "scripts/morphing-shape-1.json",
renderer: "svg",
loop: true,
autoplay: true,
});
morphShape3.setSpeed(2);
function steadyState() {
myFace.playSegments([44, 205], true);
myFace.loop = true;
}
var startSteadyState;
window.addEventListener("load", () => {
myFace.playSegments([0, 50], true);
startSteadyState = setTimeout(() => {steadyState();}, 1000);
});
2021-05-25 06:11:47 +00:00
//--------------------------------------------------------------------------- Services mouseover
document.querySelectorAll(".hero-content-link").forEach(item => {
item.addEventListener("mouseover", () => {
clearTimeout(startSteadyState);
myFace.loop = false;
myFace.playSegments([210, 249], true);
faceWrapper.style.transform = "rotate3d(20,-20,0,20deg) translateZ(-50px)";
2021-06-03 21:35:02 +00:00
document.getElementById("bg-circle").style.transform = "rotate3d(20,-20,0,20deg) translate3d(-50%,-55%,-300px)";
myFaceContainer.style.mixBlendMode = "screen";
2021-05-25 06:11:47 +00:00
});
});
2021-05-25 20:49:37 +00:00
document.getElementById("ui-ux-design").addEventListener("mouseover", () => {
2021-05-25 20:57:19 +00:00
setTimeout(() => {document.getElementById("color-overlay").style.backgroundColor = "#A5E6BA";}, 400);
2021-05-25 20:49:37 +00:00
});
document.getElementById("web-design").addEventListener("mouseover", () => {
2021-05-25 20:57:19 +00:00
setTimeout(() => {document.getElementById("color-overlay").style.backgroundColor = "#5B2A86";}, 400);
2021-05-25 20:49:37 +00:00
});
document.getElementById("frontend-dev").addEventListener("mouseover", () => {
2021-05-25 20:57:19 +00:00
setTimeout(() => {document.getElementById("color-overlay").style.backgroundColor = "#7785AC";}, 400);
2021-05-25 20:49:37 +00:00
});
document.getElementById("graphic-design").addEventListener("mouseover", () => {
2021-05-25 20:57:19 +00:00
setTimeout(() => {document.getElementById("color-overlay").style.backgroundColor = "#9AC6C5";}, 400);
2021-05-25 20:49:37 +00:00
});
2021-05-25 06:11:47 +00:00
//--------------------------------------------------------------------------- Services mouseout
document.querySelectorAll(".hero-content-link").forEach(item => {
item.addEventListener("mouseout", () => {
startSteadyState = setTimeout(() => {
steadyState();
faceWrapper.style.transform = "none";
2021-05-25 20:49:37 +00:00
document.getElementById("color-overlay").style.backgroundColor = "transparent";
2021-06-03 21:35:02 +00:00
document.getElementById("bg-circle").style.transform = "translate3d(-50%,-55%,-300px)";
myFaceContainer.style.mixBlendMode = "normal";
2021-05-25 06:11:47 +00:00
}, 500);
});
});
2021-05-25 06:11:47 +00:00
/*
//--------------------------------------------------------------------------- UI UX
uiUXLink.addEventListener("mouseover", () => {
clearTimeout(startSteadyState);
myFace.loop = false;
myFace.playSegments([210, 249], true);
faceWrapper.style.transform = "rotate3d(20,-20,0,20deg) translateZ(-50px)";
});
uiUXLink.addEventListener("mouseout", () => {
startSteadyState = setTimeout(() => {steadyState();}, 500);
faceWrapper.style.transform = "none";
});
//--------------------------------------------------------------------------- Web Design
webDesignLink.addEventListener("mouseover", () => {
clearTimeout(startSteadyState);
myFace.loop = false;
myFace.playSegments([210, 249], true);
faceWrapper.style.transform = "rotate3d(20,-20,0,20deg) translateZ(-50px)";
});
webDesignLink.addEventListener("mouseout", () => {
startSteadyState = setTimeout(() => {steadyState();}, 500);
faceWrapper.style.transform = "none";
});
//--------------------------------------------------------------------------- Frontend Dev
frontentDevLink.addEventListener("mouseover", () => {
clearTimeout(startSteadyState);
myFace.loop = false;
myFace.playSegments([210, 249], true);
faceWrapper.style.transform = "rotate3d(20,-20,0,20deg) translateZ(-50px)";
});
frontentDevLink.addEventListener("mouseout", () => {
startSteadyState = setTimeout(() => {steadyState();}, 500);
faceWrapper.style.transform = "none";
});
//--------------------------------------------------------------------------- Graphic and Animation Design
graphicDesignLink.addEventListener("mouseover", () => {
clearTimeout(startSteadyState);
myFace.loop = false;
myFace.playSegments([210, 249], true);
faceWrapper.style.transform = "rotate3d(20,-20,0,20deg) translateZ(-50px)";
});
graphicDesignLink.addEventListener("mouseout", () => {
startSteadyState = setTimeout(() => {steadyState();}, 500);
faceWrapper.style.transform = "none";
});
2021-05-25 06:11:47 +00:00
*/