fixes
This commit is contained in:
parent
7418213b66
commit
6d44c1e1ac
5 changed files with 7 additions and 8 deletions
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
@ -22,7 +22,7 @@ Then the ball will be positioned relatively to the field:
|
|||
}
|
||||
```
|
||||
|
||||
Next we need to assign the correct `ball.style.position.left/top`. They contain field-relative coordinates now.
|
||||
Next we need to assign the correct `ball.style.left/top`. They contain field-relative coordinates now.
|
||||
|
||||
Here's the picture:
|
||||
|
||||
|
@ -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, not center, would be under the mouse cursor.
|
||||
Normally, `ball.style.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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue