这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

getAnimations() 方法在 元素 interface (specified on the Animatable mixin) returns an array of all 动画 objects affecting this element or which are scheduled to do so in future. It can optionally return 动画 objects for descendant elements too.

注意 : This array includes CSS 动画 , CSS Transitions ,和 Web 动画 .

句法

const animations = Element.getAnimations(options);
					

参数

选项 可选

An options object containing the following property:

subtree
A boolean value which, if true , causes animations that target descendants of 元素 to be returned as well. This includes animations that target any CSS pseudo-elements attached to 元素 or one of its descendents. Defaults to false .

返回值

数组 of 动画 objects, each representing an animation currently targetting the 元素 on which this method is called, or one of its descendant elements if { subtree: true } 被指定。

范例

The following code snippet will wait for all animations on elem and its descendants to finish before removing the element from the document.

Promise.all(
  elem.getAnimations({ subtree: true })
    .map(animation => animation.finished)
).then(() => elem.remove());
					

规范

规范 状态 注释
Web 动画
The definition of 'Animatable.getAnimations()' in that specification.
工作草案 编者草案。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
getAnimations Chrome 79 Disabled
79 Disabled
Disabled From version 79: this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
不支持 67 — 79 Disabled
Does not support the subtree 选项。
Disabled From version 67 until version 79 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
不支持 44 — 67 Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Disabled From version 44 until version 67 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
不支持 38 — 44 Alternate Name Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 38 until version 44 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge 79 Disabled
79 Disabled
Disabled From version 79: this feature is behind the Experimental Web Platform Features preference.
Firefox 75
75
不支持 63 — 75 Disabled
Disabled From version 63 until version 75 (exclusive): this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 48 — 63 Disabled
Disabled From version 48 until version 63 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
不支持 40 — 48 Disabled
Does not support the subtree 选项。
Disabled From version 40 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
不支持 35 — 40 Alternate Name Disabled
Does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 35 until version 40 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
不支持 33 — 35 Alternate Name Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 33 until version 35 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
IE No Opera 66 Disabled
66 Disabled
Disabled From version 66: this feature is behind the Experimental Web Platform Features preference.
不支持 54 — 66 Disabled
Does not support the subtree 选项。
Disabled From version 54 until version 66 (exclusive): this feature is behind the Experimental Web Platform Features preference.
不支持 31 — 54 Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Disabled From version 31 until version 54 (exclusive): this feature is behind the Experimental Web Platform Features preference.
不支持 25 — 31 Alternate Name Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 25 until version 31 (exclusive): this feature is behind the Experimental Web Platform Features preference.
Safari 部分支持 Partial Disabled
部分支持 Partial Disabled
Does not support the subtree 选项。
Disabled This feature is behind the Web 动画 preference and the CSS Animations via Web Animations preference.
WebView Android No Chrome Android 79 Disabled
79 Disabled
Disabled From version 79: this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
不支持 67 — 79 Disabled
Does not support the subtree 选项。
Disabled From version 67 until version 79 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
不支持 44 — 67 Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Disabled From version 44 until version 67 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
不支持 38 — 44 Alternate Name Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 38 until version 44 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android 63 Disabled
63 Disabled
Disabled From version 63: this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 48 — 63 Disabled
Disabled From version 48 until version 63 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
不支持 40 — 48 Disabled
Does not support the subtree 选项。
Disabled From version 40 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
不支持 35 — 40 Alternate Name Disabled
Does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 35 until version 40 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
不支持 33 — 35 Alternate Name Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 33 until version 35 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
Opera Android 部分支持 48 Disabled
部分支持 48 Disabled
Does not support the subtree 选项。
Disabled From version 48: this feature is behind the Experimental Web Platform Features preference.
不支持 32 — 48 Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Disabled From version 32 until version 48 (exclusive): this feature is behind the Experimental Web Platform Features preference.
不支持 25 — 32 Alternate Name Disabled
Does not automatically flush pending style changes and does not support the subtree 选项。
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 25 until version 32 (exclusive): this feature is behind the Experimental Web Platform Features preference.
Safari iOS 部分支持 Partial Disabled
部分支持 Partial Disabled
Does not support the subtree 选项。
Disabled This feature is behind the Web 动画 preference and the CSS Animations via Web Animations preference.
Samsung Internet Android No

图例

