Skip to content

Commit 7f64f0e

Browse files
committed
translate 03-advanced-svelte/04-actions into Japanese
1 parent aa62e6c commit 7f64f0e

File tree

2 files changed

+17
-17
lines changed
  • content/tutorial/03-advanced-svelte/04-actions

2 files changed

+17
-17
lines changed

content/tutorial/03-advanced-svelte/04-actions/01-actions/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22
title: The use directive
33
---
44

5-
Actions are essentially element-level lifecycle functions. They're useful for things like:
5+
アクションは基本的に要素レベルのライフサイクル関数です。これらは以下のような場合に便利です。
66

7-
- interfacing with third-party libraries
8-
- lazy-loaded images
9-
- tooltips
10-
- adding custom event handlers
7+
- サードパーティライブラリとの連携
8+
- 画像の遅延読み込み
9+
- ツールチップ
10+
- カスタムイベントハンドラの追加
1111

12-
In this app, we want to make the orange modal close when the user clicks outside it. It has an event handler for the `outclick` event, but it isn't a native DOM event. We have to dispatch it ourselves. First, import the `clickOutside` function...
12+
このアプリでは、オレンジ色のモーダルを、その外側をクリックしたときに閉じるようにしたいと思います。このアプリには `outclick` イベント用のイベントハンドラがありますが、これはネイティブの DOM イベントではありません。このイベントを自分でディスパッチする必要があります。まず、`clickOutside` 関数をインポートします…
1313

1414
```js
1515
import { clickOutside } from './click_outside.js';
1616
```
1717

18-
...then use it with the element:
18+
…そして、それを要素と一緒に使用します。
1919

2020
```svelte
2121
<div class="box" use:clickOutside on:outclick="{() => (showModal = false)}">
2222
Click outside me!
2323
</div>
2424
```
2525

26-
Open the `click_outside.js` file. Like transition functions, an action function receives a `node` (which is the element that the action is applied to) and some optional parameters, and returns an action object. That object can have a `destroy` function, which is called when the element is unmounted.
26+
`click_outside.js` ファイルを開きます。トランジション関数と同様に、アクション関数は `node` (アクションが適用される要素) といくつかのオプションのパラメータを受け取り、アクションオブジェクトを返します。このオブジェクトは `destroy` 関数を持つことができ、要素がマウントされていないときに呼び出されます。
2727

28-
We want to fire the `outclick` event when the user clicks outside the orange box. One possible implementation looks like this:
28+
ユーザがオレンジ色のボックスの外側をクリックしたときに、`outclick` イベントを発生させたいと考えています。考えられる実装の1つは以下のようになります。
2929

3030
```js
3131
export function clickOutside(node) {
@@ -45,4 +45,4 @@ export function clickOutside(node) {
4545
}
4646
```
4747

48-
Update the `clickOutside` function, click the button to show the modal and then click outside it to close it.
48+
`clickOutside` 関数を更新し、ボタンをクリックしてモーダルを表示し、モーダルの外側をクリックしてモーダルを閉じてみてください。

content/tutorial/03-advanced-svelte/04-actions/02-adding-parameters-to-actions/README.md

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

5-
Like transitions and animations, an action can take an argument, which the action function will be called with alongside the element it belongs to.
5+
トランジションやアニメーションのように、アクションは引数を取ることができ、アクション関数はそれが属する要素と一緒に呼び出されます。
66

7-
Here, we're using a `longpress` action that fires an event with the same name whenever the user presses and holds the button for a given duration. Right now, if you switch over to the `longpress.js` file, you'll see it's hardcoded to 500ms.
7+
ここでは、ユーザがボタンを長押しするたびに同じ名前のイベントを発生させる `longpress` アクションを使っています。`longpress.js` ファイルに切り替えると、500msにハードコードされていることがわかります。
88

9-
We can change the action function to accept a `duration` as a second argument, and pass that `duration` to the `setTimeout` call:
9+
アクション関数を変更して、第2引数に `duration` を指定し、そしてその `duration` `setTimeout` に渡すことができます。
1010

1111
```js
1212
export function longpress(node, duration) {
@@ -22,15 +22,15 @@ export function longpress(node, duration) {
2222
}
2323
```
2424

25-
Back in `App.svelte`, we can pass the `duration` value to the action:
25+
`App.svelte` に戻り、`duration` の値をアクションに渡すことができます。
2626

2727
```svelte
2828
<button use:longpress={duration}
2929
```
3030

31-
This _almost_ works — the event now only fires after 2 seconds. But if you slide the duration down, it will still take two seconds.
31+
これは、*大体* 動作します。イベントは2秒後にのみ発生するようになりました。しかし、デュレーションを下にスライドさせても、まだ2秒かかります。
3232

33-
To change that, we can add an `update` method in `longpress.js`. This will be called whenever the argument changes:
33+
これを変更するには、`longpress.js``update` メソッドを追加します。これは引数が変更されるたびに呼び出されます。
3434

3535
```js
3636
return {
@@ -41,4 +41,4 @@ return {
4141
};
4242
```
4343

44-
> If you need to pass multiple arguments to an action, combine them into a single object, as in `use:longpress={{duration, spiciness}}`
44+
> 複数の引数をアクションに渡す必要がある場合は、`use:longpress={{duration, spiciness}}` のように、それらを1つのオブジェクトに結合します。

0 commit comments

Comments
 (0)