-
Notifications
You must be signed in to change notification settings - Fork 164
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: introduce pure bundle (JS and CSS separated) #206
Conversation
@Nomango I reused your branch to:
Can you please let me know if that works as expected in your Astro setup? |
@francoischalifour Thanks for handling this! I can't import And this is what I did.
There is another issue, when using page transition, multiple calls to mediumZoom will cause problems. Seems like the background is overlaid on the image. // instead of...
mediumZoom(imgs, { background: "rgba(0, 0, 0, 0.8)" });
// using...
if (window.zoom === undefined) {
window.zoom = mediumZoom({ background: "rgba(0, 0, 0, 0.8)" });
}
const zoom = window.zoom;
zoom.detach();
zoom.attach(imgs); Is there something I missed? |
Indeed, the imports should use the import mediumZoom from 'medium-zoom/dist/pure'
import 'medium-zoom/dist/style.css' In Page Transitions in Astro, you might need to capture when the page changes with Let me know if that works! |
Yes, it works! Here are my test codes // src/utils/mediumZoom.ts
import mediumZoom from "medium-zoom/dist/pure";
import "medium-zoom/dist/style.css";
const zoom = mediumZoom({
background: "rgba(0, 0, 0, 0.8)",
});
document.addEventListener("astro:page-load", () => zoom.detach());
export default zoom; ---
// ...
---
<script>
import zoom from "@utils/mediumZoom";
// listen to astro:page-load event to handle the first loading
document.addEventListener("astro:page-load", () => zoom.attach("main img"));
</script> |
Perfect, I'll merge this PR then, and release right after. Thanks a lot for your contributions @Nomango! |
🎉 Released in 1.1.0. |
This is work on top of #204 and closes #203.
Description
This introduces a pure bundle where the JavaScript and CSS styles are separated. This brings support for Page Transitions in Astro.
Usage
(Or import the CSS with a
<link>
tag.)