UNPKG

arrowtab

Version:

Use arrow keys to "tab" between focusable elements

15 lines 502 B
import { getXyDistance } from './getXyDistance.js'; export const getAngle = ({ activeElement, element, }) => { const { xDistance, yDistance } = getXyDistance({ activeElement, element, }); let angle = Math.acos(yDistance / Math.sqrt(xDistance ** 2 + yDistance ** 2)) * (180 / Math.PI); const direction = xDistance > 0 ? 'right' : 'left'; if (direction === 'right') { angle = 360 - angle; } return angle; }; //# sourceMappingURL=getAngle.js.map