Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cn): translate content/docs/reference-events.md into Chinese #101

Merged
merged 6 commits into from
Mar 12, 2019

Conversation

Ryanhui
Copy link
Contributor

@Ryanhui Ryanhui commented Feb 16, 2019

No description provided.

@netlify
Copy link

netlify bot commented Feb 16, 2019

Deploy preview for cn-reactjs ready!

Built with commit ae22e81

https://deploy-preview-101--cn-reactjs.netlify.com

@QC-L QC-L added the Pending Review 已翻译,待校对阶段 label Feb 16, 2019
@@ -52,23 +49,23 @@ function onClick(event) {
console.log(eventType); // => "click"
}, 0);

// Won't work. this.state.clickEvent will only contain null values.
// 无用,this.state.clickEvent 会只包含 null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 无用,this.state.clickEvent 会只包含 null
// 不起作用,this.state.clickEvent 的值将会只包含 null

@QC-L QC-L added Pending Modify 已校对,待修改阶段 and removed Pending Review 已翻译,待校对阶段 labels Feb 16, 2019
@Ryanhui
Copy link
Contributor Author

Ryanhui commented Feb 17, 2019

已修改

@QC-L QC-L added Pending Review 已翻译,待校对阶段 and removed Pending Review 已翻译,待校对阶段 labels Feb 17, 2019
@QC-L QC-L mentioned this pull request Feb 17, 2019
@QC-L QC-L added Pending Re-Review 已修改,待审校阶段 and removed Pending Modify 已校对,待修改阶段 labels Feb 21, 2019

## Overview {#overview}
## 概述 {#overview}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## 概述 {#overview}
## 概览 {#overview}

FYI: #2

@@ -6,13 +6,13 @@ layout: docs
category: Reference
---

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.
此参考指南记录了构成 React 事件系统一部分的 `SyntheticEvent` 包装器。参考 [Handling Events](/docs/handling-events.html) 指南学习更多。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
此参考指南记录了构成 React 事件系统一部分的 `SyntheticEvent` 包装器。参考 [Handling Events](/docs/handling-events.html) 指南学习更多
此参考指南记录了构成 React 事件系统一部分的 `SyntheticEvent` 包装器。请参考有关[事件处理](/docs/handling-events.html)的指南来了解更多

@@ -6,13 +6,13 @@ layout: docs
category: Reference
---

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

标题翻译为 合成事件 ?


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.
`SyntheticEvent` 实例将被传递给你的事件处理程序,这是一个浏览器原生事件的跨浏览器包装器。除了在所有浏览器间完全相同的事件,它有着和浏览器原生事件相同的接口,包括 `stopPropagation()` `preventDefault()`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`SyntheticEvent` 实例将被传递给你的事件处理程序,这是一个浏览器原生事件的跨浏览器包装器。除了在所有浏览器间完全相同的事件,它有着和浏览器原生事件相同的接口,包括 `stopPropagation()``preventDefault()`
`SyntheticEvent` 实例将被传递给你的事件处理函数,它是浏览器的原生事件的跨浏览器包装器。除兼容所有浏览器外,它还拥有和浏览器原生事件相同的接口,包括 `stopPropagation()``preventDefault()`


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:
如果因为某些原因,你需要使用浏览器的底层事件,只需要使用 `nativeEvent` 属性实现。每个 `SyntheticEvent` 对象有以下属性:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
如果因为某些原因,你需要使用浏览器的底层事件,只需要使用 `nativeEvent` 属性实现。每个 `SyntheticEvent` 对象有以下属性
当你需要使用浏览器的底层事件时,只需要使用 `nativeEvent` 属性来获取即可。每个 `SyntheticEvent` 对象都包含以下属性

>
> 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.
> 截止 v0.14 ,事件处理程序返回 `false` 不再阻止事件传播。相反,`e.stopPropagation()` 或者 `e.preventDefault()` 应适当的手动触发。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> 截止 v0.14 ,事件处理程序返回 `false` 不再阻止事件传播。相反,`e.stopPropagation()` 或者 `e.preventDefault()` 应适当的手动触发
> 截止 v0.14,当事件处理函数返回 `false` 时,不再阻止事件冒泡。你可以选择使用 `e.stopPropagation()` 或者 `e.preventDefault()` 替代


React normalizes events so that they have consistent properties across different browsers.
React 使事件正常化,所以他们在不同浏览器中有一致的属性。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
React 使事件正常化,所以他们在不同浏览器中有一致的属性
React 使事件规范化,因此它们在不同浏览器中拥有相同的属性


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.
以下的事件处理函数在冒泡阶段被事件触发。要在注册捕获阶段的事件处理函数,需要为事件名称添加 `Capture` 。例如,不是使用 `onClick` ,而是使用 `onClickCapture` 处理捕获阶段的点击事件。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
以下的事件处理函数在冒泡阶段被事件触发。要在注册捕获阶段的事件处理函数,需要为事件名称添加 `Capture` 。例如,不是使用 `onClick` ,而是使用 `onClickCapture` 处理捕获阶段的点击事件
以下的事件处理函数在冒泡阶段被触发。如需注册捕获阶段的事件处理函数,则应为事件名添加 `Capture`。例如,处理捕获阶段的点击事件请使用 `onClickCapture`,而不是 `onClick`


