Skip to content

Commit 6d7d1a5

Browse files
authored
Update article.md
1 parent a3969ad commit 6d7d1a5

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,11 @@ alert(event.clientX); // undefined, the unknown property is ignored!
130130
لیست کاملی از property ها برای event های مختلف UI به تفکیک، برای مثال، [MouseEvent](https://www.w3.org/TR/uievents/#mouseevent).
131131

132132
## Custom events
133+
برای انواع events های کاملاً جدید خودمان مانند `"hello"` باید از "CustomEvent جدید" استفاده کنیم. از نظر فنی [CustomEvent](https://dom.spec.whatwg.org/#customevent) با «رویداد» یکسان است،البته با یک استثنا.
133134

134-
For our own, completely new events types like `"hello"` we should use `new CustomEvent`. Technically [CustomEvent](https://dom.spec.whatwg.org/#customevent) is the same as `Event`, with one exception.
135+
در آرگومان دوم (object) می‌توانیم یک ویژگی «detail» برای هر اطلاعات که می‌خواهیم با event ارسال کنیم، اضافه کنیم.
135136

136-
In the second argument (object) we can add an additional property `detail` for any custom information that we want to pass with the event.
137-
138-
For instance:
137+
برای مثال:
139138

140139
```html run refresh
141140
<h1 id="elem">Hello for John!</h1>
@@ -153,10 +152,9 @@ For instance:
153152
}));
154153
</script>
155154
```
155+
ویژگی "detail" می تواند هر داده ای را داشته باشد. از نظر فنی می‌توانیم بدون آن زندگی کنیم، زیرا می‌توانیم هر ویژگی را پس از ایجاد یک شی `new Event` معمولی به آن اختصاص دهیم. اما `CustomEvent` فیلد `detail` ویژه ای را برای جلوگیری از conflicts با سایر properti های رویداد فراهم می کند.
156156

157-
The `detail` property can have any data. Technically we could live without, because we can assign any properties into a regular `new Event` object after its creation. But `CustomEvent` provides the special `detail` field for it to evade conflicts with other event properties.
158-
159-
Besides, the event class describes "what kind of event" it is, and if the event is custom, then we should use `CustomEvent` just to be clear about what it is.
157+
علاوه بر این، event class توضیح می‌دهد که «چه نوع رویدادی» است، و اگر event is custom است، باید از `CustomEvent` استفاده کنیم تا مشخص شود که چیست.
160158

161159
## event.preventDefault()
162160

0 commit comments

Comments
 (0)