Repository navigation
fix(gestures): a pan on its own scroller takes a trackpad's scroll, as a finger's pan (spec:AST-094 FR43) #10212
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] Gestures: a pan on its own scroller takes a trackpad's scroll on the axis its touch-action keeps, as it takes a finger's; a scroller inside it still takes the wheel first. A recognizer attached with `manageStyle: false` leaves the element's styles to its caller for that recognizer only. | ||
|
|
||
| @vjeux |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3148,6 +3148,37 @@ describe('GestureHost', () => { | |
| expect(lock).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| for (const holdFirst of [false, true]) { | ||
| it(`styles an element for its other recognizers when one attaches with manageStyle: false ${holdFirst ? 'before' : 'after'} them, and restores it when both leave`, () => { | ||
| detachers.push(coarsePrimaryPointer()); | ||
| const {row} = mount('<div id="row">A row a pan and a catch share</div>'); | ||
| const lock = vi.fn(() => () => {}); | ||
| const attachHold = () => | ||
| host.attach( | ||
| row, | ||
| new LongPressGestureRecognizer({name: 'hold', selectionLock: lock}), | ||
| {manageStyle: false}, | ||
| ); | ||
| const detachEarly = holdFirst ? attachHold() : null; | ||
| const detachPan = host.attach( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: these attachments sit outside
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. It is test-only, so it rides this pull request's next push rather than moving the stamped head. |
||
| row, | ||
| new PanGestureRecognizer({name: 'pan', direction: 'horizontal'}), | ||
| ); | ||
| const detachHold = detachEarly ?? attachHold(); | ||
| // The pan's touch-action, and none of the hold's styles or its lock. | ||
| expect(row.getAttribute('data-astryx-touch-action')).toBe( | ||
| 'pan-y pinch-zoom', | ||
| ); | ||
| const finger = {id: 1, x: 5, y: 5}; | ||
| touch('touchstart', row, [finger], [finger], 0); | ||
| touch('touchend', row, [finger], [], 600); | ||
| expect(lock).not.toHaveBeenCalled(); | ||
| detachHold(); | ||
| detachPan(); | ||
| expect(row.hasAttribute('data-astryx-touch-action')).toBe(false); | ||
| }); | ||
| } | ||
|
|
||
| it('a long press brings lockSelection by default', () => { | ||
| expect(new LongPressGestureRecognizer().selectionLock).toBe(lockSelection); | ||
| expect(new TapGestureRecognizer().selectionLock).toBeNull(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This skips the pan's own scroller when its
touch-actionkeeps the axis, butREADME.md's "Wheel and trackpad" paragraph and theallowedScrollTypesJSDoc inGestureRecognizer.tsandPanGestureRecognizer.tsstill say a pan moves only after every scroller under the pointer. Please state the exception there, and that an inner scroller still goes first; the SYNC line at the top of this file names the README.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 581f5e9: the README's "Wheel and trackpad" paragraph and the
allowedScrollTypesJSDoc inGestureRecognizer.tsandPanGestureRecognizer.tsstate the own-scroller exception, and that an inner scroller still goes first.