相思资源网 Design By www.200059.com
代码如下:
复制代码 代码如下:
<script type="text/javascript">
var ball;
var mouseX = 100;
var mouseY = 100;
var angle = 0;
var radius = 50;
function run(){
if(ball === undefined){
ball = document.createElement("span");
ball.style.position = "absolute";
ball.style.color = "#FF0000";
ball.style.zIndex = 999999999;
ball.innerHTML = "●";
document.body.appendChild(ball);
}
ball.style["left"] = mouseX+(Math.cos(angle)*radius) + "px";
ball.style["top"] = mouseY+(Math.sin(angle)*radius) + "px";
angle+=0.1;
}
function MousePos(e)
{
e = e || window.event;
var x,y;
if(!document.all){
x = e.pageX;
y = e.pageY;
}
else{
x = event.clientX + document.documentElement.scrollLeft;
y = event.clientY + document.documentElement.scrollTop;
}
return {x:x,y:y};
}
function setXY(e)
{
e = e || window.event;
var pos = MousePos(e);
mouseX = pos.x;
mouseY = pos.y;
}
window.onload = function(){
setInterval(run,20);
document.documentElement.onmousemove = function(e){
e = e || window.event;
setXY(e);
};
}
</script>
作者: cnblogs airy
复制代码 代码如下:
<script type="text/javascript">
var ball;
var mouseX = 100;
var mouseY = 100;
var angle = 0;
var radius = 50;
function run(){
if(ball === undefined){
ball = document.createElement("span");
ball.style.position = "absolute";
ball.style.color = "#FF0000";
ball.style.zIndex = 999999999;
ball.innerHTML = "●";
document.body.appendChild(ball);
}
ball.style["left"] = mouseX+(Math.cos(angle)*radius) + "px";
ball.style["top"] = mouseY+(Math.sin(angle)*radius) + "px";
angle+=0.1;
}
function MousePos(e)
{
e = e || window.event;
var x,y;
if(!document.all){
x = e.pageX;
y = e.pageY;
}
else{
x = event.clientX + document.documentElement.scrollLeft;
y = event.clientY + document.documentElement.scrollTop;
}
return {x:x,y:y};
}
function setXY(e)
{
e = e || window.event;
var pos = MousePos(e);
mouseX = pos.x;
mouseY = pos.y;
}
window.onload = function(){
setInterval(run,20);
document.documentElement.onmousemove = function(e){
e = e || window.event;
setXY(e);
};
}
</script>
作者: cnblogs airy
标签:
圆形运动,鼠标,小球
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无javascript动画之圆形运动,环绕鼠标运动作小球的评论...