<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title><!--速度=(目标值-当前值)/缩放系数-->
<style type="text/css">
*{
padding: 0;
margin: 0;
}
#box{
width: 200px;
height: 400px;
background: darkcyan;
position: absolute;
left: -200px;
}
</style>
<script type="text/javascript">
window.onload=function(){
var obtn=document.getElementById('btn');
var obox=document.getElementById('box');
var timer=null;
function move(){
clearInterval(timer);
timer=setInterval(function(){
//速度=(目标值-当前值)/缩放系数
var speed=(0-obox.offsetLeft)/20;
obox.style.left=obox.offsetLeft+speed+'px';
},30);
}
obtn.onclick=function(){
move();
}
}
</script>
</head>
<body>
<input type="button" name="btn" id="btn" value="移出" />
<div id="box">
</div>
</body>
</html>
缓冲运动(变速)
最新推荐文章于 2022-11-03 17:32:47 发布