0
我想要2个假货游标,我试过这个创建2个游标。如何随机移动假光标?
// get the fake cursor by is id
var xyMirror = document.getElementById('fakeCursor');
var xyMirror2 = document.getElementById('fakeCursor2');
// listen for mouse movements
window.onmousemove = function(event) {
// get the user's mouse position
var X = event.clientX;
var Y = event.clientY;
// get the browser window dimensions
windowHeight = window.innerHeight;
windowWidth = window.innerWidth;
// create an inversion of the mouse X, Y position
// subtract mouse X position from window width
// subtract mouse Y position from window height
var fakeX = windowWidth - X;
var fakeY = windowHeight - Y;
// use those numbers to update the fake cursor position
xyMirror.style.top = fakeY+'px';
xyMirror.style.left = fakeX+'px';
xyMirror2.style.top = 10 + fakeY+'px' ;
xyMirror2.style.left = 20 + fakeX+'px';
}
现在他们的运动依赖于原来的光标, 我的问题是 如何才能将他们随机?
'Math.random'一些事情吗? 'setInterval'? – evolutionxbox
@evolutionxbox不,我认为我应该使用类似时间的东西 – parik
当你说“像时间”时,你是什么意思? – evolutionxbox