All files / src/gestures/utils event-type.ts

85.71% Statements 6/7
50% Branches 2/4
100% Functions 2/2
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1834x       84x       84x     34x     293x 293x    
export function isMouseEvent(
    event: MouseEvent | TouchEvent | PointerEvent
): event is MouseEvent {
    // PointerEvent inherits from MouseEvent so we can't use a straight instanceof check.
    Iif (typeof PointerEvent !== "undefined" && event instanceof PointerEvent) {
        return !!(event.pointerType === "mouse")
    }
 
    return event instanceof MouseEvent
}
 
export function isTouchEvent(
    event: MouseEvent | TouchEvent | PointerEvent
): event is TouchEvent {
    const hasTouches = !!(event as TouchEvent).touches
    return hasTouches
}