UNPKG

arrowtab

Version:

Use arrow keys to "tab" between focusable elements

15 lines 626 B
export const getEuclideanDistance = ({ xDistance, yDistance, }) => { return Math.sqrt(xDistance ** 2 + yDistance ** 2); }; export const manhattan = ({ xDistance, yDistance, }) => { return Math.abs(xDistance) + Math.abs(yDistance); }; export const manhattanWeighted = ({ xDistance, yDistance, event, }) => { if (event.key === 'ArrowDown' || event.key === 'ArrowUp') { return Math.abs(xDistance) + Math.abs(yDistance) * 0.1; } if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') { return Math.abs(xDistance) * 0.1 + Math.abs(yDistance); } }; //# sourceMappingURL=distances.js.map