Skip to content

Commit efbf871

Browse files
committed
Changed 'fieldInnerCoords' to 'fieldCoords' to match image and text
1 parent 23b5766 commit efbf871

File tree

1 file changed

+2
-2
lines changed
  • 2-ui/2-events/01-introduction-browser-events/04-move-ball-field

1 file changed

+2
-2
lines changed

2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ We have `event.clientX/clientY` -- window-relative coordinates of the click.
3333
To get field-relative `left` coordinate of the click, we can substract the field left edge and the border width:
3434

3535
```js
36-
let left = event.clientX - fieldInnerCoords.left - field.clientLeft;
36+
let left = event.clientX - fieldCoords.left - field.clientLeft;
3737
```
3838

3939
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.
@@ -43,7 +43,7 @@ We need to move the ball half-width left and half-height up to make it center.
4343
So the final `left` would be:
4444

4545
```js
46-
let left = event.clientX - fieldInnerCoords.left - field.clientLeft - ball.offsetWidth/2;
46+
let left = event.clientX - fieldCoords.left - field.clientLeft - ball.offsetWidth/2;
4747
```
4848

4949
The vertical coordinate is calculated using the same logic.

0 commit comments

Comments
 (0)