Skip to content

Commit 71d6a2f

Browse files
committed
Translate Event: carousel
1 parent 790cdc6 commit 71d6a2f

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
The images ribbon can be represented as `ul/li` list of images `<img>`.
1+
Pita gambar bisa di diwakili sebagai `ul/li` daftar dari gambar `<img>`.
22

3-
Normally, such a ribbon is wide, but we put a fixed-size `<div>` around to "cut" it, so that only a part of the ribbon is visible:
3+
Biasanya, pita seperti itu sangat luas, tapi kita akan menambahkan ukuran tetap pada `<div>` untuk "memotong" pita, jadi hanya sebagian dari pita yang kelihatan:
44

55
![](carousel1.svg)
66

7-
To make the list show horizontally we need to apply correct CSS properties for `<li>`, like `display: inline-block`.
7+
Untuk menampilkan daftar secara horisontal kita perlu menambahkan properti CSS yang benar pada `<li>`, seperti `display: inline-block`.
88

9-
For `<img>` we should also adjust `display`, because by default it's `inline`. There's extra space reserved under `inline` elements for "letter tails", so we can use `display:block` to remove it.
9+
Untuk `<img>` kita sebaiknya juga mengatur `display`, karena bawaanya merupakan `inline`. Ada
10+
For `<img>` we should also adjust `display`, because by default it's `inline`. Ada ruang ekstra yang disediakan di bawah elemen `inline` untuk "ekor huruf", jadi kita bisa menggunakan `display:block` untuk menghapusnya.
1011

11-
To do the scrolling, we can shift `<ul>`. There are many ways to do it, for instance by changing `margin-left` or (better performance) use `transform: translateX()`:
12+
Untuk membuat pengulirannya, kita bisa menggeser `<ul>`. Ada banyak cara untuk melakukannya, contohnya dengan menganti `margin-left` atau (performa lebih baik) gunakan `transform: translateX()`:
1213

1314
![](carousel2.svg)
1415

15-
The outer `<div>` has a fixed width, so "extra" images are cut.
16+
`<div>` luar memiliki lebar tetap, jadi gambar "ekstra" dipotong.
1617

17-
The whole carousel is a self-contained "graphical component" on the page, so we'd better wrap it into a single `<div class="carousel">` and style things inside it.
18+
Keseluruhan korsel(_carousel_) adalah "komponen grafis" mandiri pada halaman, jadi sebaiknya kita membungkusnya menjadi satu `<div class="carousel">` dan menata elemen-elemen ke dalamnya.

2-ui/2-events/01-introduction-browser-events/07-carousel/solution.view/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,35 @@
2727
</div>
2828

2929
<script>
30-
/* label the images, just for convenience, to visually track them */
30+
/* Beri label pada gambar untuk memudahkan */
3131
let i = 1;
3232
for(let li of carousel.querySelectorAll('li')) {
3333
li.style.position = 'relative';
3434
li.insertAdjacentHTML('beforeend', `<span style="position:absolute;left:0;top:0">${i}</span>`);
3535
i++;
3636
}
3737

38-
/* configuration */
39-
let width = 130; // image width
40-
let count = 3; // visible images count
38+
/* Konfigurasi */
39+
let width = 130; // Lebar gambar
40+
let count = 3; // Nomor gambar
4141

4242
let list = carousel.querySelector('ul');
4343
let listElems = carousel.querySelectorAll('li');
4444

45-
let position = 0; // ribbon scroll position
45+
let position = 0; // posisi gulir pita
4646

4747
carousel.querySelector('.prev').onclick = function() {
4848
// shift left
4949
position += width * count;
50-
// can't move to the left too much, end of images
50+
// tidak bisa bergerak ke kiri terlalu banyak, gambar terakhir
5151
position = Math.min(position, 0)
5252
list.style.marginLeft = position + 'px';
5353
};
5454

5555
carousel.querySelector('.next').onclick = function() {
5656
// shift right
5757
position -= width * count;
58-
// can only shift the ribbbon for (total ribbon length - visible count) images
58+
// hanya dapat menggeser pita untuk (panjang pita total - jumlah yang terlihat) gambar
5959
position = Math.max(position, -width * (listElems.length - count));
6060
list.style.marginLeft = position + 'px';
6161
};

2-ui/2-events/01-introduction-browser-events/07-carousel/source.view/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<body>
99

10-
<!-- create your markup and styles -->
10+
<!-- buat markup dan style -->
1111

1212
<button class="arrow"></button>
1313
<button class="arrow"></button>
@@ -28,16 +28,16 @@
2828

2929

3030
<script>
31-
// label the images to visually track them, just for convenience,
32-
// this code can be removed
31+
// Beri label pada gambar untuk memudahkan
32+
// kode ini bisa di hapuskan
3333
let i = 1;
3434
for(let li of carousel.querySelectorAll('li')) {
3535
li.style.position = 'relative';
3636
li.insertAdjacentHTML('beforeend', `<span style="position:absolute;left:0;top:0">${i}</span>`);
3737
i++;
3838
}
3939

40-
// ...your code to make carousel alive!
40+
// ...kodemu untuk membuat sebuah korsel(carousel)
4141
</script>
4242

4343
</body>

2-ui/2-events/01-introduction-browser-events/07-carousel/task.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ importance: 4
22

33
---
44

5-
# Carousel
5+
# Korsel (_Carousel_)
66

7-
Create a "carousel" -- a ribbon of images that can be scrolled by clicking on arrows.
7+
Buat sebuah "korsel" --
8+
Create a "carousel" -- pita gambar yang dapat digulir dengan mengklik panah.
89

910
[iframe height=200 src="solution"]
1011

11-
Later we can add more features to it: infinite scrolling, dynamic loading etc.
12+
Nanti kita akan menambahkah lebih banyak fitur: pengguliran tanpa batas, pemuatan dinamis dan seterusnya.
1213

13-
P.S. For this task HTML/CSS structure is actually 90% of the solution.
14+
Tambahan: untuk tugas ini, struktur HTML/CSS merupakan 90% dari solusi.

0 commit comments

Comments
 (0)