Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/component/sequence/SequenceDOMRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export class SequenceDOMRenderer {
filter(
(touchEvent: TouchEvent): boolean => {
return touchEvent.touches.length === 0;
})))
})),
this._container.touchService.touchCancel$)
.subscribe(
(): void => {
if (this._changingSpeed) {
Expand Down
21 changes: 21 additions & 0 deletions test/component/sequence/SequenceComponent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@ describe("SequenceComponent.activate", () => {
expect(setGraphModeSpy.calls.argsFor(0)[0]).toBe(GraphMode.Spatial);
});

it("should reset changing position to spatial on touchcancel (Android gesture takeover)", () => {
const setGraphModeSpy: jasmine.Spy = <jasmine.Spy>navigatorMock.graphService.setGraphMode;

const touchCancelSubject$: Subject<TouchEvent> =
<Subject<TouchEvent>>containerMock.touchService.touchCancel$;

const component: SequenceComponent = createComponent();
component.activate();

// Simulate a scrubber drag that latches the renderer's changing-position
// flag (the state the touchcancel handler checks).
(<any>renderer)._setChangingPosition(true);
expect(setGraphModeSpy.calls.mostRecent().args[0]).toBe(GraphMode.Sequence);

// A touchcancel (gesture takeover / notification shade / second finger)
// must be treated like a terminal release and restore Spatial mode.
touchCancelSubject$.next({ touches: [] } as unknown as TouchEvent);

expect(setGraphModeSpy.calls.mostRecent().args[0]).toBe(GraphMode.Spatial);
});

it("should stop play when changing position", () => {
const stopSpy: jasmine.Spy = <jasmine.Spy>navigatorMock.playService.stop;

Expand Down
1 change: 1 addition & 0 deletions test/helper/TouchServiceMockCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class TouchServiceMockCreator extends MockCreatorBase<TouchService> {
this._mockProperty(mock, "singleTouchDrag$", new Subject<TouchEvent>());
this._mockProperty(mock, "singleTouchDragEnd$", new Subject<TouchEvent>());
this._mockProperty(mock, "touchEnd$", new Subject<TouchEvent>());
this._mockProperty(mock, "touchCancel$", new Subject<TouchEvent>());
this._mockProperty(mock, "touchMove$", new Subject<TouchEvent>());
this._mockProperty(mock, "touchStart$", new Subject<TouchEvent>());

Expand Down