Library: drag a horizontal chip strip to scroll it on a pointer device
The body-part and equipment filters in the Library (and the exercise picker, the muscle explorer) are `.chips` rows that overflow sideways. On a phone you swipe them; index.css hides the scrollbar. On a desktop browser there was no way to reach the chips past the right edge — a mouse wheel scrolls the page, and there's no visible handle. lib/hchips.js adds a click-drag: press anywhere on a strip and pull it along, the way a swipe does on a phone. One delegated pointerdown listener on the document. - 6px slop before a press becomes a drag, so a click still selects a chip - the click the browser fires after a drag is swallowed, so releasing over a chip doesn't toggle that filter - mouse only (pointerType 'touch'/'pen' already scroll natively); primary button only; non-overflowing rows are left alone - grab / grabbing cursor as the hint, on rows that actually overflow (data-xscroll, set on hover), gated to (hover:hover) and (pointer:fine) Closes #68 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DBkhHLqWtSYrPdsNE11PiP
This commit is contained in:
1 parent
acff80348f
commit
fc555f57ce
4 files changed
+217
No files matched your search
@@ -9,6 +9,7 @@ import { setNav } from './lib/nav.js'
|
||||
import { initBackButton } from './lib/back.js'
|
||||
import { useWakeLock } from './lib/wakelock.js'
|
||||
import { installViewportGuard } from './lib/viewport-guard.js'
|
||||
import { installChipDrag } from './lib/hchips.js'
|
||||
import { startFlow } from './sheets.jsx'
|
||||
import Icon from './components/Icon.jsx'
|
||||
import TabBar from './components/TabBar.jsx'
|
||||
@@ -80,6 +81,9 @@ function Shell() {
|
||||
const pathRef = useRef(loc.pathname)
|
||||
// iOS leaves the page displaced after the keyboard goes away (see lib/viewport-guard.js).
|
||||
useEffect(() => installViewportGuard(), [])
|
||||
// Click-drag a horizontal chip strip to scroll it sideways (lib/hchips.js) — on a desktop
|
||||
// browser there's otherwise no way to reach the filters past the edge.
|
||||
useEffect(() => installChipDrag(), [])
|
||||
useEffect(() => {
|
||||
const onScroll = () => {
|
||||
// Modals pins the body while a sheet is open; scrollY is 0 then, not a position.
|
||||
|
||||
Reference in new issue
Block a user