Slow animation with webkit-transform translate() in iPhone OS 3.0

≡放荡痞女 提交于 2019-12-01 16:52:21

问题


Has something changed in JavaScript handling in iPhone OS 3.0? This code works in Safari 4 Public Beta and in iPod Touch 2.0, but not in iPod touch with iPhone OS 3.0. The purpose is to move the box a little to the right in 2 seconds, but in 3.0 it just jumps to the new location without animation or delay.

<html>
<head>
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>iPhone JS testing</title>
<style type="text/css">
.box{
  position: absolute;
  width: 150px;
  height: 150px;
  background-color: red;
  -webkit-transition-property: -webkit-transform;
  -webkit-transition-duration: 2.0s;
}
.move{
  -webkit-transform: translateX(100px);
}
</style>
<script src="jquery-1.3.2.min.js" type="application/x-javascript"></script>
</head>
<body>
<script type="text/javascript">
  $(function () {
    $(".box").click(function(){
    $(this).addClass("move");
  });
  });
</script>
<div class="box"></div>
</body>
</html>

I can go around this by using left as the transition property, but that's giving me other kind of issues when I'm trying to integrate this to my project (basically I'd need to combine dragging movement and animated movement and the dragging uses translate and the animation left-property which isn't nice. I don't know if the dragging can be implemented using left-property). Any idea what might be wrong in the code above or is this a feature from iPhone OS 3.0 onwards?


回答1:


only the translate3d() and scale3d() functions are hardware accelerated on mobile safari.

http://www.mobigeni.com/2010/09/22/how-to-use-hardware-accelerated-css3-3d-transitions-on-ipad-and-iphone/




回答2:


Nevermind, apparently it was easiest to convert the dragging functionality to also use the left property.



来源:https://stackoverflow.com/questions/1103129/slow-animation-with-webkit-transform-translate-in-iphone-os-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!