|
1 |
| -# Animating your applications with `animate.enter` and `animate.leave` |
| 1 | +# `animate.enter`と`animate.leave`を使ったアプリケーションのアニメーション |
2 | 2 |
|
3 |
| -Well-designed animations can make your application more fun and straightforward to use, but they aren't just cosmetic. |
4 |
| -Animations can improve your application and user experience in a number of ways: |
| 3 | +適切に設計されたアニメーションは、アプリケーションをより楽しく、分かりやすく使用できるようにしますが、単なる装飾ではありません。 |
| 4 | +アニメーションは、いくつかの方法でアプリケーションとユーザー体験を向上させることができます。 |
5 | 5 |
|
6 |
| -* Without animations, web page transitions can seem abrupt and jarring |
7 |
| -* Motion greatly enhances the user experience, so animations give users a chance to detect the application's response to their actions |
8 |
| -* Good animations can smoothly direct the user's attention throughout a workflow |
| 6 | +* アニメーションがないと、ウェブページの遷移は突然で不快に感じられることがあります |
| 7 | +* モーションはユーザー体験を大幅に向上させるため、アニメーションはユーザーが自分のアクションに対するアプリケーションの応答を検出する機会を与えます |
| 8 | +* 優れたアニメーションは、ワークフロー全体でユーザーの注意をスムーズに誘導できます |
9 | 9 |
|
10 |
| -Angular provides `animate.enter` and `animate.leave` to animate your application's elements. These two features apply enter and leave CSS classes at the appropriate times or call functions to apply animations from third party libraries. `animate.enter` and `animate.leave` are not directives. They are special API supported directly by the Angular compiler. They can be used on elements directly and can also be used as a host binding. |
| 10 | +Angularは、アプリケーションの要素をアニメーション化するために`animate.enter`と`animate.leave`を提供します。これら2つの機能は、適切なタイミングでenterおよびleaveのCSSクラスを適用するか、サードパーティライブラリからアニメーションを適用する関数を呼び出します。`animate.enter`と`animate.leave`はディレクティブではありません。これらはAngularコンパイラによって直接サポートされる特別なAPIです。これらは要素に直接使用できるほか、ホストバインディングとしても使用できます。 |
11 | 11 |
|
12 |
| -## `animate.enter` |
| 12 | +## `animate.enter` {#animate.enter} |
13 | 13 |
|
14 |
| -You can use `animate.enter` to animate elements as they _enter_ the DOM. You can define enter animations using CSS classes with either transforms or keyframe animations. |
| 14 | +`animate.enter`はDOMに_入る_要素をアニメーション化するために使用できます。CSSクラスと、transformまたはキーフレームアニメーションのいずれかを使用して、enterアニメーションを定義できます。 |
15 | 15 |
|
16 | 16 | <docs-code-multifile preview path="adev/src/content/examples/animations/src/app/enter-and-leave/enter.ts">
|
17 | 17 | <docs-code header="src/app/enter.ts" path="adev/src/content/examples/animations/src/app/enter-and-leave/enter.ts" />
|
18 | 18 | <docs-code header="src/app/enter.html" path="adev/src/content/examples/animations/src/app/enter-and-leave/enter.html" />
|
19 | 19 | <docs-code header="src/app/enter.css" path="adev/src/content/examples/animations/src/app/enter-and-leave/enter.css"/>
|
20 | 20 | </docs-code-multifile>
|
21 | 21 |
|
22 |
| -When the animation completes, Angular removes the class or classes that you specified in `animate.enter` from the DOM. Animation classes are only be present while the animation is active. |
| 22 | +アニメーションが完了すると、Angularは`animate.enter`で指定したクラスをDOMから削除します。アニメーションクラスは、アニメーションがアクティブな間のみ存在します。 |
23 | 23 |
|
24 |
| -NOTE: When using multiple keyframe animations or transition properties on an element, Angular removes all classes only _after_ the longest animation has completed. |
| 24 | +NOTE: 要素で複数のキーフレームアニメーションまたはtransitionプロパティを使用している場合、Angularは最も長いアニメーションが完了した_後にのみ_すべてのクラスを削除します。 |
25 | 25 |
|
26 |
| -You can use `animate.enter` with any other Angular features, such as control flow or dynamic expressions. `animate.enter` accepts both a single class string (with multiple classes separated by spaces), or an array of class strings. |
| 26 | +`animate.enter`は、制御フローや動的式など、他のAngular機能と組み合わせて使用できます。`animate.enter`は、単一のクラス文字列(複数のクラスがスペースで区切られているもの)またはクラス文字列の配列を受け入れます。 |
27 | 27 |
|
28 | 28 | <docs-code-multifile preview path="adev/src/content/examples/animations/src/app/enter-and-leave/enter-binding.ts">
|
29 | 29 | <docs-code header="src/app/enter-binding.ts" path="adev/src/content/examples/animations/src/app/enter-and-leave/enter-binding.ts" />
|
30 | 30 | <docs-code header="src/app/enter-binding.html" path="adev/src/content/examples/animations/src/app/enter-and-leave/enter-binding.html" />
|
31 | 31 | <docs-code header="src/app/enter-binding.css" path="adev/src/content/examples/animations/src/app/enter-and-leave/enter-binding.css"/>
|
32 | 32 | </docs-code-multifile>
|
33 | 33 |
|
34 |
| -## `animate.leave` |
| 34 | +## `animate.leave` {#animate.leave} |
35 | 35 |
|
36 |
| -You can use `animate.leave` to animate elements as they _leave_ the DOM. You can define leave animations using CSS classes with either transforms or keyframe animations. |
| 36 | +`animate.leave` を使用して、要素がDOMから_離れる_ときにアニメーションを適用できます。CSSクラスと、transformまたはキーフレームアニメーションのいずれかを使用して、離脱アニメーションを定義できます。 |
37 | 37 |
|
38 | 38 | <docs-code-multifile preview path="adev/src/content/examples/animations/src/app/enter-and-leave/leave.ts">
|
39 | 39 | <docs-code header="src/app/leave.ts" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave.ts" />
|
40 | 40 | <docs-code header="src/app/leave.html" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave.html" />
|
41 | 41 | <docs-code header="src/app/leave.css" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave.css"/>
|
42 | 42 | </docs-code-multifile>
|
43 | 43 |
|
44 |
| -When the animation completes, Angular automatically removes the animated element from the DOM. |
| 44 | +アニメーションが完了すると、Angularはアニメーション化された要素をDOMから自動的に削除します。 |
45 | 45 |
|
46 |
| -NOTE: When using multiple keyframe animations or transition properties on a an element, Angular waits to remove the element only _after_ the longest of those animations has completed. |
| 46 | +NOTE: 要素に複数のキーフレームアニメーションまたはtransitionプロパティを使用する場合、Angularはそれらのアニメーションの中で最も長いものが完了した_後にのみ_要素を削除します。 |
47 | 47 |
|
48 |
| -`animate.leave` can also be used with signals, and other bindings. You can use `animate.leave` with a single class or multiple classes. Either specify it as a simple string with spaces or a string array. |
| 48 | +`animate.leave` はsignalsやその他のbindingでも使用できます。`animate.leave` は単一のクラスまたは複数のクラスで使用できます。スペースで区切られた単純な文字列として指定するか、文字列配列として指定します。 |
49 | 49 |
|
50 | 50 | <docs-code-multifile preview path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-binding.ts">
|
51 | 51 | <docs-code header="src/app/leave-binding.ts" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-binding.ts" />
|
52 | 52 | <docs-code header="src/app/leave-binding.html" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-binding.html" />
|
53 | 53 | <docs-code header="src/app/leave-binding.css" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-binding.css"/>
|
54 | 54 | </docs-code-multifile>
|
55 | 55 |
|
56 |
| -## Event Bindings, Functions, and Third-party Libraries |
| 56 | +## イベントバインディング、関数、およびサードパーティライブラリ {#event-bindings-functions-and-third-party-libraries} |
57 | 57 |
|
58 |
| -Both `animate.enter` and `animate.leave` support event binding syntax that allows for function calls. You can use this syntax to call a function in your component code or utilize third-party animation libraries, like [GSAP](https://gsap.com/), [anime.js](https://animejs.com/), or any other JavaScript animation library. |
| 58 | +`animate.enter`と`animate.leave`はどちらも、関数呼び出しを可能にするイベントバインディング構文をサポートしています。この構文を使用して、コンポーネントコード内の関数を呼び出したり、[GSAP](https://gsap.com/)、[anime.js](https://animejs.com/)などのサードパーティのアニメーションライブラリ、またはその他のJavaScriptアニメーションライブラリを利用したり可能です。 |
59 | 59 |
|
60 | 60 | <docs-code-multifile preview path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-event.ts">
|
61 | 61 | <docs-code header="src/app/leave-event.ts" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-event.ts" />
|
62 | 62 | <docs-code header="src/app/leave-event.html" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-event.html" />
|
63 | 63 | <docs-code header="src/app/leave-event.css" path="adev/src/content/examples/animations/src/app/enter-and-leave/leave-event.css"/>
|
64 | 64 | </docs-code-multifile>
|
65 | 65 |
|
66 |
| -The `$event` object has the type `AnimationCallbackEvent`. It includes the element as the `target` and provides an `animationComplete()` function to notify the framework when the animation finishes. |
| 66 | +`$event`オブジェクトは`AnimationCallbackEvent`型です。これには`target`として要素が含まれ、アニメーションが終了したときにフレームワークに通知するための`animationComplete()`関数を提供します。 |
67 | 67 |
|
68 |
| -IMPORTANT: You **must** call the `animationComplete()` function when using `animate.leave` for Angular to remove the element. |
| 68 | +IMPORTANT: Angularが要素を削除するためには、`animate.leave`を使用する際に`animationComplete()`関数を**必ず**呼び出す必要があります。 |
69 | 69 |
|
70 |
| -If you don't call `animationComplete()` when using `animate.leave`, Angular calls the function automatically after a four-second delay. You can configure the duration of the delay by providing the token `MAX_ANIMATION_TIMEOUT` in milliseconds. |
| 70 | +`animate.leave`を使用する際に`animationComplete()`を呼び出さない場合、Angularは4秒の遅延後に自動的にその関数を呼び出します。遅延の期間は、`MAX_ANIMATION_TIMEOUT`トークンをミリ秒単位で提供することにより設定できます。 |
71 | 71 |
|
72 | 72 | ```typescript
|
73 | 73 | { provide: MAX_ANIMATION_TIMEOUT, useValue: 6000 }
|
74 | 74 | ```
|
75 | 75 |
|
76 |
| -## Testing |
| 76 | +## テスト {#testing} |
77 | 77 |
|
78 |
| -TestBed provides built-in support for enabling or disabling animations in your test environment. CSS animations require a browser to run, and many of the APIs are not available in a test environment. By default, TestBed disables animations for you in your test environments. |
| 78 | +TestBedは、テスト環境でアニメーションを有効または無効にするための組み込みサポートを提供します。CSSアニメーションはブラウザでの実行が必要であり、多くのAPIはテスト環境では利用できません。デフォルトでは、TestBedはテスト環境でアニメーションを無効にします。 |
79 | 79 |
|
80 |
| -If you want to test that the animations are animating in a browser test, for example an end-to-end test, you can configure TestBed to enable animations by specifying `animationsEnabled: true` in your test configuration. |
| 80 | +ブラウザテスト、例えばエンドツーエンドテストでアニメーションが動作していることをテストしたい場合は、テスト設定で`animationsEnabled: true`を指定することで、TestBedをアニメーションを有効にするように設定できます。 |
81 | 81 |
|
82 | 82 | ```typescript
|
83 | 83 | TestBed.configureTestingModule({animationsEnabled: true});
|
84 | 84 | ```
|
85 | 85 |
|
86 |
| -This will configure animations in your test environment to behave normally. |
| 86 | +これにより、テスト環境でのアニメーションが通常通りに動作するように設定されます。 |
87 | 87 |
|
88 |
| -NOTE: Some test environments do not emit animation events like `animationstart`, `animationend` and their transition event equivalents. |
| 88 | +NOTE: 一部のテスト環境では、`animationstart`、`animationend`のようなアニメーションイベントや、それらに相当するトランジションイベントを発行しません。 |
0 commit comments