Skip to content
easeweb
Search topics

Pinch, drag and tilt gestures with no button

A product's 360-degree view turns only by dragging, zooms only by pinching and turns when the phone tilts, with no buttons and no way to stop the tilt.

WCAG 2.2
SC 2.5.1A· new in 2.1SC 2.5.4A· new in 2.1SC 2.5.7AA· new in 2.2
Required by
EN 301 549 (EU)
Broken frame.addEventListener('touchmove', pinchToZoom)
The accessibility problem illustrated: Motor:How do I zoom in with one finger?
01

The problem

People who use one finger, a mouse, a head pointer, a switch, voice control or a screen reader can't turn or zoom the product, and people whose hands or phones move can't stop it turning

02

Try it

Turn the mug round and read the small print on its back, using single clicks or taps only

The slider stands in for tilting a phone. On each side, click or tap the mug once, then move the slider: does the mug hold still until you ask it to turn? Drag and pinch work too, but try without them.

Simulate
0°

Broken Can you fix this?

BrokenA view that only gestures work
Enamel mug
Drag to turn. Pinch to zoom.

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Put every gesture on a button too, and make tilting opt-in

Before
BrokenA view that only gestures work
<figure class="spin-view">  <div class="spin-frame">    <img src="mug-00.jpg" alt="Enamel mug">  </div>  <figcaption>Drag to turn. Pinch to zoom.</figcaption></figure>
What is wrong4 points
  • Someone who can't drag can't turn the mug or move the zoomed photo: both need a drag.
  • Someone with one finger or a mouse can't zoom in at all: zooming needs two fingers.
  • The mug turns whenever the phone moves. Once the first touch has turned the tilt on, nothing turns it off.
  • A keyboard, a switch or voice control can't work the view. Nothing on the page is a control, so a single click, a tap, a key or a spoken command has nothing to act on.
After
FixButtons beside the view, and tilting as a switch
<figure class="spin-view">  <div class="spin-frame" tabindex="0" role="region" aria-label="Zoomed photo">    <img src="mug-00.jpg" alt="Enamel mug">  </div>  <figcaption>Drag to turn. Pinch to zoom.</figcaption>  <div class="spin-controls">    <button type="button" data-turn="-1">Turn left</button>    <button type="button" data-turn="1">Turn right</button>    <button type="button" data-zoom="-1">Zoom out</button>    <button type="button" data-zoom="1">Zoom in</button>    <button type="button" class="tilt-switch" aria-pressed="false" hidden>Turn by tilting the phone</button>  </div></figure>
How it is fixed7 steps
  1. Add Turn left and Turn right buttons. Each press shows the next photo round, so twelve presses go all the way round. A click, a tap, Enter, Space and "Click Turn right" all work, because they are buttons.
  2. Add Zoom in and Zoom out buttons, which step from one to three times, keeping the middle of the view where it was.
  3. Leave moving the zoomed photo to the browser: the frame scrolls, so a mouse uses its scroll bars or wheel, a keyboard the arrow keys once the frame has focus, and a finger flicks it as it would any scrolling box.
  4. Keep the drag and the pinch as shortcuts. The drag now moves the same scroll.
  5. Set touch-action: pan-y, so a finger on the photo scrolls the page past it, and the site still gets two-finger touches for its own pinch.
  6. Make the tilt a switch that does nothing until it is pressed. It reports "on" or "off" through aria-pressed, and pressing it again removes the listener. On iOS, the same press is the tap that Safari needs before it will ask for permission to read the motion sensors.
  7. Show the switch only on a touch device that has motion events.

This fixes the Before and passes 2.5.1, 2.5.4 and 2.5.7.

04

Verify the fix

5 checks.

Test with: Mouse, Touch, Device motion, Keyboard, Speech input, Screen reader

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the viewer or its library changes.

How screen readers handle aria-pressed

Limits

This is a starting pattern, not a guarantee for every viewer. Both 2.5.1 and 2.5.4 make an exception where the gesture or the motion is essential, such as a signature drawn with a finger, a step counter or a game played by tilting; check that claim honestly before relying on it. Other gestures have guides of their own: swiping between slides in carousels that keyboard and screen reader users can't use, dragging a thumb in range sliders that only move by dragging, dragging cards in drag-and-drop boards that only a mouse can use, swiping or long-pressing a row in right-click, long-press and swipe actions with no button, dragging a map to find a place in maps that are the only way to find a location, thumbnails in product photo thumbnails that need a mouse or say nothing, and a zoom that follows the mouse in product photo zoom that needs a mouse. Test the complete journey on the phones and assistive technology your customers use.

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.

See the service