```
onClick onContextMenu onDoubleClick onDrag onDragEnd onDragEnter onDragExit
onDragLeave onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
onMouseMove onMouseOut onMouseOver onMouseUp
```
`onMouseEnter` 和 `onMouseLeave` 事件从离开的元素向进入的元素传播,不是正常的冒泡,也没有捕获阶段。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`onMouseEnter``onMouseLeave` 事件从离开的元素向进入的元素传播,不是正常的冒泡,也没有捕获阶段。
`onMouseEnter``onMouseLeave` 事件从离开的元素向进入的元素传播,不是正常的冒泡,也没有捕获阶段。


```
onPointerDown onPointerMove onPointerUp onPointerCancel onGotPointerCapture
onLostPointerCapture onPointerEnter onPointerLeave onPointerOver onPointerOut
```
`onPointerEnter` 和 `onPointerLeave` 事件从离开的元素向进入的元素传播,不是正常的冒泡,也没有捕获阶段。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`onPointerEnter``onPointerLeave` 事件从离开的元素向进入的元素传播,不是正常的冒泡,也没有捕获阶段。
`onPointerEnter``onPointerLeave` 事件从离开的元素向进入的元素传播,不是正常的冒泡,也没有捕获阶段。


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`.
并非每个浏览器都支持指针事件(在写这篇文章时,支持的浏览器有:ChromeFirefoxEdge,和 Internet Explorer)。React 有意没有通过 polyfill 支持其他浏览器,因为符合标准的 polyfill 会显著增加 react-dom 的包大小。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
并非每个浏览器都支持指针事件(在写这篇文章时,支持的浏览器有:Chrome,Firefox,Edge和 Internet Explorer)。React 有意没有通过 polyfill 支持其他浏览器,因为符合标准的 polyfill 会显著增加 react-dom 的包大小
并非每个浏览器都支持指针事件(在写这篇文章时,已支持的浏览器有:Chrome,Firefox,Edge 和 Internet Explorer)。React 故意不通过 polyfill 的方式适配其他浏览器,主要是符合标准的 polyfill 会显著增加 react-dom 的 bundle 大小

@netlify
Copy link

netlify bot commented Mar 12, 2019

Deploy preview for zh-hans-reactjs ready!

Built with commit ae22e81

https://deploy-preview-101--zh-hans-reactjs.netlify.com

QC-L
QC-L previously approved these changes Mar 12, 2019

React normalizes events so that they have consistent properties across different browsers.
React 使事件规范化,因此它们在不同浏览器中拥有相同的属性。
Copy link

@thoamsy thoamsy Mar 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React 通过将事件 normalize 以让它们在不同浏览器中拥有一致的属性?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ryanhui 修改下~

@hijiangtao hijiangtao merged commit 299594c into reactjs:master Mar 12, 2019
permalink: docs/events.html
layout: docs
category: Reference
---

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.
此参考指南记录了构成 React 事件系统一部分的 `SyntheticEvent` 包装器。请参考有关[事件处理](/docs/handling-events.html)的指南来了解更多。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此参考指南记录了构成 React 事件系统一部分的 SyntheticEvent 包装器。请参考事件处理的指南来了解更多。

  • 不需要「有关」吧,这个文档直接就是讲「事件处理」的呀


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:
如果因为某些原因,当你需要使用浏览器的底层事件时,只需要使用 `nativeEvent` 属性来获取即可。每个 `SyntheticEvent` 对象都包含以下属性:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当你出于某些原因,必须使用浏览器的底层事件时,你只需使用 nativeEvent 属性即可获取。每个 SyntheticEvent 对象都包含以下属性:

>
> 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.
> 截止 v0.14,当事件处理函数返回 `false` 时,不再阻止事件冒泡。你可以选择使用 `e.stopPropagation()` 或者 `e.preventDefault()` 替代。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自 v0.14 起,从事件处理函数中返回 false 将不再阻止事件冒泡。更恰当的做法是使用 e.stopPropagation() 或者 e.preventDefault() 手动触发。


If your application requires pointer events, we recommend adding a third party pointer event polyfill.
如果你的应用要求指针事件,我们推荐添加第三方的指针事件 polyfil 。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果你的应用需要用到指针事件,我们建议你添加第三方的指针事件 polyfill。

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不过,这个 React 是不是已经支持了?

OhIAmFine pushed a commit to OhIAmFine/zh-hans.reactjs.org that referenced this pull request May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending Re-Review 已修改,待审校阶段
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants