The calculation for x/y (line 33, 34 in direction-reveal.js) is not correct. The right parenthesis for the normalization is set wrong. Correct calculation:
let x = (e.pageX - position.x - (w / 2)) (w > h ? (h / w) : 1);
let y = (e.pageY - position.y - (h / 2)) (h > w ? (w / h) : 1);
This causes a correct normalization for aspect ratios of the hovered element not equal 1, and subsequently the correct calculation of the direction.
The calculation for x/y (line 33, 34 in direction-reveal.js) is not correct. The right parenthesis for the normalization is set wrong. Correct calculation: let x = (e.pageX - position.x - (w / 2)) (w > h ? (h / w) : 1); let y = (e.pageY - position.y - (h / 2)) (h > w ? (w / h) : 1); This causes a correct normalization for aspect ratios of the hovered element not equal 1, and subsequently the correct calculation of the direction.