Skip to content

Commit 979b22d

Browse files
Update src/components/ui/WorkExperience.astro
- Removed `document.addEventListener('DOMContentLoaded', ...)` wrapper - Script now executes immediately when the component renders - Compatible with Astro's client-side navigation and view transitions Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b2e793b commit 979b22d

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

src/components/ui/WorkExperience.astro

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,30 @@ const images = entry.data.images
5858
import { createRoot } from 'react-dom/client';
5959
import { createElement } from 'react';
6060

61-
document.addEventListener('DOMContentLoaded', () => {
62-
const thumbs = document.querySelectorAll('.work-image-thumb');
63-
64-
thumbs.forEach((thumb) => {
65-
thumb.addEventListener('click', () => {
66-
const images = JSON.parse(thumb.getAttribute('data-images') || '[]');
67-
const index = parseInt(thumb.getAttribute('data-index') || '0');
68-
69-
const container = document.createElement('div');
70-
document.body.appendChild(container);
71-
const root = createRoot(container);
72-
73-
const closeHandler = () => {
74-
root.unmount();
75-
document.body.removeChild(container);
76-
};
77-
78-
root.render(
79-
createElement(ImageLightbox, {
80-
images,
81-
isOpen: true,
82-
initialIndex: index,
83-
onClose: closeHandler,
84-
})
85-
);
86-
});
61+
const thumbs = document.querySelectorAll('.work-image-thumb');
62+
63+
thumbs.forEach((thumb) => {
64+
thumb.addEventListener('click', () => {
65+
const images = JSON.parse(thumb.getAttribute('data-images') || '[]');
66+
const index = parseInt(thumb.getAttribute('data-index') || '0');
67+
68+
const container = document.createElement('div');
69+
document.body.appendChild(container);
70+
const root = createRoot(container);
71+
72+
const closeHandler = () => {
73+
root.unmount();
74+
document.body.removeChild(container);
75+
};
76+
77+
root.render(
78+
createElement(ImageLightbox, {
79+
images,
80+
isOpen: true,
81+
initialIndex: index,
82+
onClose: closeHandler,
83+
})
84+
);
8785
});
8886
});
8987
</script>

0 commit comments

Comments
 (0)