-
Notifications
You must be signed in to change notification settings - Fork 161
fix(nav-drawer): preserve single-tap actions on iOS #17473
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
21 commits
Select commit
Hold shift + click to select a range
f2a2893
fix(nav-drawer): preserve single-tap actions on iOS
viktorkombov 784df09
chore(*): add a missing semicolon
viktorkombov 1ae5d73
refactor(touch): reset gesture tracking consistently
viktorkombov 69d487a
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
viktorkombov 826f563
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
viktorkombov 2881b88
Merge branch 'master' into vkombov/fix-17472
viktorkombov 79752a7
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular…
viktorkombov d1afb7a
Merge branch 'vkombov/fix-17472' of https://github.com/IgniteUI/ignit…
viktorkombov e174201
test(touch): dispatch native touch events
viktorkombov 59325e7
Merge branch 'master' into vkombov/fix-17472
kdinev 2f7255f
Change touchmove event to use TouchEvent
kdinev 00dc082
Merge branch 'master' into vkombov/fix-17472
kdinev 9cc026a
fix(*): prevent unintended drawer toggling on fast touch movements
viktorkombov f655a22
Merge branch 'master' into vkombov/fix-17472
kdinev ec4e277
Merge branch 'master' into vkombov/fix-17472
rkaraivanov c079fce
Merge branch 'master' into vkombov/fix-17472
kdinev e4bb558
Merge branch 'master' into vkombov/fix-17472
viktorkombov 7fa6830
Merge branch 'master' into vkombov/fix-17472
kdinev addeb5a
Merge branch 'master' into vkombov/fix-17472
kdinev fc40a0c
Merge branch 'master' into vkombov/fix-17472
kdinev cd7de6a
Merge branch 'master' into vkombov/fix-17472
kdinev 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import { IgxTouchManager } from './touch'; | ||
|
|
||
| describe('IgxTouchManager', () => { | ||
| let manager: IgxTouchManager; | ||
| let target: HTMLDivElement; | ||
|
|
||
| beforeEach(() => { | ||
| target = document.createElement('div'); | ||
| document.body.appendChild(target); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| manager?.destroy(); | ||
| target.remove(); | ||
| }); | ||
|
|
||
| it('should stop tracking when pointerDown vetoes the gesture', () => { | ||
| const panStart = jasmine.createSpy('panStart'); | ||
| const panMove = jasmine.createSpy('panMove'); | ||
| manager = new IgxTouchManager(target, { | ||
| pointerDown: () => false, | ||
| panStart, | ||
| panMove | ||
| }); | ||
|
|
||
| dispatchPointerEvent(target, 'pointerdown', 10, 10); | ||
| const touchMove = dispatchTouchMove(target); | ||
| dispatchPointerEvent(target, 'pointermove', 30, 10); | ||
|
|
||
| expect(touchMove.defaultPrevented).toBeFalse(); | ||
| expect(panStart).not.toHaveBeenCalled(); | ||
| expect(panMove).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should preserve native touch behavior until the pan threshold is exceeded', () => { | ||
| const panStart = jasmine.createSpy('panStart'); | ||
| const panMove = jasmine.createSpy('panMove'); | ||
| manager = new IgxTouchManager(target, { | ||
| panStart, | ||
| panMove | ||
| }, { panAxis: 'horizontal', panThreshold: 5 }); | ||
|
|
||
| dispatchPointerEvent(target, 'pointerdown', 10, 10); | ||
| const initialTouchMove = dispatchTouchMove(target); | ||
| dispatchPointerEvent(target, 'pointermove', 13, 10); | ||
| const candidateTouchMove = dispatchTouchMove(target); | ||
|
|
||
| expect(initialTouchMove.defaultPrevented).toBeFalse(); | ||
| expect(candidateTouchMove.defaultPrevented).toBeFalse(); | ||
| expect(panStart).not.toHaveBeenCalled(); | ||
| expect(panMove).not.toHaveBeenCalled(); | ||
|
|
||
| dispatchPointerEvent(target, 'pointermove', 11, 20); | ||
| const verticalTouchMove = dispatchTouchMove(target); | ||
|
|
||
| expect(verticalTouchMove.defaultPrevented).toBeFalse(); | ||
| expect(panStart).not.toHaveBeenCalled(); | ||
| expect(panMove).not.toHaveBeenCalled(); | ||
|
|
||
| dispatchPointerEvent(target, 'pointermove', 16, 10); | ||
| const activePanTouchMove = dispatchTouchMove(target); | ||
|
|
||
| expect(panStart).toHaveBeenCalledTimes(1); | ||
| expect(panMove).toHaveBeenCalledTimes(1); | ||
| expect(activePanTouchMove.defaultPrevented).toBeTrue(); | ||
| }); | ||
|
|
||
| it('should not emit swipe when movement stays below the pan threshold', () => { | ||
| const panStart = jasmine.createSpy('panStart'); | ||
| const panMove = jasmine.createSpy('panMove'); | ||
| const swipe = jasmine.createSpy('swipe'); | ||
| spyOn(Date, 'now').and.returnValues(0, 1, 1); | ||
| manager = new IgxTouchManager(target, { panStart, panMove, swipe }, { panThreshold: 5 }); | ||
|
|
||
| dispatchPointerEvent(target, 'pointerdown', 10, 10); | ||
| dispatchPointerEvent(target, 'pointermove', 13, 10); | ||
| dispatchPointerEvent(target, 'pointerup', 13, 10); | ||
|
|
||
| expect(panStart).not.toHaveBeenCalled(); | ||
| expect(panMove).not.toHaveBeenCalled(); | ||
| expect(swipe).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| for (const endX of [13, 16]) { | ||
| it(`should emit swipe before panEnd after a recognized pan ending at x=${endX}`, () => { | ||
| const swipe = jasmine.createSpy('swipe'); | ||
| const panEnd = jasmine.createSpy('panEnd'); | ||
| spyOn(Date, 'now').and.returnValues(0, 1, 2); | ||
| manager = new IgxTouchManager(target, { swipe, panEnd }, { panThreshold: 5 }); | ||
|
|
||
| dispatchPointerEvent(target, 'pointerdown', 10, 10); | ||
| dispatchPointerEvent(target, 'pointermove', 16, 10); | ||
| dispatchPointerEvent(target, 'pointerup', endX, 10); | ||
|
|
||
| expect(swipe).toHaveBeenCalledTimes(1); | ||
| expect(panEnd).toHaveBeenCalledTimes(1); | ||
| expect(swipe).toHaveBeenCalledBefore(panEnd); | ||
| expectTrackingStateToBeReset(manager); | ||
| }); | ||
| } | ||
|
|
||
| for (const eventType of ['pointerup', 'pointercancel']) { | ||
| it(`should reset tracking state on ${eventType}`, () => { | ||
| manager = new IgxTouchManager(target, {}); | ||
|
|
||
| dispatchPointerEvent(target, 'pointerdown', 10, 10); | ||
| dispatchPointerEvent(target, 'pointermove', 20, 10); | ||
| dispatchPointerEvent(target, eventType, 20, 10); | ||
|
|
||
| expectTrackingStateToBeReset(manager); | ||
| }); | ||
| } | ||
|
|
||
| it('should reset tracking state when destroyed', () => { | ||
| manager = new IgxTouchManager(target, {}); | ||
|
|
||
| dispatchPointerEvent(target, 'pointerdown', 10, 10); | ||
| dispatchPointerEvent(target, 'pointermove', 20, 10); | ||
| manager.destroy(); | ||
|
|
||
| expectTrackingStateToBeReset(manager); | ||
| }); | ||
| }); | ||
|
|
||
| function expectTrackingStateToBeReset(manager: IgxTouchManager): void { | ||
| expect((manager as any)._tracking).toBeFalse(); | ||
| expect((manager as any)._panStarted).toBeFalse(); | ||
| expect((manager as any)._pointerId).toBeNull(); | ||
| expect((manager as any)._startTarget).toBeNull(); | ||
| } | ||
|
|
||
| function dispatchPointerEvent(target: EventTarget, type: string, clientX: number, clientY: number): void { | ||
| target.dispatchEvent(new PointerEvent(type, { | ||
| bubbles: true, | ||
| cancelable: true, | ||
| pointerId: 1, | ||
| pointerType: 'touch', | ||
| clientX, | ||
| clientY | ||
| })); | ||
| } | ||
|
|
||
| function dispatchTouchMove(target: EventTarget): TouchEvent { | ||
| const event = new TouchEvent('touchmove', { bubbles: true, cancelable: true }); | ||
| target.dispatchEvent(event); | ||
| return event; | ||
| } |
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
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.