我目前有这个,跟随鼠标光标潜水..但是当我靠近网站的边缘时,它会创建滚动条等,我将如何限制它留在体内并在它超出视野而不是隐藏时隐藏扩展网站..
这是JS;
var mouseX = 0, mouseY = 0;
$(document).mousemove(function(e){
mouseX = e.pageX;
mouseY = e.pageY;
});
// cache the selector
var follower = $("#follower");
var xp = 0, yp = 0;
var loop = setInterval(function(){
// change 12 to alter damping higher is slower
xp += (mouseX - xp) / 1;
yp += (mouseY - yp) / 1;
follower.css({left:xp+5, top:yp+5});
}, 30);
这是CSS:
#follower{
position : absolute;
background-color : red;
color : white;
padding : 10px;
}
然后是 HTML:
<div id="follower">Move your mouse</div>
非常感谢任何帮助..谢谢