<!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.οnlοad=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.οnclick=function(){
move();
}
}
</script>
</head>
<body>
<input type="button" name="btn" id="btn" value="移出" />
<div id="box">
</div>
</body>
</html>
缓冲运动(变速)
最新推荐文章于 2023-10-11 18:17:35 发布