This commit is contained in:
Ilya Kantor 2017-06-17 19:00:42 +03:00
parent 749e6e164b
commit d67c04c22f
6 changed files with 48 additions and 55 deletions

View file

@ -45,8 +45,8 @@
// the ball has position:absolute, the field: position:relative
// so ball coordinates are relative to the field inner left-upper corner
let ballCoords = {
top: event.clientY - fieldInnerCoords.top - field.clientTop - ball.clientHeight / 2,
left: event.clientX - fieldInnerCoords.left - field.clientLeft - ball.clientWidth / 2
top: event.clientY - fieldCoords.top - field.clientTop - ball.clientHeight / 2,
left: event.clientX - fieldCoords.left - field.clientLeft - ball.clientWidth / 2
};
// prevent crossing the top field boundary