Skip to content

Commit 185d24f

Browse files
committed
translate SyntheticEvent page
1 parent 5358bae commit 185d24f

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

content/docs/reference-events.md

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ layout: docs
66
category: Reference
77
---
88

9-
This reference guide documents the `SyntheticEvent` wrapper that forms part of React's Event System. See the [Handling Events](/docs/handling-events.html) guide to learn more.
9+
Tìa liệu này nhằm giải thích `SyntheticEvent` trong Hệ thống Event của React. Xem [Handling Events](/docs/handling-events.html) để biết thêm chi tiết.
1010

11-
## Overview {#overview}
11+
## Tổng quan {#overview}
1212

13-
Your event handlers will be passed instances of `SyntheticEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers.
13+
Các hàm xử lý sự kiện sẽ được truyền vào một instance của `SyntheticEvent` (một lớp bọc các event để triệt tiêu sự khác nhau về event của các trình duyệt). No có giao diện (interface) tương tự như một event của trình duyệt, bao gồm `stopPropagation()`, và `preventDefault()` và hoạt động giống nhau cho mọi trình duyệt.
1414

15-
If you find that you need the underlying browser event for some reason, simply use the `nativeEvent` attribute to get it. Every `SyntheticEvent` object has the following attributes:
15+
Nếu bạn cần lấy event thật từ trình duyệt vì một lý do nào đó, chỉ cần sử dụng thuộc tính `nativeEvent` là được. Mọi `SyntheticEvent` object đều có những thuộc tính sau:
1616

1717
```javascript
1818
boolean bubbles
@@ -31,19 +31,19 @@ number timeStamp
3131
string type
3232
```
3333

34-
> Note:
34+
> Ghi chú:
3535
>
36-
> As of v0.14, returning `false` from an event handler will no longer stop event propagation. Instead, `e.stopPropagation()` or `e.preventDefault()` should be triggered manually, as appropriate.
36+
> Từ bản v0.14, hàm xử lý event trả về `false` sẽ không ngừng sự lan truyền của event đó. `e.stopPropagation()` hoặc `e.preventDefault()` phải được gọi để ngăn event đó đi tiếp.
3737
38-
### Event Pooling {#event-pooling}
38+
### Gộp Event {#event-pooling}
3939

40-
The `SyntheticEvent` is pooled. This means that the `SyntheticEvent` object will be reused and all properties will be nullified after the event callback has been invoked.
41-
This is for performance reasons.
42-
As such, you cannot access the event in an asynchronous way.
40+
Một `SyntheticEvent` sẽ được gộp lại nghĩa là event object sẽ được sử dụng lại và tất cả thuộc tính trong object đó sẽ bị gán null sau khi hàm xử lý event chạy xong.
41+
Việc làm này nhằm tăng hiệu suất.
42+
Vì vậy, bạn không thể dùng event object một cách asynchronous. Ví dụ:
4343

4444
```javascript
4545
function onClick(event) {
46-
console.log(event); // => nullified object.
46+
console.log(event); // => object có thuộc tính sẽ bị null sau khi sử dụng.
4747
console.log(event.type); // => "click"
4848
const eventType = event.type; // => "click"
4949

@@ -52,23 +52,23 @@ function onClick(event) {
5252
console.log(eventType); // => "click"
5353
}, 0);
5454

55-
// Won't work. this.state.clickEvent will only contain null values.
55+
// Không chạy. this.state.clickEvent sẽ là một object có tất cả thuộc tính null.
5656
this.setState({clickEvent: event});
5757

