Skip to content

Let the page scroll when a touch moves across a slider - #3099

Open
martin-s-a wants to merge 1 commit into
shoelace-style:nextfrom
martin-s-a:slider-touch-scroll-upstream
Open

martin-s-a wants to merge 1 commit into
shoelace-style:nextfrom
martin-s-a:slider-touch-scroll-upstream

Conversation

@martin-s-a

Copy link
Copy Markdown

Fixes #3098.

On a touch screen, a vertical swipe that started on a horizontal <wa-slider> changed its value instead of scrolling the page: #slider had touch-action: none, and the slider set its value in the drag's start, which DraggableElement runs on pointerdown/touchstart.

  • slider.styles.ts: touch-action: pan-y for a horizontal slider and pan-x for a vertical one, so the slider keeps its own axis and the browser can scroll along the other.
  • drag.ts: a touchAxis option for DraggableElement. When it is set, a touch only starts a drag once it moves 10px along that axis. A touch that doesn't move is a tap, so start and stop run when it ends, and a touch the browser cancels to scroll never starts. Mouse and pen drags start on press as before, and drag() is unchanged.
  • slider.ts: passes touchAxis, from orientation, to the track and thumb draggables of single and range sliders.

Tests: three slider tests with touch pointer events, for a touch the browser cancels before it moves along the slider (the value stays and no events are emitted), a touch released without moving (sets the value) and a touch that only starts dragging after it moves along the slider. The slider group passes in Chromium in both rendering modes, and fails with touchAxis ignored. Firefox and WebKit aren't installed in my environment, so CI is the first run there. I also checked it in Home Assistant's gallery with touch emulation in Chromium 156: a vertical swipe that starts on the slider scrolls the page and leaves the value, including one that drifts sideways and a second swipe during the fling of the first, while a tap, a sideways drag and a mouse press still set it. Not tested on a physical Android or iOS device.

The slider set its value as soon as a touch went down, and touch-action: none kept the browser from scrolling, so a vertical swipe that started on a horizontal slider changed its value instead of scrolling the page. The slider now leaves the other axis to the browser (pan-y, or pan-x when vertical), and DraggableElement gets a touchAxis option: a touch only starts a drag once it moves along that axis, a touch that doesn't move is a tap, and a touch the browser takes over to scroll does nothing. Mouse and pen drags start on press as before.
@vercel

vercel Bot commented Nov 25, 2026

Copy link
Copy Markdown

@martin-s-a is attempting to deploy a commit to the Font Awesome Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swiping across wa-slider on a touch screen changes its value instead of scrolling the page

1 participant