Merge pull request 'fix: handle script with swup' (#388) from main into release
All checks were successful
release-image / guarddog (push) Successful in 25s
release-image / build (push) Successful in 1m52s
release-image / semantic-release (push) Successful in 54s
release-image / release-harbor (push) Successful in 5m35s
release-image / release-gitea (push) Successful in 5m34s
All checks were successful
release-image / guarddog (push) Successful in 25s
release-image / build (push) Successful in 1m52s
release-image / semantic-release (push) Successful in 54s
release-image / release-harbor (push) Successful in 5m35s
release-image / release-gitea (push) Successful in 5m34s
Reviewed-on: #388
This commit was merged in pull request #388.
This commit is contained in:
@@ -82,7 +82,7 @@ const images = await Promise.all(imagesData.map(async (img) => ({
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('astro:page-load', () => {
|
function initHeroImage() {
|
||||||
const container = document.getElementById('hero-image-container');
|
const container = document.getElementById('hero-image-container');
|
||||||
if (container) {
|
if (container) {
|
||||||
const images = container.querySelectorAll('.hero-image');
|
const images = container.querySelectorAll('.hero-image');
|
||||||
@@ -96,5 +96,13 @@ const images = await Promise.all(imagesData.map(async (img) => ({
|
|||||||
images[randomIndex].classList.add('flex');
|
images[randomIndex].classList.add('flex');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', initHeroImage);
|
||||||
|
} else {
|
||||||
|
initHeroImage();
|
||||||
|
}
|
||||||
|
if ((window as any).swup) {
|
||||||
|
(window as any).swup.hooks.on('page:view', initHeroImage);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user