Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for view transitions #5

Merged
merged 1 commit into from
Apr 25, 2024
Merged

feat: add support for view transitions #5

merged 1 commit into from
Apr 25, 2024

Conversation

martrapp
Copy link
Contributor

Describe the pull request

Hi @HiDeoo, people have an issue using The Bags Starlight support.
starlight-image-zoom doesn't work any more as soon as they add view transitions.
I would be happy if you could integrate these changes to make ImageZoom compatible with Astro's view transitions.

Why

Closes martrapp/astro-vtbot#89

How

if ImageZoom should also work with view transitions, the initialization code that runs at DOMContentLoaded also needs to run on soft loads after-swap .

As the web component runs the constructor whenever the component is inserted into the DOM, setting up the astro:after-swap listener needs a static property to keep track of initialization.

Without full page reloads, listeners on document and window need some cleanup, which I added after-preparation. To make that more symmetric, I also hoisted the addEventlistener calls for click and resize up into the idle callback.

Finally, there I added cleanup for the wheel handler in #close.

Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
starlight-image-zoom ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2024 3:11pm

Copy link
Owner

@HiDeoo HiDeoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request, super appreciated!

The code makes sense to me and all the tests I could try locally (thanks to astro-vtbot 👜 ) worked perfectly fine. 🚀

@HiDeoo HiDeoo changed the title Makes ImageZoom compatible with view transitions feat: add support for view transitions Apr 25, 2024
@HiDeoo HiDeoo merged commit a787bea into HiDeoo:main Apr 25, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

not work starlight-image-zoom plugin
2 participants