简体   繁体   English

在Chrome中可以在Javascript中设置CSS 3 Transition and Transform,但在IE 10,FF中不能正常使用吗?

[英]Setting CSS 3 Transition and Transform in Javascript works in Chrome But not in IE 10, FF properly?

I have the following code, 我有以下代码,

    gallery.css("transition-duration", duration + "ms");
    gallery.css("-webkit-transition-duration", duration + "ms");
    gallery.css("-moz-transition-duration", duration + "ms");
    gallery.css("-ms-transition-duration", duration + "ms");
    gallery.css("-o-transition-duration", duration + "ms");
    //inverse the number we set in the css
    var value = (distance < 0 ? "" : "-") + Math.abs(distance).toString();

    gallery.css("transform", "translate3d(" + value + "px,0,0)");
    gallery.css("-webkit-transform", "translate3d(" + value + "px,0,0)");
    gallery.css("-moz-transform", "translate3d(" + value + "px,0,0)");
    gallery.css("-ms-transform", "translate3d(" + value + "px,0,0)");
    gallery.css("-o-transform", "translate3d(" + value + "px,0,0)");

which works greate in chrome, andriod, Iphone. 在chrome,andriod和Iphone中都可以使用。 But on IE 10(on Mobile) does not work and Firefox works partially. 但是在IE 10(移动版)上无法运行,而Firefox可以部分运行。 Any way to solve this in Javascript/Jquery? 有什么办法解决此问题的Javascript / Jquery?

See the Demo 观看演示

Update: I think I got the main issue. 更新:我想我的主要问题。 The main issue is that touch events(touchstart, touchend, touchmove) not work in IE 10 mobile. 主要问题是触摸事件(touchstart,touchend,touchmove)在IE 10移动版中不起作用。 I have used IE 10 Pointers which is work great for me. 我使用了IE 10指针 ,对我来说非常有用。 Thanks everyone. 感谢大家。

While Translate3d is still not supported in all browsers, it should work in FF. 尽管并非所有浏览器都支持Translate3d ,但它应可在FF中使用。 Atm it's the only browser which supports it without prefix . Atm是唯一支持不带prefix的浏览器。

IE10 does not support transform-style with preserve-3d , so this might be an issue for you. IE10不支持带有preserve-3d transform-style ,因此这可能对您来说是个问题。 Nonetheless 3d transforms are possible here. 尽管如此,此处仍可以进行3d转换。

I suggest you change your tranlate3d to translateX since you only modify the X value anyway. 我建议您将tranlate3d更改为translateX因为无论如何您只修改X值。 This could already solve your issue. 这可能已经解决了您的问题。 Also in general it is recommended to declare the standard-conform value last (the prefix free form) since this is the preferred notation and not have some proprietary stuff override this. 同样,通常也建议最后声明符合标准的值(无前缀形式),因为这是首选的表示法,并且没有一些专有的东西可以覆盖它。

One thing which you should definitely keep in mind is the order in which you use vendor-specific prefixes. 您一定要牢记的一件事是使用特定于供应商的前缀的顺序 There is a difference between saying: 说法之间的差异:

gallery.css("transition-duration", duration + "ms");
gallery.css("-webkit-transition-duration", duration + "ms");
gallery.css("-moz-transition-duration", duration + "ms");
gallery.css("-ms-transition-duration", duration + "ms");
gallery.css("-o-transition-duration", duration + "ms");

and... 和...

gallery.css("-webkit-transition-duration", duration + "ms");
gallery.css("-moz-transition-duration", duration + "ms");
gallery.css("-ms-transition-duration", duration + "ms");
gallery.css("-o-transition-duration", duration + "ms");
gallery.css("transition-duration", duration + "ms");

As mentioned in this SO question 's accepted answer : 本SO问题公认答案所述

Whichever is last out of -webkit-border-radius and border-radius will be the one that's used. -webkit-border-radiusborder-radius中的最后一个将被使用。

