feat(reader): swipe left/right to turn pages in single mode
Wire horizontal swipe into the mobile tap-zone overlay (single mode only, so continuous mode keeps native vertical scroll). A leftward swipe past the threshold turns to the next page, rightward to the previous; a mostly- vertical drag is ignored so panning a tall page never turns it. The gesture suppresses the synthesized zone tap so it doesn't double-fire. Swipe classification is a pure, unit-tested helper; e2e drives real touch pointer events for horizontal (both directions) and vertical cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
20
frontend/src/lib/swipe.test.ts
Normal file
20
frontend/src/lib/swipe.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { swipeDirection } from './swipe';
|
||||
|
||||
describe('swipeDirection', () => {
|
||||
it('classifies a leftward horizontal swipe as next', () => {
|
||||
expect(swipeDirection(-100, 8)).toBe('next');
|
||||
});
|
||||
|
||||
it('classifies a rightward horizontal swipe as prev', () => {
|
||||
expect(swipeDirection(120, -10)).toBe('prev');
|
||||
});
|
||||
|
||||
it('ignores a swipe shorter than the threshold', () => {
|
||||
expect(swipeDirection(-20, 2)).toBeNull();
|
||||
});
|
||||
|
||||
it('ignores a mostly-vertical drag so panning does not turn the page', () => {
|
||||
expect(swipeDirection(-50, 90)).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user