You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/2-events/05-dispatch-events/article.md
+13-14Lines changed: 13 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -234,8 +234,7 @@ alert(event.clientX); // undefined, the unknown property is ignored!
234
234
</script>
235
235
```
236
236
237
-
ترتیب خروجی این است: 1 -> nested -> 2.
238
-
237
+
ترتیب خروجی این است: 1 -> تودرتو (nested) -> 2
239
238
لطفاً توجه داشته باشید که منوی رویداد تودرتو که باز است در `document` وجود دارد. انتشار و مدیریت رویداد تودرتو قبل از اینکه پردازش به کد خارجی بازگردد (`onclick`) به پایان می رسد.
240
239
241
240
این فقط مربوط به `dispatchEvent` نیست، موارد دیگری نیز وجود دارد. اگر یک کنترل کننده رویداد متدهایی را فراخوانی کند که رویدادهای دیگر را راهاندازی میکنند، آنها نیز به صورت همزمان و به صورت تودرتو پردازش میشوند.
@@ -269,23 +268,23 @@ alert(event.clientX); // undefined, the unknown property is ignored!
269
268
270
269
## Summary
271
270
272
-
To generate an event from code, we first need to create an event object.
271
+
برای تولید یک event code، ابتدا باید یک event object ایجاد کنیم.
273
272
274
-
The generic`Event(name, options)`constructor accepts an arbitrary event name and the `options` object with two properties:
سازنده `Event(name, options)`یک نام رویداد دلخواه و `options` object را با دو ویژگی میپذیرد:
274
+
-`bubbles: true`اگر رویداد باید حباب شود.
275
+
-`cancelable: true` اگر`event.preventDefault()`باید کار کند.
277
276
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`برای رویدادهای ماوس.
279
278
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` به آن دسترسی داشته باشند.
281
280
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`، ما باید با دقت زیادی از آنها استفاده کنیم.
283
282
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 را ایجاد کنیم زیرا این یک روش هک برای اجرای کنترلرها است. این معماری در بیشتر مواقع بد است.
285
284
286
-
Native events might be generated:
285
+
هم چنین native events ممکن است ایجاد شوند:
287
286
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" در اسکریپت و ببینید که آیا رابط به درستی واکنش نشان می دهد.
290
289
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