58-
// You can still export event properties.
58+
// Bạn vẫn có thể giữ thuộc tính đó do nó là primitive.
5959
this.setState({eventType: event.type});
6060
}
6161
```
6262

63-
> Note:
63+
> Ghi chú:
6464
>
65-
> If you want to access the event properties in an asynchronous way, you should call `event.persist()` on the event, which will remove the synthetic event from the pool and allow references to the event to be retained by user code.
65+
> Nếu bạn muốn giữ lại thuộc tính của event sau khi chạy hàm xử lý, bạn phải gọi `event.persist()` để tách event object ra khỏi nhóm gộp và giữ lại các thuộc tính của nó.
6666
67-
## Supported Events {#supported-events}
67+
## Các Events được hỗ trợ {#supported-events}
6868

69-
React normalizes events so that they have consistent properties across different browsers.
69+
React chuẩn hoá các event để chúng hoạt động giống nhau trên các trình duyệt khác nhau.
7070

71-
The event handlers below are triggered by an event in the bubbling phase. To register an event handler for the capture phase, append `Capture` to the event name; for example, instead of using `onClick`, you would use `onClickCapture` to handle the click event in the capture phase.
71+
Các hàm xử lý event được thực thi trong lúc event bubble lên. Nếu muốn gán hàm xử lý vào lúc capture xuống của event, thêm hậu tố Capture vào sau tên event, ví dụ `onClickCapture`.
7272

7373
- [Clipboard Events](#clipboard-events)
7474
- [Composition Events](#composition-events)
@@ -85,21 +85,21 @@ The event handlers below are triggered by an event in the bubbling phase. To reg
8585
- [Image Events](#image-events)
8686
- [Animation Events](#animation-events)
8787
- [Transition Events](#transition-events)
88-
- [Other Events](#other-events)
88+
- [Events khác](#other-events)
8989

9090
* * *
9191

92-
## Reference {#reference}
92+
## Tài liệu tham khảo {#reference}
9393

9494
### Clipboard Events {#clipboard-events}
9595

96-
Event names:
96+
Tên Event:
9797

9898
```
9999
onCopy onCut onPaste
100100
```
101101

102-
Properties:
102+
Thuộc tính:
103103

104104
```javascript
105105
DOMDataTransfer clipboardData
@@ -109,13 +109,13 @@ DOMDataTransfer clipboardData
109109

110110
### Composition Events {#composition-events}
111111

112-
Event names:
112+
Tên Event:
113113

114114
```
115115
onCompositionEnd onCompositionStart onCompositionUpdate
116116
```
117117

118-
Properties:
118+
Thuộc tính:
119119

120120
```javascript
121121
string data
@@ -124,15 +124,15 @@ string data
124124

125125
* * *
126126

127-
### Keyboard Events {#keyboard-events}
127+
### Event bàn phím {#keyboard-events}
128128

129-
Event names:
129+
Tên Event:
130130

131131
```
132132
onKeyDown onKeyPress onKeyUp
133133
```
134134

135-
Properties:
135+
Thuộc tính:
136136

137137
```javascript
138138
boolean altKey
@@ -149,21 +149,21 @@ boolean shiftKey
149149
number which
150150
```
151151

152-
The `key` property can take any of the values documented in the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values).
152+
Thuộc tính `key` sẽ có những giá trị như trong [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values).
153153

154154
* * *
155155

156156
### Focus Events {#focus-events}
157157

158-
Event names:
158+
Tên Event:
159159

160160
```
161161
onFocus onBlur
162162
```
163163

164-
These focus events work on all elements in the React DOM, not just form elements.
164+
Những event focus sẽ hoạt động trên tất cả React DOM, không chỉ trong form.
165165

166-
Properties:
166+
Thuộc tính:
167167

168168
```javascript
169169
DOMEventTarget relatedTarget
@@ -173,29 +173,29 @@ DOMEventTarget relatedTarget
173173

174174
### Form Events {#form-events}
175175

176-
Event names:
176+
Tên Event:
177177

178178
```
179179
onChange onInput onInvalid onSubmit
180180
```
181181

182-
For more information about the onChange event, see [Forms](/docs/forms.html).
182+
Xem thêm thông tin về Form Event ở [Forms](/docs/forms.html).
183183

184184
* * *
185185

186-
### Mouse Events {#mouse-events}
186+
### Event chuột {#mouse-events}
187187

188-
Event names:
188+
Tên Event:
189189

190190
```
191191
onClick onContextMenu onDoubleClick onDrag onDragEnd onDragEnter onDragExit
192192
onDragLeave onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
193193
onMouseMove onMouseOut onMouseOver onMouseUp
194194
```
195195

196-
The `onMouseEnter` and `onMouseLeave` events propagate from the element being left to the one being entered instead of ordinary bubbling and do not have a capture phase.
196+
Event `onMouseEnter` `onMouseLeave` lan ra từ element được rời đi và không có capture.
197197

198-
Properties:
198+
Thuộc tính:
199199

