This commit is contained in:
Ilya Kantor 2019-05-16 13:37:21 +03:00
parent 40a4e181be
commit d9740908bf
4 changed files with 5 additions and 5 deletions

View file

@ -36,7 +36,7 @@ To get field-relative `left` coordinate of the click, we can substract the field
let left = event.clientX - fieldCoords.left - field.clientLeft;
```
Normally, `ball.style.position.left` means the "left edge of the element" (the ball). So if we assign that `left`, then the ball edge would be under the mouse cursor.
Normally, `ball.style.position.left` means the "left edge of the element" (the ball). So if we assign that `left`, then the ball edge, not center, would be under the mouse cursor.
We need to move the ball half-width left and half-height up to make it center.