GalleryPremium

Lens Zoom

An 80 px square viewfinder with a thin edge lands wherever the mouse, a finger or the keyboard points and shows your image enlarged 2.5 times, with no rounding to shave off the corners.

JSBackground

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Gallery has 44 effects, including 6 free. Explore the category →

3 usage examples

“Where is the pika hiding?” — spotting game in a mountain park's newsletter — Lens Zoom example 1

① “Where is the pika hiding?” — spotting game in a mountain park's newsletter

WhenThe Tessarine Mountains Park game of the week shows a granite scree; somewhere, a pika sits in the shade of a boulder. The player sweeps the viewfinder over the stones. When it passes over the animal, the left panel turns green: “Found!”
WhyHere the square viewfinder works as binoculars: it turns a still photo into ground to search, and its magnification confirms at a glance that you did see an ear and not a pebble.
SettingsWrapper in position: absolute to the right of a 152 px panel, --lnz-width: 100%, --lnz-ratio: 388/360, --lnz-radius: 0, --lnz-size: 124px, data-zoom="2.5", 582 px photo backed by a 1,455 px file in data-zoom-src; .lnz-label caption removed. The “found” detection is written by the scene.
Counting the rings of a felled tree — worksheet of a forest nature trail — Lens Zoom example 2

② Counting the rings of a felled tree — worksheet of a forest nature trail

WhenAt stop 4 of the schoolchildren's trail in Ostrevaille Forest, the online worksheet shows the slice of a large trunk and asks: how old was this tree? The pupil follows the rings from the heart out to the bark, viewfinder in hand, then types an answer.
WhyTight rings cannot be counted on a 330 px photo. Enlarged three times in a square, they come in rows nicely parallel to its edges, and the whole stump stays visible around it so you do not lose your place.
Settings--lnz-width: 332px, --lnz-ratio: 332/232, --lnz-radius: 8px, --lnz-size: 96px, --lnz-ring: 2px solid #fff, data-zoom="3", 1,494 px file in data-zoom-src.
Spotted tomato leaf sent to a garden advice service — the adviser looks at the spots up close — Lens Zoom example 3

③ Spotted tomato leaf sent to a garden advice service — the adviser looks at the spots up close

WhenIn the Phyllène message centre, a gardener attached a photo to her question. The adviser moves the viewfinder over the leaflets, recognises round spots with a pale centre and writes her reply under the message, without opening the attachment.
WhyIn a message thread the photo has to stay small. The viewfinder supplies the missing detail needed to decide, right where the reply is written.
Settings--lnz-width: 180px, --lnz-ratio: 3/2, --lnz-radius: 8px, --lnz-size: 72px, --lnz-ring: 2px solid #fff, data-zoom="3". For the capture, since the photo is off the mouse path, the scene sends the frame the pointermove events the script listens for, along a route over the spots.

How it works

The HTML is three parts inside .lnz-frame: your <img class="lnz-image">, an optional caption and an empty square, .lnz-lens. While nobody is aiming, the square is transparent. On the first move, the script gives it the image file as a background (or the one in data-zoom-src) and adds the is-active class to the frame: the viewfinder appears in 0.2 s.

After that it all comes down to two numbers. The viewfinder background is stretched to the size of the displayed image multiplied by data-zoom: for the original frame, 278 px wide inside, that makes 695 px, or 2.5 times. Then it is shifted so the targeted point lands in the middle of the square. Read while aiming at (100, 60) then (200, 150): the centre of the viewfinder sits exactly at those coordinates in Chromium, Firefox and WebKit.

Near an edge the viewfinder sticks out and the frame cuts it (overflow: hidden), so you can aim right up to the last pixel. The script adds no global name and only attaches to the .fx-0181-root blocks it finds; pasted twice in the page, it duplicates nothing.

