为什么动画一直抖
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{padding:0;margin:0;}
#box{width:200px;height:200px;background:red;position:relative;left:-200px;}
span{width:20px;height:50px;position:absolute;left:200px;background:blue;top:75px;}
</style>
<script type="text/javascript">
window.onload=function(){
var boxs=document.getElementById('box');
boxs.onmouseover=function(){
movefun();
}
boxs.onmouseout=function(){
movefuns();
}
}
var timer=null;
function movefun(){
clearInterval(timer);
var boxs=document.getElementById('box'),
timer=setInterval(function(){
if(boxs.offsetLeft==0){
clearInterval(timer);
}else{
boxs.style.left=boxs.offsetLeft+10+'px';
}
},30);
}
function movefuns(){
clearInterval(timer);
var boxs=document.getElementById('box'),
timer=setInterval(function(){
if(boxs.offsetLeft==-200){
clearInterval(timer);
}else{
boxs.style.left=boxs.offsetLeft-10+'px';
}
},30);
}
</script>
</head>
<body>
<div id="box"><span>分享</span></div>
</body>
</html>