-webkit-border-radius is the "experimental" property - the implementation may contain deviations from the specification. -webkit-border-radius是“实验”属性-实现可能包含与规范的差异。 The implementation for border-radius will match what's in the specification. border-radius的实现将与规范中的实现匹配。

It's preferable to have the "W3C implementation" used when it's available, to ensure consistency between all the browsers that support it. 最好在可用时使用“ W3C实现”,以确保所有支持它的浏览器之间的一致性。

With that said - be aware that your current implementation is likely to override the "W3C implemented" version with the vendor-specific experimental property. 这样说-请注意,您当前的实现可能会使用供应商特定的实验属性来覆盖“ W3C实现”版本。

On to a more specific answer to your question: 关于您的问题的更具体答案:

This table may give you a bit more insight into which versions of which browsers claim support for 3d transformation CSS, from version to version. 下表可以让您更深入地了解哪些浏览器的版本支持3d转换CSS(不同版本)。

  1. Internet Explorer IE浏览器

    According to this blog article , IE 10 supports full CSS3 3D Transformations (note that IE9 only supported 2-D transforms , and previous versions didn't even support that). 根据这篇博客文章 ,IE 10支持完整的CSS3 3D转换(请注意IE9仅支持2-D转换 ,而以前的版本甚至不支持)。

  2. Firefox 火狐

    As of the fixing of Bug 505115 , Firefox claims support of CSS3 3D-Transforms. 自修复Bug 505115以来 ,Firefox声称支持CSS3 3D-Transforms。 According to this example page , as well - Mozilla does support the transformations (and even demonstrates doing so if you load that page in Firefox). 同样,根据此示例页面 -Mozilla确实支持转换(甚至演示了如何在Firefox中加载该页面)。

    Unfortunately, more complicated tests in Firefox fail. 不幸的是,Firefox中更复杂的测试失败了。 See this link for an example of something that works elegantly in Chrome, but not in FF. 请参阅此链接 ,以获取可以在Chrome浏览器中正常运行但在FF中无法正常运行的示例。 Partial support, to be sure, but without the animation of the WebKit implementation. 当然,部分支持,但没有WebKit实现的动画效果。

    Note: I am using Firefox 20.0.1 in order to test. 注意:我使用Firefox 20.0.1进行测试。

  3. Opera 歌剧

    Opera provides this article to describe their support of transforms. Opera提供了这篇文章来描述他们对转换的支持。

End Result : 最终结果

Support is coming to the major browsers, but slowly. 主要浏览器都提供了支持,但是速度很慢。 Future versions claim more full support, but each vendor seems to have a different definition of what "full" means. 将来的版本将要求更多的全面支持,但是每个供应商对于“完整”的含义似乎都有不同的定义。 So - as usual in the web-world... coder-beware... test in multiple environments and see what actually works before trusting the browsers to function properly in accordance with specs. 因此,就像在网络世界中一样……谨防编码器…在多种环境中进行测试,然后在信任浏览器根据规范正常运行之前,先查看实际的工作原理。

For Internet Explorer specific details, take a look at the MSDN document about Cascading Style Sheets (CSS) features related to transforms . 有关Internet Explorer的详细信息,请查看有关与转换相关的级联样式表(CSS)功能的MSDN文档。

Looking at transform-style property , it appears only to support transform-style: flat 看一下transform-style属性 ,它似乎仅支持transform-style: flat

The Transform Functions section lists a translate3d() function 转换函数部分列出了translate3d()函数

This section contains reference documentation for the Cascading Style Sheets (CSS) transform functions that are supported in Windows Internet Explorer. 本节包含Windows Internet Explorer支持的级联样式表(CSS)转换功能的参考文档。 Support for 2-D Transforms was added in Windows Internet Explorer 9, while support for 3-D Transforms was added in Internet Explorer 10. Windows Internet Explorer 9中添加了对2-D转换的支持,而Internet Explorer 10中添加了对3-D转换的支持。

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

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