javascript 用于 CSS 过渡和动画的 PolyFill/Shim

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5344745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 16:53:41  来源:igfitidea点击:

PolyFill/Shim for CSS transitions and animations

javascripthtmlcsspolyfillscss-transitions

提问by Graham Conzett

Google is failing me somewhat on this (I think because the terminology for PolyFill/Shim/Spackle is new and diverse at the moment). I'm trying to find a good JavaScript PolyFill or Shim for webkit's (and now as of the RC FireFox 4's) CSS transitions.

谷歌在这方面有点让我失望(我认为是因为 PolyFill/Shim/Spackle 的术语目前是新的和多样化的)。我正在尝试为 webkit 的(现在是 RC FireFox 4 的)CSS 转换找到一个好的 JavaScript PolyFill 或 Shim。

I have found this workthat Weston Ruterdid, but it hasn't been updated in a while, and uses browser detection as opposed to feature detection.

我发现了Weston Ruter所做的这项工作,但它已经有一段时间没有更新了,并且使用浏览器检测而不是功能检测。

I also uncovered FakeSmilebut it is geared mostly to SVG animation.

我还发现了FakeSmile,但它主要面向 SVG 动画。

Does anyone know of any good libraries to fill in this functionality? Preferably something that would work with Modernizrand is still being actively worked on. So far the best option looks like starting with what Weston came up with.

有谁知道有什么好的库来填充这个功能?最好是可以与Modernizr 一起使用并且仍在积极开发的东西。到目前为止,最好的选择似乎是从 Weston 提出的方案开始。

回答by Sindre Sorhus

There is a very good CSS3 transition polyfill for jQuery called jQuery.transition.

jQuery 有一个非常好的 CSS3 过渡 polyfill,称为jQuery.transition

You can just use the usual animate()method in jQuery, and it will automatically use CSS3 transitions if available, and if not, it will fall back to vanilla jQuery.

您可以在 jQuery 中使用通常的animate()方法,如果可用,它将自动使用 CSS3 过渡,如果没有,它将回退到 vanilla jQuery。

回答by Anson

Google's Polymer Projectincludes a Web Animationspolyfill for the draft W3C Web Animationsspec.

谷歌的聚合物项目包括网页动画填充工具的草案W3C的Web动画规范。

Caveat emptor:This is pretty early work, as the W3C spec is only a Public Working Draft, so anything could change. Also, the Polymer polyfills look like they're targeting only the latest version of browsers (e.g. IE10+) so it may not suit your needs. Still, this is early on in the project, so keep an eye on it and experiment.

警告:这是相当早期的工作,因为 W3C 规范只是一个公共工作草案,所以任何事情都可能改变。此外,Polymer polyfills 看起来只针对最新版本的浏览器(例如 IE10+),因此它可能不适合您的需求。尽管如此,这还处于项目的早期阶段,因此请密切关注它并进行实验。

If you're careful to test the platforms your users are on, you could take advantage of the future web today.

如果您小心地测试用户所使用的平台,那么您今天就可以利用未来的网络。