Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
let ball = document.getElementById('ball')
let field = document.getElementById('field')

// ball.offsetWidth=0 до того, как изображение загрузилось!
// исправим это, установив ширину:
ball.style.left = Math.round(field.clientWidth / 2) + 'px'
ball.style.top = Math.round(field.clientHeight / 2) + 'px'
// У скрытого поля размеры равны нулю. Измеряем его, когда читатель открывает решение.
new ResizeObserver(() => {
ball.style.left = Math.round(field.clientWidth / 2) + 'px'
ball.style.top = Math.round(field.clientHeight / 2) + 'px'
}).observe(field)
</script>


Expand Down