<html>
<style>
div {
width: 500px;
height: 200px;
background-color: aqua;
}
</style>
<div>
</div>
<script>
let anmationId
const el = document.querySelector('div')
function anmiation(){
const offsetHeight = el.offsetHeight
el.style.height = offsetHeight + 20+'px'
anmationId= requestAnimationFrame(anmiation)
}
function startAnmation(){
if (!anmationId) {
anmiation()
}
}
startAnmation()
function stopAnmation(){
cancelAnimationFrame(anmationId)
anmationId = null
}
</script>
</html>
requestAnimationFrame动画
最新推荐文章于 2024-08-18 10:54:05 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)