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..1c8dbfeda 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,25 +1,22 @@ +# انیمیشن دایره با فراخوانی +در تمرینِ یک دایره با که انیمیشن گذاری بزرگ میشود نشان داده شده است. -# Animated circle with callback +حالا برای ما فقط یک دایره کافی نیست ما میخواهیم یک پیغام درون آن داشته باشیم. پیغام باید *بعد * از تمام شدن انیمیشن به نمایش دربیاید (دایره کامل بزرگ شود) در غیر اینصورت زننده و بدشکل خواهد بود. +در راه حل داده شده برای تمرین تابع `showCircle(cx, cy, radius)` یک دایره رسم میکند ولی چیزی برای نشان دادن اتمام آن وجود ندارد. -In the task an animated growing circle is shown. +یک آرگومانِ فراخوان به آن اضافه کنید که در زمان اتمام انیمیشن اجرا شود : `showCircle(cx, cy, raduis, callback)`. +تابع `callback` باید `
` را به عنوان آرگومان بگیرد. -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. - -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. - -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. - -Here's the example: +و یک مثال: ```js showCircle(150, 150, 100, div => { - div.classList.add('message-ball'); - div.append("Hello, world!"); + div.classList.add("message-ball"); + div.append("Hello, world!"); }); ``` +پیش نمایش: -Demo: - -[iframe src="solution" height=260] +[iframe src="solution" height=250] -Take the solution of the task as the base. +راه حل اراعه شده در تمرینِ را به عنوان پایه استفاده کنید. \ No newline at end of file diff --git a/1-js/11-async/01-callbacks/article.md b/1-js/11-async/01-callbacks/article.md index 344d92b74..8ad216c69 100644 --- a/1-js/11-async/01-callbacks/article.md +++ b/1-js/11-async/01-callbacks/article.md @@ -1,241 +1,205 @@ +# مقدمه: فراخوان - -# Introduction: callbacks - -```warn header="We use browser methods in examples here" -To demonstrate the use of callbacks, promises and other abstract concepts, we'll be using some browser methods: specifically, loading scripts and performing simple document manipulations. - -If you're not familiar with these methods, and their usage in the examples is confusing, you may want to read a few chapters from the [next part](/document) of the tutorial. - -Although, we'll try to make things clear anyway. There won't be anything really complex browser-wise. ``` +برای نشان دادن استفاده فراخوانها و قول ها و دیگر مفاهیم معنوی از بعضی متد های مرورگر استفاده خواهیم کرد به ویژه بازگذاری اسکریپت ها و اعمال کردن تغییرات ساده در سند. +اگر به این متدها و کاربردشان در مثال ها آشنا نیستید بهتره که از [next part](/document) قسمت های بعدی را بخوانید. +به هر حال ما تلاش میکنیم همه چیز را واضح و شفاف بیان کنیم. و از نظر مرورگر پیچیده نیستند. +``` -Many functions are provided by JavaScript host environments that allow you to schedule *asynchronous* actions. In other words, actions that we initiate now, but they finish later. +در محیط های جاوااسکریپت برخی توابع ساخته شده اند که به شما اجازه میدهند اعمال و اتفاقات را به صورت *ناهمگام* برنامه ریزی کنید و انجام دهید.به عبارت دیگر اعنالی را الان تعریف کنیم ولی بعدا انجام شوند. -For instance, one such function is the `setTimeout` function. +برای مثال تابع ‍`setTimeout` از این نوع توابع است. -There are other real-world examples of asynchronous actions, e.g. loading scripts and modules (we'll cover them in later chapters). +مثال هی واقعیتری نیز از کارهای ناهمگام وجود دارند. مثلا بازگذاری اسکریپت ها و ماژول ها(بعدا توضیح داده میشوند) -Take a look at the function `loadScript(src)`, that loads a script with the given `src`: +یک نگاه به تابع `loadScript(src)` بندازیم که یک اسکریپت را با `src` داده شده بارگذاری میکند. -```js -function loadScript(src) { - // creates a