From 22f63efcf425d67e64573bdd7558050d8f8aea83 Mon Sep 17 00:00:00 2001 From: Thang Huynh Quoc Date: Sun, 10 May 2020 13:34:47 +0700 Subject: [PATCH 1/3] Translate Introduction: callbacks's chapter --- .../01-animate-circle-callback/task.md | 14 +- 1-js/11-async/01-callbacks/article.md | 125 +++++++++--------- 2 files changed, 68 insertions(+), 71 deletions(-) diff --git a/1-js/11-async/01-callbacks/01-animate-circle-callback/task.md b/1-js/11-async/01-callbacks/01-animate-circle-callback/task.md index 4a20ca604..63241ae09 100644 --- a/1-js/11-async/01-callbacks/01-animate-circle-callback/task.md +++ b/1-js/11-async/01-callbacks/01-animate-circle-callback/task.md @@ -1,15 +1,15 @@ -# Animated circle with callback +# Hiệu ứng hình tròn với hàm gọi lại -In the task an animated growing circle is shown. +Trong bài tập này sẽ hiển thị hiệu ứng phát triển hình tròn. -Now let's say we need not just a circle, but to show a message inside it. The message should appear *after* the animation is complete (the circle is fully grown), otherwise it would look ugly. +Hiện tại có thể nói ta chưa cần có một hình tròn, nhưng ta cần hiển thị thông báo trong nó. Thông báo cần được xuất hiện *sau* khi hiệu ứng hoàn thành (hình tròn đã phát triển lớn nhất), mặt khác thì nó sẽ trông xấu xí. -In the solution of the task, the function `showCircle(cx, cy, radius)` draws the circle, but gives no way to track when it's ready. +Giải pháp trong bài tập này, có hàm `showCircle(cx, cy, radius)` vẽ ra hình tròn nhưng không đưa cách nào để biết nó đã sẵn sàng. -Add a callback argument: `showCircle(cx, cy, radius, callback)` to be called when the animation is complete. The `callback` should receive the circle `
` as an argument. +Thêm biến có tên callback: `showCircle(cx, cy, radius, callback)` để được gọi sau khi hiệu ứng hoàn thành. `callback` nên nhận hình tròn `
` như là một biến truyền vào. -Here's the example: +Đây là ví dụ: ```js showCircle(150, 150, 100, div => { @@ -22,4 +22,4 @@ Demo: [iframe src="solution" height=260] -Take the solution of the task as the base. +Lấy cách làm của bài như cơ sở. diff --git a/1-js/11-async/01-callbacks/article.md b/1-js/11-async/01-callbacks/article.md index c2f67c6cc..8f8c0b744 100644 --- a/1-js/11-async/01-callbacks/article.md +++ b/1-js/11-async/01-callbacks/article.md @@ -1,10 +1,10 @@ -# Introduction: callbacks +# Giới thiệu: callbacks -Many actions in JavaScript are *asynchronous*. +Có rất nhiều hành động trong Javascript là *bất đồng bộ*. -For instance, take a look at the function `loadScript(src)`: +Có ví dụ sau, hãy nhìn vào hàm `loadScript(src)`: ```js function loadScript(src) { @@ -14,41 +14,41 @@ function loadScript(src) { } ``` -The purpose of the function is to load a new script. When it adds the `