blob: 33345afd5edbe12da40ca46d9d519606a2e939b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
---
title: ShadowRoot.getAnimations()
slug: Web/API/ShadowRoot/getAnimations
tags:
- API
- Animation
- CSS
- CSS アニメーション
- CSS トランジション
- ShadowRoot
- メソッド
- リファレンス
- トランジション
- ウェブアニメーション
- getAnimations
- waapi
- ウェブアニメーション API
browser-compat: api.ShadowRoot.getAnimations
translation_of: Web/API/ShadowRoot/getAnimations
---
{{APIRef("Web Animations")}}
**`getAnimations()`** は {{domxref("ShadowRoot")}} のメソッドで、ターゲット要素がシャドウツリーの子孫である、現在有効なすべての {{domxref("Animation")}} オブジェクトの配列を返します。この配列には [CSS アニメーション](/ja/docs/Web/CSS/CSS_Animations)、[CSS トランジション](/ja/docs/Web/CSS/CSS_Transitions)、[ウェブアニメーション](/ja/docs/Web/API/Web_Animations_API) が含まれています。
## 構文
```js
getAnimations();
```
### 引数
なし。
### 返値
{{domxref("Animation")}} オブジェクトの配列 ({{jsxref("Array")}}) で、それぞれが呼び出された {{domxref("ShadowRoot")}} の子孫である要素に現在関連付けられた 1 つのアニメーションを表します。
## 例
次のコードでは、シャドウツリーにあるすべてのアニメーションの {{domxref("Animation.playbackRate")}} を半分にすることで、アニメーションの速度を下げます。
```js
let customElem = document.querySelector('my-shadow-dom-element');
let shadow = customElem.shadowRoot;
shadow.getAnimations().forEach(
function (animation) {
animation.playbackRate *= .5;
}
);
```
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- [Web Animations API](/ja/docs/Web/API/Web_Animations_API)
- [CSS アニメーション](/ja/docs/Web/CSS/CSS_Animations)
- [CSS トランジション](/ja/docs/Web/CSS/CSS_Transitions)
- {{domxref("Element.getAnimations()")}} - 単一の
{{domxref("Element")}} とその配下のアニメーションのみを読み取ります。
- {{domxref("Animation")}}
|