-
Notifications
You must be signed in to change notification settings - Fork 145
feat: support pixel-based scroll gestures #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
471e664
feat: add pixel-based scroll gestures
thymikee b86745c
fix: address remaining scroll review comments
thymikee 2c5fcae
chore: make scroll direction switch exhaustive
thymikee 205bca0
docs: keep readme informational
thymikee 20b7a7a
docs: revert readme changes
thymikee 797a417
refactor: reuse shared apple scroll planning
thymikee 77c15bd
refactor: reduce apple scroll runner churn
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import test from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { dispatchCommand } from '../dispatch.ts'; | ||
| import { AppError } from '../../utils/errors.ts'; | ||
| import type { DeviceInfo } from '../../utils/device.ts'; | ||
|
|
||
| const IOS_DEVICE: DeviceInfo = { | ||
| platform: 'ios', | ||
| id: 'sim-1', | ||
| name: 'iPhone 17 Pro', | ||
| kind: 'simulator', | ||
| booted: true, | ||
| }; | ||
|
|
||
| test('dispatch scroll rejects mixing amount and --pixels', async () => { | ||
| await assert.rejects( | ||
| () => dispatchCommand(IOS_DEVICE, 'scroll', ['down', '0.4'], undefined, { pixels: 240 }), | ||
| (error: unknown) => | ||
| error instanceof AppError && | ||
| error.code === 'INVALID_ARGS' && | ||
| /either a relative amount or --pixels/i.test(error.message), | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import test from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { AppError } from '../../utils/errors.ts'; | ||
| import { buildScrollGesturePlan } from '../scroll-gesture.ts'; | ||
|
|
||
| test('buildScrollGesturePlan maps relative amount to viewport travel', () => { | ||
| const plan = buildScrollGesturePlan({ | ||
| direction: 'down', | ||
| amount: 0.5, | ||
| referenceWidth: 400, | ||
| referenceHeight: 800, | ||
| }); | ||
|
|
||
| assert.deepEqual(plan, { | ||
| direction: 'down', | ||
| x1: 200, | ||
| y1: 600, | ||
| x2: 200, | ||
| y2: 200, | ||
| referenceWidth: 400, | ||
| referenceHeight: 800, | ||
| amount: 0.5, | ||
| pixels: 400, | ||
| }); | ||
| }); | ||
|
|
||
| test('buildScrollGesturePlan clamps pixel travel to the safe gesture band', () => { | ||
| const plan = buildScrollGesturePlan({ | ||
| direction: 'right', | ||
| pixels: 500, | ||
| referenceWidth: 300, | ||
| referenceHeight: 600, | ||
| }); | ||
|
|
||
| assert.equal(plan.x1, 285); | ||
| assert.equal(plan.x2, 15); | ||
| assert.equal(plan.y1, 300); | ||
| assert.equal(plan.y2, 300); | ||
| assert.equal(plan.pixels, 270); | ||
| }); | ||
|
|
||
| test('buildScrollGesturePlan rejects invalid amounts', () => { | ||
| assert.throws( | ||
| () => | ||
| buildScrollGesturePlan({ | ||
| direction: 'down', | ||
| amount: 0, | ||
| referenceWidth: 400, | ||
| referenceHeight: 800, | ||
| }), | ||
| (error: unknown) => | ||
| error instanceof AppError && | ||
| error.code === 'INVALID_ARGS' && | ||
| /amount must be a positive number/i.test(error.message), | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.