All files / react-native-web/src/modules/useResponderEvents ResponderEventTypes.js

100% Statements 20/20
100% Branches 11/11
100% Functions 6/6
100% Lines 20/20

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 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82                                                                                      17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x     381x       412x       297x       275x       250x       250x    
/**
 * Copyright (c) Nicolas Gallagher
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */
 
export type Touch = {
  force: number,
  identifier: number,
  // The locationX and locationY properties are non-standard additions
  locationX: any,
  locationY: any,
  pageX: number,
  pageY: number,
  target: any,
  // Touches in a list have a timestamp property
  timestamp: number
};
 
export type TouchEvent = {
  altKey: boolean,
  ctrlKey: boolean,
  metaKey: boolean,
  shiftKey: boolean,
  // TouchList is an array in the Responder system
  changedTouches: Array<Touch>,
  force: number,
  // React Native adds properties to the "nativeEvent that are usually only found on W3C Touches ‾\_(ツ)_/‾
  identifier: number,
  locationX: any,
  locationY: any,
  pageX: number,
  pageY: number,
  target: any,
  // The timestamp has a lowercase "s" in the Responder system
  timestamp: number,
  // TouchList is an array in the Responder system
  touches: Array<Touch>
};
 
export const BLUR = 'blur';
export const CONTEXT_MENU = 'contextmenu';
export const FOCUS_OUT = 'focusout';
export const MOUSE_DOWN = 'mousedown';
export const MOUSE_MOVE = 'mousemove';
export const MOUSE_UP = 'mouseup';
export const MOUSE_CANCEL = 'dragstart';
export const TOUCH_START = 'touchstart';
export const TOUCH_MOVE = 'touchmove';
export const TOUCH_END = 'touchend';
export const TOUCH_CANCEL = 'touchcancel';
export const SCROLL = 'scroll';
export const SELECT = 'select';
export const SELECTION_CHANGE = 'selectionchange';
 
export function isStartish(eventType: mixed): boolean {
  return eventType === TOUCH_START || eventType === MOUSE_DOWN;
}
 
export function isMoveish(eventType: mixed): boolean {
  return eventType === TOUCH_MOVE || eventType === MOUSE_MOVE;
}
 
export function isEndish(eventType: mixed): boolean {
  return eventType === TOUCH_END || eventType === MOUSE_UP || isCancelish(eventType);
}
 
export function isCancelish(eventType: mixed): boolean {
  return eventType === TOUCH_CANCEL || eventType === MOUSE_CANCEL;
}
 
export function isScroll(eventType: mixed): boolean {
  return eventType === SCROLL;
}
 
export function isSelectionChange(eventType: mixed): boolean {
  return eventType === SELECT || eventType === SELECTION_CHANGE;
}