Skip to content

Commit b1d8414

Browse files
committed
Use astro page load.
1 parent ef624e4 commit b1d8414

File tree

12 files changed

+19
-18
lines changed

12 files changed

+19
-18
lines changed

src/components/Header.astro

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ import links from "@data/links.json";
4646
</div>
4747
</section>
4848
<Search />
49+
50+
<style>
51+
:root::view-transition-group(navbar) {
52+
z-index: 100;
53+
}
54+
</style>
4955
<script>
5056
document.addEventListener("astro:page-load", () => {
5157
let prevScrollPos = window.pageYOffset;
52-
const navbar = document.getElementById("navbar");
53-
if (!navbar) return;
54-
55-
let isFocused = false;
58+
const navbar = document.getElementById("navbar") as HTMLElement;
5659

5760
window.addEventListener("scroll", () => {
58-
if (isFocused) return;
5961
let currentScrollPos = window.pageYOffset;
6062
if (prevScrollPos > currentScrollPos) {
6163
navbar.style.transform = "translateY(0)";
@@ -65,13 +67,12 @@ document.addEventListener("astro:page-load", () => {
6567
prevScrollPos = currentScrollPos;
6668
});
6769

70+
6871
navbar.addEventListener("focusin", () => {
69-
isFocused = true;
7072
navbar.style.transform = "translateY(0)";
7173
});
7274

7375
navbar.addEventListener("focusout", () => {
74-
isFocused = false;
7576
if (window.pageYOffset > 100) {
7677
navbar.style.transform = "translateY(-100%)";
7778
}

src/components/Modal.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const { id = 'modal', open = false, closeOnOutsideClick = false } = Astro.props;
2727
</div>
2828
</div>
2929
<script >
30-
document.addEventListener('DOMContentLoaded', () => {
30+
document.addEventListener('astro:page-load', () => {
3131
// Function to toggle body scroll
3232
const toggleBodyScroll = (disable: any) => {
3333
if (disable) {

src/components/NavItems.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const { items, inverted = false, level = 1 } = Astro.props;
103103

104104
<script>
105105
// Add keyboard navigation support
106-
document.addEventListener('DOMContentLoaded', () => {
106+
document.addEventListener('astro:page-load', () => {
107107
const navButtons = document.querySelectorAll('[role="menuitem"][aria-haspopup="true"]');
108108

109109
navButtons.forEach(button => {

src/components/Offline.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77
<script is:inline>
88

9-
document.addEventListener('DOMContentLoaded', () => {
9+
document.addEventListener('astro:page-load', () => {
1010
const offlineIcon = document.getElementById('offline-icon');
1111

1212
function updateOnlineStatus() {

src/components/Search.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Modal from "@components/Modal.astro";
2424

2525

2626
<script>
27-
document.addEventListener("DOMContentLoaded", function () {
27+
document.addEventListener("astro:page-load", function () {
2828
const searchContainer = document.querySelector(".pagefind-ui") as HTMLElement | null;
2929
const searchInput = searchContainer?.querySelector("input") as HTMLInputElement | null;
3030
const searchButton = document.getElementById("searchButton") as HTMLElement | null;

src/components/schedule/day.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ const dateText = format(date, "eeee - do MMMM");
638638
</style>
639639

640640
<script>
641-
document.addEventListener("DOMContentLoaded", function () {
641+
document.addEventListener("astro:page-load", function () {
642642
const containers = document.querySelectorAll(".schedule-container");
643643

644644
function syncScroll(event: any) {

src/components/sections/speakers.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const sectionSubtitle = "Meet some of our amazing speakers";
7070
</Section>
7171

7272
<script>
73-
document.addEventListener('DOMContentLoaded', () => {
73+
document.addEventListener('astro:page-load', () => {
7474
const track = document.querySelector('.speakers-track') as HTMLElement;
7575
const slides = document.querySelectorAll('.speaker-slide');
7676
const totalOriginalSlides = slides.length / 2;

src/components/sessions/filter.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import Select from "@ui/Select.astro";
8080
search: string;
8181
}
8282

83-
document.addEventListener("DOMContentLoaded", () => {
83+
document.addEventListener("astro:page-load", () => {
8484
const forms = document.querySelectorAll<HTMLFormElement>("form.filter-sessions");
8585
const resultsInfo = document.getElementById("results-info");
8686

src/components/ui/Accordion.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const { title, id } = Astro.props;
2929
}
3030
</style>
3131
<script>
32-
document.addEventListener("DOMContentLoaded", () => {
32+
document.addEventListener("astro:page-load", () => {
3333
const hash = window.location.hash.substring(1); // Remove #
3434
if (hash) {
3535
const details = document.getElementById(

src/layouts/MarkdownLayout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const { title, description, toc=false } = Astro.props;
3434
</Layout>
3535

3636
<script is:inline>
37-
document.addEventListener("DOMContentLoaded", () => {
37+
document.addEventListener("astro:page-load", () => {
3838
const tocContainer = document.getElementById("toc");
3939
if (!tocContainer) return;
4040

src/pages/media/speaker/[slug].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ window.addEventListener('resize', fitAllText);
8585
</script>
8686

8787
<script is:inline define:vars={{slug: entry.data.slug}}>
88-
document.addEventListener('DOMContentLoaded', () => {
88+
document.addEventListener('astro:page-load', () => {
8989
document.querySelectorAll('.social').forEach((socialDiv, index) => {
9090

9191
socialDiv.addEventListener('click', () => {

src/pages/media/sponsor/[slug].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ window.addEventListener('resize', fitAllText);
8686
</script>
8787

8888
<script is:inline define:vars={{slug: sponsor.id}}>
89-
document.addEventListener('DOMContentLoaded', () => {
89+
document.addEventListener('astro:page-load', () => {
9090
document.querySelectorAll('.social').forEach((socialDiv, index) => {
9191

9292
socialDiv.addEventListener('click', () => {

0 commit comments

Comments
 (0)