Skip to content

Commit 206dfa7

Browse files
committed
Translate Event: move-ball-field/solution.view
1 parent a9f727e commit 206dfa7

File tree

1 file changed

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

1 file changed

+8
-8
lines changed

2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
<body style="height:2000px">
2929

30-
Click on a field to move the ball there.
30+
Klik pada lapangan untuk memindahkan bola kesana.
3131
<br>
3232

3333

@@ -39,29 +39,29 @@
3939
<script>
4040
field.onclick = function(event) {
4141

42-
// window-relative field coordinates
42+
// Koordinat lapangan relatif terhadap jendela (window)
4343
let fieldCoords = this.getBoundingClientRect();
4444

45-
// the ball has position:absolute, the field: position:relative
46-
// so ball coordinates are relative to the field inner left-upper corner
45+
// bola memiliki position:absolute, lapangan: position:relative
46+
// jadi koordinat bola relatif terhadap sudut dalam kiri atas lapangan
4747
let ballCoords = {
4848
top: event.clientY - fieldCoords.top - field.clientTop - ball.clientHeight / 2,
4949
left: event.clientX - fieldCoords.left - field.clientLeft - ball.clientWidth / 2
5050
};
5151

52-
// prevent crossing the top field boundary
52+
// mencegah melewati batas atas lapangan
5353
if (ballCoords.top < 0) ballCoords.top = 0;
5454

55-
// prevent crossing the left field boundary
55+
// mencegah melewati kiri atas lapangan
5656
if (ballCoords.left < 0) ballCoords.left = 0;
5757

5858

59-
// // prevent crossing the right field boundary
59+
// mencegah melewati batas kanan lapangan
6060
if (ballCoords.left + ball.clientWidth > field.clientWidth) {
6161
ballCoords.left = field.clientWidth - ball.clientWidth;
6262
}
6363

64-
// prevent crossing the bottom field boundary
64+
// mencegah melewati batas bawah lapangan
6565
if (ballCoords.top + ball.clientHeight > field.clientHeight) {
6666
ballCoords.top = field.clientHeight - ball.clientHeight;
6767
}

0 commit comments

Comments
 (0)