UNPKG

rn-zoomable

Version:

A zoomable image component like Instagram

17 lines (13 loc) 373 B
// @flow import type { Touch } from "../types/Touch"; export function pow2abs(a: number, b: number) { return Math.pow(Math.abs(a - b), 2); } function getDistance(touches: Array<Touch>) { const [a, b] = touches; if (a == null || b == null) { return 0; } return Math.sqrt(pow2abs(a.pageX, b.pageX) + pow2abs(a.pageY, b.pageY)); } export default getDistance;