Medium Zoom is a lightweight, responsive JavaScript library designed to replicate the elegant image zooming experience found on the Medium platform. Currently stable at version 1.1.0, the package sees active development with regular patch releases addressing bugs and minor enhancements, building upon its significant 1.0.0 refactor. Key differentiators include its high performance (aiming for 60fps), support for high-definition image loading on zoom, extensive customization options for margin, background, and scroll offset, and a pluggable architecture allowing for custom features and templates. It is framework-agnostic, working seamlessly across React, Vue, Angular, Svelte, and Solid, and offers comprehensive event handling for various zoom states. The library focuses on providing a smooth, intuitive user experience that is friendly to mouse, keyboard, and touch gestures.
npm install medium-zoomVerified import paths — ran on the pinned version, not inferred.
This code initializes `mediumZoom` on elements matching a CSS selector, demonstrates attaching additional elements, sets custom options, and logs events during the zoom lifecycle. It also includes the necessary CSS import.
Review calls to `mediumZoom` methods. For animation methods, use `async/await` or `.then()` to handle their completion. For other methods, adjust chaining as needed.
Ensure you explicitly import the CSS file: `import 'medium-zoom/dist/medium-zoom.css';` in your entry point, or link it via a `<link>` tag in your HTML. Since v1.1.0, a `medium-zoom.pure.css` bundle is also available.
Upgrade to `medium-zoom@1.0.4` or newer. If stuck on older versions, implement conditional rendering or client-side mounting for the zoom functionality within your SSR application.
Ensure you are using `import mediumZoom from 'medium-zoom';` for ESM setups. If using CommonJS, ensure your build pipeline correctly handles the module export.
Verify your CSS selector is correct and matches existing `<img>` elements. Wrap your `mediumZoom` initialization in a `DOMContentLoaded` listener or defer it until your images are present in the DOM.
Add `import 'medium-zoom/dist/medium-zoom.css';` to your main JavaScript/TypeScript file or include a `<link>` tag for the CSS in your HTML.
After dynamically adding new images, use the `zoom.attach(selector)` method on your existing `mediumZoom` instance to make the new images zoomable.
No dependency data recorded yet.