Skip to content

Commit

Permalink
🌟 add popup animation
Browse files Browse the repository at this point in the history
  • Loading branch information
MorganKryze committed May 18, 2024
1 parent 9637da4 commit 7e8de5b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/src/animations/popup.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script>
// JavaScript
document.querySelectorAll('img').forEach(img => {
img.addEventListener('click', function() {
const popup = document.createElement('img');
popup.src = this.src;
popup.classList.add('popup');

const overlay = document.createElement('div');
overlay.classList.add('overlay');

overlay.addEventListener('click', function() {
popup.style.opacity = '0';
this.style.opacity = '0';
setTimeout(() => {
popup.remove();
this.remove();
}, 300);
});

document.body.appendChild(overlay);
document.body.appendChild(popup);

setTimeout(() => {
popup.style.opacity = '1';
overlay.style.opacity = '1';
}, 0);
});
});
</script>
1 change: 1 addition & 0 deletions src/src/pages/collections/france.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import "../../styles/global.css";
import "../../animations/hide.astro";
import "../../animations/popup.astro";
import CollectionLayout from "../../layouts/CollectionLayout.astro";
import GalleryImage from "../../components/GalleryImage.astro";
Expand Down
1 change: 1 addition & 0 deletions src/src/pages/collections/ireland.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import "../../styles/global.css";
import "../../animations/hide.astro";
import "../../animations/popup.astro";
import CollectionLayout from "../../layouts/CollectionLayout.astro";
import GalleryImage from "../../components/GalleryImage.astro";
Expand Down
1 change: 1 addition & 0 deletions src/src/pages/collections/sardegna.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import "../../styles/global.css";
import "../../animations/hide.astro";
import "../../animations/popup.astro";
import GalleryImage from "../../components/GalleryImage.astro";
import CollectionLayout from "../../layouts/CollectionLayout.astro";
Expand Down
1 change: 1 addition & 0 deletions src/src/pages/collections/tales.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import "../../styles/global.css";
import "../../animations/hide.astro";
import "../../animations/popup.astro";
import CollectionLayout from "../../layouts/CollectionLayout.astro";
import GalleryImage from "../../components/GalleryImage.astro";
Expand Down
26 changes: 26 additions & 0 deletions src/src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,30 @@

.hover-effect:hover {
transform: scale(1.05);
}

.popup {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
max-width: 90%;
max-height: 90%;
overflow: auto;
opacity: 0;
transition: opacity 0.3s ease-in-out;
border-radius: 10px;
}

.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}

0 comments on commit 7e8de5b

Please sign in to comment.