Search topics
Product photo zoom that needs a mouse
A product photo zooms only while the mouse moves over it, and nothing the keyboard can reach shows the small print or detail that the zoom shows.
frame.addEventListener('mousemove', (event) => { The problem
Keyboard, switch and voice control users can't see the detail that a product photo's zoom shows
A shop sells an enamel mug. Its product page has a large photo, thumbnails of the front, the side and the back under it, and an Add to cart button. The back carries small print that says "Dishwasher safe" and "350 ml", too small to read at the photo's size. With a mouse it is easy: move the pointer over the photo and it grows to three times its size around the pointer, until the print can be read.
The thumbnails are buttons with names, so a keyboard user can Tab to the back and press Enter, and the back of the mug appears. Then they press Tab again, to find a way to enlarge it. Focus goes from the thumbnails straight to Add to cart. Nothing on the photo takes focus, and no key makes it grow, so the small print stays a grey smudge.
This is how the common zoom libraries work out of the box. Drift describes itself as "zoom on hover", and jQuery Zoom starts on mouseover unless told otherwise. Drift's own example sets it on a plain image, with nothing else to press, and a page built that way has no other way to see the photo larger.
Success criterion 2.1.1 Keyboard asks that everything the mouse can do, the keyboard can do. Here the mouse can enlarge the photo and move around it. The zoom listens for mousemove, which no key sets off, and there is no button, link or Tab stop that does the same. W3C's failure F54 describes this case: event handlers specific to a pointing device are the only way to run a function. The function is seeing the detail in the photo.
A zoom made to start on focus is not enough. Even if Tab could reach the photo and enlarge it, the zoom follows the pointer: with no pointer, the keyboard has no way to move the view to the corner it wants to read.
The detail is often what a buyer needs: the capacity, whether it goes in the dishwasher, the weave of a fabric, a size chart printed on a label. A person who can't use a mouse can choose every photo and still not read any of it.
1 of 10 groups affected
- No vision (not affected)
- Low vision (not affected)
- Colour vision (not affected)
- No hearing (not affected)
- Hard of hearing (not affected)
- No speech (not affected)
- Motor (affected)
- Reach, strength (not affected)
- Cognitive (not affected)
- Seizures (not affected)
- Limited manipulation The zoom starts only from a moving mouse, and nothing on the photo takes focus, so keyboard, switch and voice control users can change the photo but never enlarge it, and can't read what only the zoom shows.
The audit can't press a key and watch a photo grow. What it can see is the mark a zoom library leaves: the attributes and elements that Drift, elevateZoom, jQuery Zoom, Magento's magnifier and Shopify's Dawn theme, with its zoom set to Click and hover, add. When a photo carries one, sits in no link, and nothing near it that Tab reaches says it zooms, enlarges or opens the photo, the audit sends a lead, ew:hover-zoom-manual-check, for a person to check. A zoom written by hand, like the one in this example, leaves no such mark, and no check finds it.
A lead is not a finding: a page may offer the same detail in a way the audit doesn't know, such as a separate photo of the label. And no lead is not a pass: a button nearby whose words say "Zoom" stops the lead even if it opens something else. axe has nothing to check here: the photo is an image with alt text, and that passes.
Try it
Read the small print on the back of the mug, first with the mouse, then with Tab alone
Show the back with its thumbnail and move the mouse over the photo. Then put the mouse aside and Tab on from the thumbnails: focus goes past the photo to Add to cart.
Apply a fix and use the control it adds; once the photo is large, the arrow keys move it.
Broken Can you fix this?
Enamel mug
$24
The fix
Let the keyboard reach the detail the hover zoom shows
<div class="gallery"> <div class="photo-frame"> <img class="photo" src="mug-front.jpg" alt="Front of the mug"> </div> <div class="thumbs">…</div></div>What is wrong3 points
- The zoom starts only from
mousemove, and leaves onmouseleave. No key sets off either. - Nothing in the gallery takes focus for the zoom: no button, no link, and the frame has no Tab stop.
- So the keyboard can change the photo but never see its detail.
A Zoom button over a box that scrolls
<div class="gallery"> <button type="button" class="zoom">Zoom in</button> <div class="photo-frame" role="region" aria-label="Zoomed photo"> <img class="photo" src="mug-front.jpg" alt="Front of the mug"> </div> <div class="thumbs">…</div></div>How it is fixed5 steps
- Add a Zoom in button over the photo, ahead of it in the page, so Tab meets it first.
- When it is pressed, make the photo three times as wide inside a frame that scrolls, and start from the middle of the photo.
- Give the frame a Tab stop while it is zoomed, and a role and a name, so Tab reaches it, a screen reader can say what it is, and the arrow keys move around the photo. Take the Tab stop off again when it zooms out.
- Change the button's words to Zoom out while the photo is zoomed, so it says what the next press does.
- Leave the zoom that follows the mouse in place as a shortcut, and switch it off while the button has the photo zoomed.
This fixes the Before and passes 2.1.1. The zoomed photo needs a large enough file behind it to keep its detail sharp at three times the width.
Why this fix: Make a gesture a shortcut, never the only way
Each one keeps the hover zoom for people with a mouse. The Zoom button and the dialog pass in any browser; the link passes only where the browser lets the keyboard enlarge the file it opens. They differ in what the person sees when they ask for more. The Zoom button stays in place and takes the least room in the design, but the view is no larger than the photo's own box, which is small on a phone. The dialog gives the photo most of the screen, and is a usual form on product pages: WooCommerce, when a theme turns on both its gallery zoom and its lightbox, keeps the hover zoom and adds a control that opens the photo, and Shopify's Dawn theme opens the photo from a button by default. It costs a little more markup, and the rest of the page is out of reach until it closes. The link takes only a few lines and has little to break, but it takes the person away from the page and leaves the enlarging to the browser. WooCommerce's gallery has one under its hover zoom: each photo sits in a link to its full-size file. Choose it when there is no time for more, or as the fallback underneath a dialog, so the larger photo can still be reached if the script fails.
The zoom's frame needs a Tab stop only while it scrolls, so the first fix adds tabindex when it zooms and takes it off again. A stop that does nothing at rest is one more for a keyboard user to pass.
A page that serves smaller files to small screens with srcset shows a smaller file in currentSrc. Point the dialog and the link at the largest file instead, kept in a data attribute beside src and changed with it, as Drift does with data-zoom.
A main photo that opens larger when the bare image is clicked fails 2.1.1 in the same way as the hover zoom. Put a button beside it, as the dialog fix does, or wrap the photo in a link to the large file, which is what PhotoSwipe asks for in its markup and what Fancybox's own example shows: a link can open the lightbox when the script has loaded, and the file when it hasn't. A lens drawn over the photo can stay, since it needs no focus of its own.
On a touch screen there is no hover. Drift starts its zoom from a touch by default, and WooCommerce switches jQuery Zoom to a tap on touch screens, so the zoom often still works there; the fixes' controls work on a touch screen too, and don't depend on the library's choice.
Adding tabindex="0" to the photo and starting the zoom on focus gives a Tab stop that shows one fixed part of the photo, with no way to move to the rest.
Verify the fix
5 checks, no mouse.
Test with: Keyboard, Speech input, Forced colors
Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the gallery, its library or its theme changes.
Limits
This is a starting pattern, not a guarantee for every application. It covers how the keyboard reaches the detail a hover zoom shows. The thumbnails that change the photo are in product photo thumbnails that need a mouse or say nothing. A lightbox has its own needs for focus and closing: see modals that leave keyboard focus behind them. A photo viewer that turns or zooms by dragging, pinching or tilting is in pinch, drag and tilt gestures with no button. The browser's own zoom and a screen magnifier enlarge the photo as drawn on the page; they are the person's tools, and this guide is about the zoom the page adds.
This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.
EaseWeb service
Fixed it? Keep it from coming back.
I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.