Skip to content

Commit

Permalink
make display experience more smooth
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniere-Mathieu committed May 11, 2023
1 parent 8da99e3 commit 0a347b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ import { Image } from "@astrojs/image/components";
---

<script>
const elements = document.querySelectorAll(".main__experience");

elements.forEach((element) => {
const element = document.getElementById("experienceWrapper");
if (!element) {
console.error("Element not found");
} else {
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
if (!element.classList.contains("animate"))
element.classList.add("animate");
const elements = document.querySelectorAll(".main__experience");
elements.forEach((element) => {
if (!element.classList.contains("animate"))
element.classList.add("animate");
});
}
});
});

observer.observe(element);
});
}
</script>

<html lang="fr">
Expand Down Expand Up @@ -65,7 +69,7 @@ import { Image } from "@astrojs/image/components";
<div class="main__bar"></div>
<h2>Experiences</h2>
<div class="main__experienceContainer">
<ul class="main__experienceWrapper">
<ul class="main__experienceWrapper" id="experienceWrapper">
{
tech.map((item) => (
<li class="main__experience">
Expand Down
4 changes: 3 additions & 1 deletion src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
align-items: center;
gap: 10px;
z-index: 1;
display: none;
&:hover,
&:focus {
transform: rotate(3deg);
Expand Down Expand Up @@ -150,6 +151,7 @@

.animate {
animation: translate 2s ease-in-out;
display: flex;
}

@keyframes translate {
Expand All @@ -160,7 +162,7 @@

to {
transform: translateX(0%);
display: block;
display: flex;
}
}

Expand Down

0 comments on commit 0a347b8

Please sign in to comment.