请问有没有办法随着时间的推移结合更多的 CSS3 转换?
例如,当我设置这个
$bgWrapper.css({
'-webkit-transform' : ' scale3d(' + currScale + ', '+ currScale +', 1)'
});
然后在几分钟内
$bgWrapper.css({
'-webkit-transform' : 'translate3d('+ ((currCoords[0])/currScale) +'px, '+ ((currCoords[1])/currScale) +'px, 0px) '
});
我遇到了一个问题。第一个转换被第二个转换覆盖,但这就是我绝对不希望发生的事情。
所以我观察到我可以组合这些值,这样我就可以暂时存储旧的值并执行此操作
var tmpTransform = $bgWrapper.css('-webkit-transform');
$bgWrapper.css({
'-webkit-transform' : ''+ tmpTransform +'translate3d('+ ((currCoords[0])/currScale) +'px, '+ ((currCoords[1])/currScale) +'px, 0px) '
});
但即使这不正确,重复调用也存在问题..
那么有没有一种方法可以通过javascript获取css3比例的准确值?有没有办法通过js获取CSS3翻译的准确值?
目前我只得到具有这些值的矩阵,当然我可以解析它,但我希望有更好的解决方案。
最后..我想-webkit-transform:matrix(...)在iPad上不是硬件加速的,所以唯一的方法是matrix3d?正确地结合所有这些转换没有问题。
非常感谢,希望你理解我的问题:)
please is there a way how to combine more CSS3 transforms over the time?
For example when I set this
$bgWrapper.css({
'-webkit-transform' : ' scale3d(' + currScale + ', '+ currScale +', 1)'
});
And then in few moments this
$bgWrapper.css({
'-webkit-transform' : 'translate3d('+ ((currCoords[0])/currScale) +'px, '+ ((currCoords[1])/currScale) +'px, 0px) '
});
I get a problem. First transform is overriden with the second one, but thats what I definitely don't want to happen.
So I observed I can combine these values,so I can temporarily store the old one and the do this
var tmpTransform = $bgWrapper.css('-webkit-transform');
$bgWrapper.css({
'-webkit-transform' : ''+ tmpTransform +'translate3d('+ ((currCoords[0])/currScale) +'px, '+ ((currCoords[1])/currScale) +'px, 0px) '
});
But even thats not correct, there are problems with repeating calls..
So is there a way how to obtain exact value of css3 scale vie javascript? Is there a way how to get exact value of CSS3 translate via js?
Currently I am only getting matrix with these values, off course I can parse it, but I hope there is better solution.
And finally..I suppose that -webkit-transform: matrix(...) is not hardware accelerared on iPad, so only way is matrix3d? to correctly combine all these transformation without problems..
Thanks a lot, hope you understand my questions:)
发布评论
评论(2)
您需要操作矩阵才能完成您想做的事情:
操纵WebkitCSSMatrix是:您可以在此处查看演示:
http://jsfiddle.net/ 6jGaA/
You need to manipulate the matrix in order do accomplish what you want to do:
The methods for
manipulating WebkitCSSMatrixare:And you can view a demo here:
http://jsfiddle.net/6jGaA/
我是网页设计新手,但并不是 Google 新手。
要组合转换,您必须将所有转换放在同一行代码中。
本文对此进行了解释:http://www.htmlgoodies.com/beyond/css/css3-features-every-web-designer-is-excited-about-skewed-rotated-and-scaled-text.html。
我所说的这段话就在底部附近。
组合转换
CSS 转换本身很有用,但当您将它们组合在一起并获得显着结果时,它们的真正威力才会显现出来。每当您组合它们时,请记住您必须在一行中定义所有转换。这是示例语法:
I am new to web design but am no novice Googler.
To combine transformations, you have to put all the transformations on the same line of code.
This article explains it: http://www.htmlgoodies.com/beyond/css/css3-features-every-web-designer-is-excited-about-skewed-rotated-and-scaled-text.html.
The passage I am talking about is near the bottom.
Combining the Transformations
CSS transforms by themselves are useful, but their real power is unveiled when you combine them together and get remarkable results. Whenever you are combining them, remember that you have to define all the transforms in one line. Here is the sample syntax: