28

09月

2020年

辽勤日历

农历 庚子年八月十二星期一

党建专栏

友情链接

let close = document.querySelector(".cl").addEventListener("click",()=>{ document.querySelector(".fc").style.display=" none" }) let fc = document.querySelector(".fc") let width = window.innerWidth let height = window.innerHeight let fcW = fc.offsetWidth let fcH = fc.offsetHeight let maxW = window.innerWidth - fc.offsetWidth let maxH = window.innerHeight - fc.offsetHeight let nowH = 0; let nowW = 0; let stepW = 3; let stepH = 3; var a; var b; // console.log(window) // console.dir(fc) // console.log(maxW,maxH) function step(){ if(nowW>=maxW){ stepW =stepW*-1 // alert(1) } if(nowH>=maxH){ stepH =stepH*-1 // alert(2) } if(nowW<0){ stepW =stepW*-1 // alert(1) } if(nowH<0){ stepH =stepH*-1 // alert(2) } nowW = nowW+stepW nowH = nowH+stepH fc.style.left = nowW +"px" fc.style.top = nowH +"px" // console.log(nowW) // console.log(nowH) window.requestAnimationFrame(step) } window.requestAnimationFrame(step) fc.addEventListener("mouseover",()=>{ a = stepW b = stepH stepW = 0 stepH = 0 // window.requestAnimationFrame() }) fc.addEventListener("mouseout",()=>{ stepW = a stepH = b // window.requestAnimationFrame(step) })