您现在的位置是:首页 > 电脑技术查询 > web开发

层晃动效果的函数,鼠标移动过快onMouseout导致图片颤抖,该怎么处理

编辑:chaxungu时间:2022-10-02 23:22:33分类:web开发

层晃动效果的函数,鼠标移动过快onMouseout导致图片颤抖
<script language= "JavaScript ">
var rector=20
var stopit=0
var a=1
var b=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0

}function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
shake.style.top=parseInt(shake.style.top)+rector
}


function stoprattle(which){
stopit=1

which.style.left=0
which.style.top=0
}


</script> <div "onMouseover= "init(this);rattleimage() " onMouseout= "stoprattle(this) "> </div>

------解决方案--------------------
这样的话,或许你应该通过setTimeout检测鼠标若干毫秒(例如500ms)内没有mouseout才执行晃动。
------解决方案--------------------
帮顶