Guide

Under the hood

How the viewer mounts, locks the page and stays fast.

Mounting

A module can't edit your app.vue, so the client plugin does it lazily: on the first open it imports the viewer component and renders it into a container in <body> with your app's context; after the closing animation it unmounts it. Until someone opens an image, the viewer costs nothing but a click listener.

The viewer component itself doesn't depend on Nuxt — it gets everything through props and reports back through events.

The strip

Every slide is in the DOM from the start. Each shows the copy of the image already loaded on the page (currentSrc), and the full image is loaded on top of it for the current slide and its neighbours. That's why there is never an empty frame, however fast you swipe.

The endless strip works from three images: its position grows without limit, and every slide stands in the copy closest to it. A slide is always moved while it's off screen.

The flight

While the viewer is open, the page image of the current slide is visibility: hidden — the image flies out of its place instead of doubling it. The flight is a FLIP animation from the visible crop of the thumbnail, respecting object-fit, object-position and border-radius through an animated clip-path.

Scroll lock

The page can't scroll while the viewer is open. If <html> doesn't have scrollbar-gutter: stable, the scrollbar width is compensated with padding-right on <body>, so the page doesn't jump. Your own fixed elements may need the same — target them with the openClass on <html>.

The viewer layer is 100vw wide rather than inset: 0: with a stable scrollbar gutter, inset: 0 would leave a stripe on the right where the page shows through.

Size

The module ships a plugin, a composable, two tiny components, the viewer component and one CSS file — no runtime dependencies. The viewer is code-split and loaded on the first open.