Accessibility

  • With the keyboard: Tab brings focus to the frame, ringed with a white line, and the viewfinder lights up in the centre. Each arrow key pushes it 12 px, 48 px with Shift; Escape turns it off, and so does leaving the frame. Checked on two neighbouring frames: only the focused one reacts.
  • With a finger: the viewfinder appears under the finger, follows it while it drags and goes off when it lifts, so a quick tap lights it only for an instant. Two limits to know: the finger hides part of an 80 px viewfinder (raise --lnz-size to 120 px or more on mobile), and the frame holds the gesture (touch-action: none), so the page does not scroll when you start from the image.
  • Screen readers: the frame is announced as a group with the instruction in its aria-label (remember to translate it), the image with its alt. The viewfinder is purely visual and hidden: if the image holds text to be read, provide that text elsewhere on the page.
  • “Reduce motion” preference: the 0.2 s fade-in is removed and the viewfinder shows at once. Its movement stays, since it only follows the hand.

Browser compatibility

A 4 KB script with no library, built on Pointer Events; on the CSS side, aspect-ratio sets the frame shape and object-fit: cover the crop. Bench-tested on 4 December 2026 on Chromium 149, Firefox 151 and WebKit 26.5: aiming with the mouse, keyboard path and emulated finger tap in all three; finger down then dragged in Chromium only (the page did not scroll).

Chrome 88+✓ Full (measured on Chromium 149)
Firefox 89+✓ Full (measured on Firefox 151)
Safari 15+✓ WebKit 26.5 engine measured, real Safari not verified
Edge 88+✓ Full (Chromium engine)
iOS Safari 15+✓ Not verified on a device
Android Chrome 88+✓ Emulated touch measured, real device not verified

If the script fails to load, an ordinary image remains in its frame. The versions listed are those of aspect-ratio (MDN data): on anything older, the frame has no imposed proportion and takes the natural height of the image.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0181-root">
  <div class="lnz-frame" tabindex="0" role="group" aria-label="Magnifier: hover the image, drag a finger or use the arrow keys" data-zoom="2.5">
    <img class="lnz-image" src="photo.jpg" data-zoom-src="photo-large.jpg" alt="What the photo shows">
    <span class="lnz-label" aria-hidden="true">Move Mouse</span>
    <div class="lnz-lens" aria-hidden="true"></div>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Image (HTML — src, alt and data-zoom-src of .lnz-image) violet grid pattern (SVG in the code) Your photo. data-zoom-src is optional: it names a heavier file, loaded only when the viewfinder lights up.
data-zoom (on .lnz-frame) 2.5 Magnification. The script rereads it on every move, so you can change it on the fly, with a slider for instance.
--lnz-size 80px Side of the viewfinder. The bigger it is, the more context you see; 120 px or more for finger use.
--lnz-shape 0 Corner rounding of the viewfinder. Leave 0 for the crisp square, 6px to soften it.
--lnz-ring 2px solid rgba(255, 255, 255, 0.8) Edge of the viewfinder. A solid white stands out better on a light photo.
--lnz-width · --lnz-ratio · --lnz-radius 280px · 7 / 5 · 0.75rem Maximum width, proportion and corners of the frame. The image is cropped to fill it.
.lnz-label caption “Move Mouse” Word shown in the middle of the demo pattern. Delete it as soon as you put in a real image.

FAQ

Frankly, not much: both effects have the same script, line for line, and the same style sheet apart from four values. Magnifying Glass comes as a 100 px disc with a thick 3 px white rim and an inner reflection, magnification 2. Lens Zoom comes as an 80 px square with a thin translucent edge, no reflection, magnification 2.5. If you already own one, three variables and the data-zoom attribute give you almost the other.
At equal width, a square shows 27% more area than a disc (6,400 px² against 5,027 for 80 px). And its edges run parallel to what is read in lines: a paragraph, the weave of a fabric, the columns of a table, the rings of a trunk. The disc suggests a desk magnifier; it is a matter of use more than of technique.
Take the frame width multiplied by the magnification, then by the screen density. For the 280 px frame at 2.5 on a double-density screen: 280 × 2.5 × 2 = 1,400 px wide. Above that the file weighs more for no gain; below it, the viewfinder softens the image. This file must have the same framing as the displayed image.