完整支持

完整支持

部分支持

部分支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

使用非标名称。

另请参阅

元数据

  • 最后修改:
  1. Web 动画 API
  2. 元素
  3. 特性
    1. accessKey
    2. 属性
    3. childElementCount
    4. children
    5. classList
    6. className
    7. clientHeight
    8. clientLeft
    9. clientTop
    10. clientWidth
    11. currentStyle
    12. firstElementChild
    13. id
    14. innerHTML
    15. lastElementChild
    16. localName
    17. 名称
    18. namespaceURI
    19. nextElementSibling
    20. onfullscreenchange
    21. onfullscreenerror
    22. openOrClosedShadowRoot
    23. outerHTML
    24. part
    25. prefix
    26. previousElementSibling
    27. runtimeStyle
    28. scrollHeight
    29. scrollLeft
    30. scrollLeftMax
    31. scrollTop
    32. scrollTopMax
    33. scrollWidth
    34. shadowRoot
    35. slot
    36. tabStop
    37. tagName
  4. 方法
    1. after()
    2. animate()
    3. append()
    4. attachShadow()
    5. before()
    6. closest()
    7. computedStyleMap()
    8. createShadowRoot()
    9. getAnimations()
    10. getAttribute()
    11. getAttributeNames()
    12. getAttributeNode()
    13. getAttributeNodeNS()
    14. getAttributeNS()
    15. getBoundingClientRect()
    16. getClientRects()
    17. getElementsByClassName()
    18. getElementsByTagName()
    19. getElementsByTagNameNS()
    20. hasAttribute()
    21. hasAttributeNS()
    22. hasAttributes()
    23. hasPointerCapture()
    24. insertAdjacentElement()
    25. insertAdjacentHTML()
    26. insertAdjacentText()
    27. matches()
    28. msZoomTo()
    29. prepend()
    30. querySelector()
    31. querySelector()
    32. querySelectorAll()
    33. querySelectorAll()
    34. releasePointerCapture()
    35. remove()
    36. removeAttribute()
    37. removeAttributeNode()
    38. removeAttributeNS()
    39. replaceChildren()
    40. replaceWith()
    41. requestFullscreen()
    42. requestPointerLock()
    43. scroll()
    44. scrollBy()
    45. scrollIntoView()
    46. scrollIntoViewIfNeeded()
    47. scrollTo()
    48. setAttribute()
    49. setAttributeNode()
    50. setAttributeNodeNS()
    51. setAttributeNS()
    52. setCapture()
    53. setPointerCapture()
    54. toggleAttribute()
  5. 事件
    1. afterscriptexecute
    2. auxclick
    3. blur
    4. click
    5. compositionend
    6. compositionstart
    7. compositionupdate
    8. contextmenu
    9. copy
    10. cut
    11. dblclick
    12. DOMActivate
    13. DOMMouseScroll
    14. error
    15. focus
    16. focusin
    17. focusout
    18. fullscreenchange
    19. fullscreenerror
    20. gesturechange
    21. gestureend
    22. gesturestart
    23. keydown
    24. keypress
    25. keyup
    26. mousedown
    27. mouseenter
    28. mouseleave
    29. mousemove
    30. mouseout
    31. mouseover
    32. mouseup
    33. mousewheel
    34. MozMousePixelScroll
    35. msContentZoom
    36. MSGestureChange
    37. MSGestureEnd
    38. MSGestureHold
    39. MSGestureStart
    40. MSGestureTap
    41. MSInertiaStart
    42. MSManipulationStateChanged
    43. overflow
    44. paste
    45. scroll
    46. select
    47. show
    48. touchcancel
    49. touchend
    50. touchmove
    51. touchstart
    52. underflow
    53. webkitmouseforcechanged
    54. webkitmouseforcedown
    55. webkitmouseforceup
    56. webkitmouseforcewillbegin
    57. wheel
  6. 继承:
    1. 节点
    2. EventTarget
  7. Web 动画相关页面
    1. 动画
    2. AnimationEffect
    3. AnimationEvent
    4. AnimationPlaybackEvent
    5. AnimationTimeline
    6. Document.getAnimations()
    7. Document.timeline
    8. DocumentTimeline
    9. EffectTiming
    10. Element.animate()
    11. KeyframeEffect

版权所有  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1