Debian Codegraph @

src/inputjs/get-scale.js

raw
1 import { PROPS_CLIENT_XY } from './input-consts';
2 import getDistance from './get-distance';
3 /**
4 * @private
5 * calculate the scale factor between two pointersets
6 * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
7 * @param {Array} start array of pointers
8 * @param {Array} end array of pointers
9 * @return {Number} scale
10 */
11 export default function getScale(start, end) {
12 return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
13 }