Skip to content

Commit cc1b439

Browse files
committed
translate 01-svelte/05-events into Japanese
1 parent 5eee71e commit cc1b439

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

content/tutorial/01-svelte/05-events/01-dom-events/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: DOM events
33
---
44

5-
As we've briefly seen already, you can listen to any event on an element with the `on:` directive:
5+
今までざっと見てきたように、`on:` ディレクティブを使用して要素の任意のイベントをリスニングできます。
66

77
```svelte
88
<div on:mousemove={handleMousemove}>

content/tutorial/01-svelte/05-events/02-inline-handlers/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
title: Inline handlers
33
---
44

5-
You can also declare event handlers inline:
5+
イベントハンドラをインラインで宣言することもできます。
66

77
```svelte
88
<div on:mousemove="{e => m = { x: e.clientX, y: e.clientY }}">
99
The mouse position is {m.x} x {m.y}
1010
</div>
1111
```
1212

13-
The quote marks are optional, but they're helpful for syntax highlighting in some environments.
13+
`""` 引用符はオプションですが、一部の環境で構文を強調表示する場合に役立ちます。
1414

15-
> In some frameworks you may see recommendations to avoid inline event handlers for performance reasons, particularly inside loops. That advice doesn't apply to Svelte — the compiler will always do the right thing, whichever form you choose.
15+
> 一部のフレームワークでは、パフォーマンス上の理由から、特にループ処理内で、イベントハンドラをインラインで宣言しないように推奨されています。しかし、この推奨事項はSvelteには当てはまりません。あなたがどのように書いたとしても、常に適切にコンパイルします。

content/tutorial/01-svelte/05-events/03-event-modifiers/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Event modifiers
33
---
44

5-
DOM event handlers can have _modifiers_ that alter their behaviour. For example, a handler with a `once` modifier will only run a single time:
5+
DOM イベントハンドラには、それらの動作を変更する修飾子(*modifiers*)を設定することができます。たとえば、`once` 修飾子をハンドラに設定すると、1回だけ実行します。
66

77
```svelte
88
<script>
@@ -16,15 +16,15 @@ DOM event handlers can have _modifiers_ that alter their behaviour. For example,
1616
</button>
1717
```
1818

19-
The full list of modifiers:
19+
イベント修飾子の一覧:
2020

21-
- `preventDefault`calls `event.preventDefault()` before running the handler. Useful for client-side form handling, for example.
22-
- `stopPropagation`calls `event.stopPropagation()`, preventing the event reaching the next element
23-
- `passive`improves scrolling performance on touch/wheel events (Svelte will add it automatically where it's safe to do so)
24-
- `nonpassive`explicitly set `passive: false`
25-
- `capture`fires the handler during the _capture_ phase instead of the _bubbling_ phase ([MDN docs](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture))
26-
- `once`remove the handler after the first time it runs
27-
- `self`only trigger handler if event.target is the element itself
28-
- `trusted`only trigger handler if `event.isTrusted` is `true`. I.e. if the event is triggered by a user action.
21+
* `preventDefault`ハンドラを実行する前に `event.preventDefault()` を呼び出します。たとえば、クライアントのフォーム処理に役立ちます。
22+
* `stopPropagation`次の要素にイベントが伝播しないように `event.stopPropagation()` を呼び出します。
23+
* `passive`タッチ/ホイールイベントでスクロールのパフォーマンスを向上させます(Svelte が安全な場所に自動的に追加します)。
24+
* `nonpassive``passive: false` を明示的に設定します。
25+
* `capture`*バブリング* フェーズではなく、*キャプチャ* フェーズ中にハンドラを起動します。([MDN docs](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture))
26+
* `once`ハンドラを最初に実行した後に削除します。
27+
* `self`設定した要素が event.target の場合にのみ、ハンドラをトリガします。
28+
* `trusted``event.isTrusted` `true` の場合にのみハンドラをトリガします。つまり、ユーザーのアクションによってイベントがトリガされた場合です。
2929

30-
You can chain modifiers together, e.g. `on:click|once|capture={...}`.
30+
イベント修飾子を連結することができます。(例)`on:click|once|capture={...}`

content/tutorial/01-svelte/05-events/04-component-events/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Component events
33
---
44

5-
Components can also dispatch events. To do so, they must create an event dispatcher. Update `Inner.svelte`:
5+
コンポーネントはイベントを発信することもできます。そのためには、イベントディスパッチャを作成する必要があります。`Inner.svelte` を更新してください。
66

77
```svelte
88
<script>
@@ -18,10 +18,10 @@ Components can also dispatch events. To do so, they must create an event dispatc
1818
</script>
1919
```
2020

21-
> `createEventDispatcher` must be called when the component is first instantiated — you can't do it later inside e.g. a `setTimeout` callback. This links `dispatch` to the component instance.
21+
> `createEventDispatcher` はコンポーネントを最初にインスタンス化するときに呼び出す必要があります。(後から `setTimeout` のコールバックなどの内側で呼び出すことはできません。)これにより `dispatch` をコンポーネントインスタンスに関連づけます。
2222
23-
Notice that the `App` component is listening to the messages dispatched by `Inner` component thanks to the `on:message` directive. This directive is an attribute prefixed with `on:` followed by the event name that we are dispatching (in this case, `message`).
23+
`App` コンポーネントは `Inner` コンポーネントによってディスパッチされたメッセージを `on:message` ディレクティブによって受信していることに注目してください。このディレクティブは、`on:` の前にディスパッチするイベント名(この場合は `message`)を付加した属性です。
2424

25-
Without this attribute, messages would still be dispatched, but the App would not react to it. You can try removing the `on:message` attribute and pressing the button again.
25+
この属性がない場合、メッセージはディスパッチされますが、アプリはそれに反応しません。`on:message`属性を削除して、もう一度ボタンを押してみてください。
2626

27-
> You can also try changing the event name to something else. For instance, change `dispatch('message')` to `dispatch('myevent')` in `Inner.svelte` and change the attribute name from `on:message` to `on:myevent` in the `App.svelte` component.
27+
> イベント名を他のものに変更してみることもできます。例えば、`Inner.svelte``dispatch('message')` `dispatch('myevent')` に変更し、`App.svelte` コンポーネントの属性名を `on:message` から `on:myevent` に変更します。

content/tutorial/01-svelte/05-events/05-event-forwarding/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
title: Event forwarding
33
---
44

5-
Unlike DOM events, component events don't _bubble_. If you want to listen to an event on some deeply nested component, the intermediate components must _forward_ the event.
5+
DOM イベントとは異なり、コンポーネントのイベントは *バブル* しません。もし深くネストされたコンポーネントでイベントをリッスンする場合、中間コンポーネントはイベントを *フォワード* する必要があります。
66

7-
In this case, we have the same `App.svelte` and `Inner.svelte` as in the [previous chapter](/tutorial/component-events), but there's now an `Outer.svelte` component that contains `<Inner/>`.
7+
今回のケースでは、[前のチャプタ](/tutorial/component-events)と同じように `App.svelte``Inner.svelte` がありますが、`<Inner/>` を含む `Outer.svelte` コンポーネントがあります。
88

9-
One way we could solve the problem is adding `createEventDispatcher` to `Outer.svelte`, listening for the `message` event, and creating a handler for it:
9+
この問題を解決する1つの方法は、`Outer.svelte``createEventDispatcher` を追加して、`message` イベントをリッスンして、そのハンドラを作成することです。
1010

1111
```svelte
1212
<script>
@@ -23,7 +23,7 @@ One way we could solve the problem is adding `createEventDispatcher` to `Outer.s
2323
<Inner on:message={forward}/>
2424
```
2525

26-
But that's a lot of code to write, so Svelte gives us an equivalent shorthand — an `on:message` event directive without a value means 'forward all `message` events'.
26+
しかし、これでは書くコードが多いので、Svelte は同等のショートハンドを提供します。値のない `on:message` イベントディレクティブは「全ての `message` イベントをフォワードする」ことを意味します。
2727

2828
```svelte
2929
<script>

content/tutorial/01-svelte/05-events/06-dom-event-forwarding/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: DOM event forwarding
33
---
44

5-
Event forwarding works for DOM events too.
5+
イベントフォワーディングは DOM イベントでも機能します。
66

7-
We want to get notified of clicks on our `<CustomButton>` — to do that, we just need to forward `click` events on the `<button>` element in `CustomButton.svelte`:
7+
`<CustomButton>` でのクリックの通知を受け取るためには、`CustomButton.svelte` にある `<button>` 要素の `click` イベントをフォワードする必要があります。
88

99
```svelte
1010
<button on:click>

0 commit comments

Comments
 (0)