Skip to content

Commit 6bd31dc

Browse files
authored
Update article.md
1 parent ab1a699 commit 6bd31dc

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

2-ui/2-events/05-dispatch-events/article.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ alert(event.clientX); // undefined, the unknown property is ignored!
234234
</script>
235235
```
236236

237-
ترتیب خروجی این است: 1 -> nested -> 2.
238-
237+
ترتیب خروجی این است: 1 -> تودرتو (nested) -> 2
239238
لطفاً توجه داشته باشید که منوی رویداد تودرتو که باز است در `document` وجود دارد. انتشار و مدیریت رویداد تودرتو قبل از اینکه پردازش به کد خارجی بازگردد (`onclick`) به پایان می رسد.
240239

241240
این فقط مربوط به `dispatchEvent` نیست، موارد دیگری نیز وجود دارد. اگر یک کنترل کننده رویداد متدهایی را فراخوانی کند که رویدادهای دیگر را راه‌اندازی می‌کنند، آنها نیز به صورت همزمان و به صورت تودرتو پردازش می‌شوند.
@@ -269,23 +268,23 @@ alert(event.clientX); // undefined, the unknown property is ignored!
269268

270269
## Summary
271270

272-
To generate an event from code, we first need to create an event object.
271+
برای تولید یک event code، ابتدا باید یک event object ایجاد کنیم.
273272

274-
The generic `Event(name, options)` constructor accepts an arbitrary event name and the `options` object with two properties:
275-
- `bubbles: true` if the event should bubble.
276-
- `cancelable: true` if the `event.preventDefault()` should work.
273+
سازنده `Event(name, options)` یک نام رویداد دلخواه و `options` object را با دو ویژگی می‌پذیرد:
274+
- `bubbles: true` اگر رویداد باید حباب شود.
275+
- `cancelable: true` اگر `event.preventDefault()` باید کار کند.
277276

278-
Other constructors of native events like `MouseEvent`, `KeyboardEvent` and so on accept properties specific to that event type. For instance, `clientX` for mouse events.
277+
سایر سازنده‌های native events مانند `MouseEvent`, `KeyboardEvent` و غیره ویژگی‌های خاص آن نوع رویداد را می‌پذیرند. به عنوان مثال، `clientX` برای رویدادهای ماوس.
279278

280-
For custom events we should use `CustomEvent` constructor. It has an additional option named `detail`, we should assign the event-specific data to it. Then all handlers can access it as `event.detail`.
279+
برای custom events باید از سازنده `CustomEvent` استفاده کنیم. این یک گزینه اضافی به نام `detail` دارد، ما باید داده های رویداد خاص را به آن اختصاص دهیم. سپس همه کنترل کننده ها می توانند به عنوان `event.detail` به آن دسترسی داشته باشند.
281280

282-
Despite the technical possibility of generating browser events like `click` or `keydown`, we should use them with great care.
281+
علیرغم امکان فنی ایجاد browser events مانند `click` یا `keydown`، ما باید با دقت زیادی از آنها استفاده کنیم.
283282

284-
We shouldn't generate browser events as it's a hacky way to run handlers. That's bad architecture most of the time.
283+
ما نباید browser events را ایجاد کنیم زیرا این یک روش هک برای اجرای کنترلرها است. این معماری در بیشتر مواقع بد است.
285284

286-
Native events might be generated:
285+
هم چنین native events ممکن است ایجاد شوند:
287286

288-
- As a dirty hack to make 3rd-party libraries work the needed way, if they don't provide other means of interaction.
289-
- For automated testing, to "click the button" in the script and see if the interface reacts correctly.
287+
- به عنوان یک dirty hack برای اینکه کتابخانه های شخص ثالث به روش مورد نیاز کار کنند، اگر ابزارهای تعامل دیگری را ارائه ندهند.
288+
- برای تست خودکار، روی دکمه "click the button" در اسکریپت و ببینید که آیا رابط به درستی واکنش نشان می دهد.
290289

291-
Custom events with our own names are often generated for architectural purposes, to signal what happens inside our menus, sliders, carousels etc.
290+
همک چنین custom events با نام خود ما اغلب برای مقاصد معماری ایجاد می شوند تا نشان دهند که چه اتفاقی در منوها، اسلایدر ها و غیره می افتد.

0 commit comments

Comments
 (0)