200200
```javascript
201201
boolean altKey
@@ -218,18 +218,18 @@ boolean shiftKey
218218

219219
### Pointer Events {#pointer-events}
220220

221-
Event names:
221+
Tên Event:
222222

223223
```
224224
onPointerDown onPointerMove onPointerUp onPointerCancel onGotPointerCapture
225225
onLostPointerCapture onPointerEnter onPointerLeave onPointerOver onPointerOut
226226
```
227227

228-
The `onPointerEnter` and `onPointerLeave` events propagate from the element being left to the one being entered instead of ordinary bubbling and do not have a capture phase.
228+
Event `onPointerEnter` `onPointerLeave` lan ra từ element được rời đi và không có capture.
229229

230-
Properties:
230+
Thuộc tính:
231231

232-
As defined in the [W3 spec](https://www.w3.org/TR/pointerevents/), pointer events extend [Mouse Events](#mouse-events) with the following properties:
232+
Như trong [W3 spec](https://www.w3.org/TR/pointerevents/), Pointer events được thêm vào từ [Mouse Events](#mouse-events) và có những thuộc tính sau:
233233

234234
```javascript
235235
number pointerId
@@ -244,17 +244,17 @@ string pointerType
244244
boolean isPrimary
245245
```
246246

247-
A note on cross-browser support:
247+
Ghi chú về hỗ trợ trình duyệt
248248

249-
Pointer events are not yet supported in every browser (at the time of writing this article, supported browsers include: Chrome, Firefox, Edge, and Internet Explorer). React deliberately does not polyfill support for other browsers because a standard-conform polyfill would significantly increase the bundle size of `react-dom`.
249+
Pointer events chưa được hỗ trợ trong tất cả trình duyệt (tại thời điểm viết bài này, những trình duyệt được hỗ trợ: Chrome, Firefox, Edge, and Internet Explorer)). React không cố để polyfill cho những trình duyệt khác vì nó sẽ làm `react-dom` anng85 hơn rất nhiều.
250250

251-
If your application requires pointer events, we recommend adding a third party pointer event polyfill.
251+
Nếu bạn cần pointer event, chúng tôi khuyến khích thêm polyfill cho nó.
252252

253253
* * *
254254

255255
### Selection Events {#selection-events}
256256

257-
Event names:
257+
Tên Event:
258258

259259
```
260260
onSelect
@@ -264,13 +264,13 @@ onSelect
264264

265265
### Touch Events {#touch-events}
266266

267-
Event names:
267+
Tên Event:
268268

269269
```
270270
onTouchCancel onTouchEnd onTouchMove onTouchStart
271271
```
272272

273-
Properties:
273+
Thuộc tính:
274274

275275
```javascript
276276
boolean altKey
@@ -287,13 +287,13 @@ DOMTouchList touches
287287

288288
### UI Events {#ui-events}
289289

290-
Event names:
290+
Tên Event:
291291

292292
```
293293
onScroll
294294
```
295295

296-
Properties:
296+
Thuộc tính:
297297

298298
```javascript
299299
number detail
@@ -304,13 +304,13 @@ DOMAbstractView view
304304

305305
### Wheel Events {#wheel-events}
306306

307-
Event names:
307+
Tên Event:
308308

309309
```
310310
onWheel
311311
```
312312

313-
Properties:
313+
Thuộc tính:
314314

315315
```javascript
316316
number deltaMode
@@ -323,7 +323,7 @@ number deltaZ
323323

324324
### Media Events {#media-events}
325325

326-
Event names:
326+
Tên Event:
327327

328328
```
329329
onAbort onCanPlay onCanPlayThrough onDurationChange onEmptied onEncrypted
@@ -336,7 +336,7 @@ onTimeUpdate onVolumeChange onWaiting
336336

337337
### Image Events {#image-events}
338338

339-
Event names:
339+
Tên Event:
340340

341341
```
342342
onLoad onError
@@ -346,13 +346,13 @@ onLoad onError
346346

347347
### Animation Events {#animation-events}
348348

349-
Event names:
349+
Tên Event:
350350

351351
```
352352
onAnimationStart onAnimationEnd onAnimationIteration
353353
```
354354

355-
Properties:
355+
Thuộc tính:
356356

357357
```javascript
358358
string animationName
@@ -364,13 +364,13 @@ float elapsedTime
364364

365365
### Transition Events {#transition-events}
366366

367-
Event names:
367+
Tên Event:
368368

369369
```
370370
onTransitionEnd
371371
```
372372

373-
Properties:
373+
Thuộc tính:
374374

375375
```javascript
376376
string propertyName
@@ -382,7 +382,7 @@ float elapsedTime
382382

383383
### Other Events {#other-events}
384384

385-
Event names:
385+
Tên Event:
386386

387387
```
388388
onToggle

0 commit comments

Comments
 (0)