Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rotate3d 180deg 的一些坑 #41

Open
weekeight opened this issue Dec 10, 2015 · 0 comments
Open

rotate3d 180deg 的一些坑 #41

weekeight opened this issue Dec 10, 2015 · 0 comments
Labels

Comments

@weekeight
Copy link
Owner

问题描述

当将一个元素从 rotate3d(0,0,0,0) 变到 rotate3d(0,0,1,180deg) 的时候,理论上以及在chrome、安卓微信webview上都是顺时针旋转的,可是在safari及IOS的微信webview上就是逆时针的了。

有意思的是如果是变到 rotate3d(0,0,1,179.9deg) 所有浏览器都是顺时针的

还有如果使用 rotateZ(0) 变到 rotateZ(180deg) 的时候所有浏览器都是顺时针的了,符合预期。让我费解的时 IOS 的策略,如果180deg的时候非要逆时针那就让 rotate3drotateZ 统一嘛,可是事实上却不是,不是自相矛盾吗?(有知道原因的童鞋请告知我~)

解决方案

直接用 rotateZ 来做旋转动画,让所有浏览器都统一旋转方向

示例代码

示例地址

<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
  <meta name="referrer" content="origin-when-cross-origin">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no">
<title>ios rotate180 bug</title>
<style>
.center{
  position: relative;
  margin: 0 auto;
  text-align: center;
}
.rect{
  position: absolute;
  box-sizing: border-box;
  display: inline-block;
  width: 100px;
  height: 200px;
  border-top:5px solid red;
  border-bottom: 5px solid blue;
  border-right: 5px solid green;
  border-left: 5px solid purple;

  transform: rotate3d(0,0,0,0deg);
  /*transform: rotateZ(0deg);*/
  transition: all 5s;
  will-change: transform;
}
</style>
</head>
<body>
  <p>click to show rotation animation</p>
  <div class="center">
    <div class="rect" id="J_Rect"></div>
  </div>
</body>
<script src="http://statics.mangguoyisheng.com/resource/demo/1.0.0/third-party/jquery/jquery-2.1.4.min.js"></script>
<script>
  $('#J_Rect').click(function(){
    $('#J_Rect').css({
      'transform': 'rotate3d(0,0,1,180deg)'
      // 'transform': 'rotateZ(180deg)'
    });
  });
</script>
</html>

@weekeight weekeight added the css label Dec 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant