简体   繁体   English

取消JS和CSS中的所有动画

[英]Cancel all animations in JS and CSS

I want a piece of Javascript code or some guidance on how to write one that can stop all the CSS and JS (canvas, webgl, etc.) animations in a given page. 我想要一段Javascript代码或一些指南,说明如何编写可以在给定页面中停止所有CSS和JS(画布,webgl等)动画的代码。

Sometimes some animations make user's computer slow on Opera and Firefox, so i need a snippet that can help user "cancel" all css/js based animations in my web app. 有时,某些动画会使用户的计算机在Opera和Firefox上运行缓慢,因此我需要一个片段,以帮助用户“取消”我的Web应用程序中所有基于css / js的动画。

You can test this to stop the javascript: 您可以测试一下以停止javascript:

 //event is the Event object
 if (event.stopPropagation) {
  event.stopPropagation ();
 }
 event.cancelBubble = true;

For CSS, i do not know! 对于CSS,我不知道!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM