refactor(web): centralize touch mouse adapters
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getTouchPoint, resolveTouchDragDecision } from "./timelineTouch.js";
|
||||
import { createTouchMouseDownEvent, getTouchPoint, resolveTouchDragDecision } from "./timelineTouch.js";
|
||||
|
||||
describe("timelineTouch", () => {
|
||||
it("falls back from active touches to changedTouches and then zeroes", () => {
|
||||
@@ -72,4 +72,25 @@ describe("timelineTouch", () => {
|
||||
shouldHandleDrag: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("creates a primary-button mouse-down adapter for touch handlers", () => {
|
||||
const currentTarget = new EventTarget();
|
||||
|
||||
expect(createTouchMouseDownEvent({ clientX: 42, clientY: 17 }, currentTarget)).toMatchObject({
|
||||
button: 0,
|
||||
clientX: 42,
|
||||
currentTarget,
|
||||
shiftKey: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("allows missing targets when creating a touch mouse-down adapter", () => {
|
||||
const event = createTouchMouseDownEvent({ clientX: 7, clientY: 9 });
|
||||
|
||||
expect(event.currentTarget).toBeNull();
|
||||
expect(() => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user