在 Javascript 中使用矩阵过滤器
我能够为所有浏览器设置 CSS 旋转设置,但现在我需要在 Javascript 中执行此操作。 我也在使用 jQuery,目前以下内容
.css({ '-ms-filter':"progid:DXImageTransform.Microsoft.Matrix(M11=0.9659258262890683, M12=-0.2588190451025207, M21=0.2588190451025207, M22=0.9659258262890683, SizingMethod='auto expand')" });
不起作用。 CSS 中的相同代码可以完美运行。我尝试过转义撇号,但没有成功。有什么想法吗?我首先需要初始设置值,因此只需一个简单的 .CSS,如上所示。然后这些值在以下函数中更新:
function rotate(degree){
if((ievers==6)||(ievers==7)||(ievers==8)){
current_obj.css({
/* IE8 */
'-ms-filter':'"progid:DXImageTransform.Microsoft.BasicImage(rotation='+degree+')"',/* IE<8 */'filter':'progid:DXImageTransform.Microsoft.BasicImage(rotation='+degree+')'});
} else {
/* HANDLE OTHER BROWSERS */ ...
};
rotatetimer = setTimeout(function(){ rotate(++degree); },10 );}
此代码已设置并适用于除 IE7/8 之外的所有浏览器(因为 (rotation=x) 只允许您有 4 个旋转选项。所以我尝试将该行替换为.Matrix 并动态计算 SIN/COS 值。
I'm able to get CSS rotation setup for all browsers, but now I need to do this inside Javascript.
I'm using jQuery as well and currently the following:
.css({ '-ms-filter':"progid:DXImageTransform.Microsoft.Matrix(M11=0.9659258262890683, M12=-0.2588190451025207, M21=0.2588190451025207, M22=0.9659258262890683, SizingMethod='auto expand')" });
is not working. The same code in the CSS works perfectly. I've tried escaping apostrophes, but it didn't work. Any ideas? I first need to set the values initially, so just a simple .CSS as show above. Then the values are updated within the following function:
function rotate(degree){
if((ievers==6)||(ievers==7)||(ievers==8)){
current_obj.css({
/* IE8 */
'-ms-filter':'"progid:DXImageTransform.Microsoft.BasicImage(rotation='+degree+')"',/* IE<8 */'filter':'progid:DXImageTransform.Microsoft.BasicImage(rotation='+degree+')'});
} else {
/* HANDLE OTHER BROWSERS */ ...
};
rotatetimer = setTimeout(function(){ rotate(++degree); },10 );}
This code is setup and works in everything except IE7/8 (because of the (rotation=x) only allowing you 4 options for rotation. So I'm trying to swap that line out with the .Matrix and dynamically calculate the SIN/COS values on the fly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
current_obj[0].style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=0.9659258262890683, M12=-0.2588190451025207, M21=0.2588190451025207, M22=0.9659258262890683, SizingMethod='自动展开')";
为我工作。另外,正如我所见,BasicImage 滤镜的旋转值以九十度增量进行测量。有关过滤器的更多参考:MSDN 过滤器
current_obj[0].style.filter = "progid:DXImageTransform.Microsoft.Matrix(M11=0.9659258262890683, M12=-0.2588190451025207, M21=0.2588190451025207, M22=0.9659258262890683, SizingMethod='auto expand')";
worked for me. Also, as I see, the BasicImage filter's rotation value is measured in ninety-degrees increment. More references on filters: MSDN filters