Skip to content

Commit e7c0145

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

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,19 @@ alert(event.clientX); // undefined, the unknown property is ignored!
158158

159159
## event.preventDefault()
160160

161-
Many browser events have a "default action", such as navigating to a link, starting a selection, and so on.
161+
بسیاری از رویدادهای مرورگر دارای یک "default action" هستند، مانند پیمایش یک لینک، شروع یک انتخاب و غیره.
162162

163-
For new, custom events, there are definitely no default browser actions, but a code that dispatches such event may have its own plans what to do after triggering the event.
163+
برای event های جدید و custom events، قطعاً هیچ اقدام پیش‌فرض مرورگر وجود ندارد، اما کدی که چنین رویدادی را ارسال می‌کند ممکن است برنامه‌های خاص خود را داشته باشد که پس از راه‌اندازی رویداد چه کاری انجام دهد.
164164

165-
By calling `event.preventDefault()`, an event handler may send a signal that those actions should be canceled.
165+
با فراخوانی `event.preventDefault()`، یک کنترل کننده رویداد ممکن است سیگنالی ارسال کند که آن اقدامات باید لغو شوند.
166166

167-
In that case the call to `elem.dispatchEvent(event)` returns `false`. And the code that dispatched it knows that it shouldn't continue.
167+
در آن صورت فراخوانی به `elem.dispatchEvent(event)` false برمی گردد. و کدی که آن را ارسال کرده می داند که نباید ادامه یابد.
168168

169-
Let's see a practical example - a hiding rabbit (could be a closing menu or something else).
169+
بیایید یک مثال عملی ببینیم - یک خرگوش پنهان (ممکن است منوی بسته شدن یا چیز دیگری باشد).
170170

171-
Below you can see a `#rabbit` and `hide()` function that dispatches `"hide"` event on it, to let all interested parties know that the rabbit is going to hide.
171+
در زیر می‌توانید یک تابع #rabbit and hide() را مشاهده کنید که رویداد "hide" را روی آن ارسال می‌کند تا به همه علاقه‌مندان اطلاع دهد که خرگوش قرار است مخفی شود.
172172

173-
Any handler can listen for that event with `rabbit.addEventListener('hide',...)` and, if needed, cancel the action using `event.preventDefault()`. Then the rabbit won't disappear:
173+
هر کنترل‌کننده‌ای می‌تواند با `rabbit.addEventListener('hide',...)` به آن رویداد گوش دهد و در صورت نیاز، عمل را با استفاده از `event.preventDefault()` لغو کند. سپس خرگوش ناپدید نمی شود:
174174

175175
```html run refresh autorun
176176
<pre id="rabbit">
@@ -201,8 +201,7 @@ Any handler can listen for that event with `rabbit.addEventListener('hide',...)`
201201
});
202202
</script>
203203
```
204-
205-
Please note: the event must have the flag `cancelable: true`, otherwise the call `event.preventDefault()` is ignored.
204+
نکته: event حتما باید flag `cancelable: true` را داشته باشد یا اینکه `event.preventDefault()` فراخوانی نمیشود.
206205

207206
## Events-in-events are synchronous
208207

0 commit comments

Comments
 (0)