14 lines
583 B
JavaScript
14 lines
583 B
JavaScript
{7c238aed164b692b936d3f559b171a61e84f0768 true 583 main.js 0xc00b097f10}
var balls = document.getElementsByClassName("ball");
|
|
document.onmousemove = function(){
|
|
var x = event.clientX * 100 / window.innerWidth + "%";
|
|
var y = event.clientY * 100 / window.innerHeight + "%";
|
|
//event.clientX => get the horizontal coordinate of the mouse
|
|
//event.clientY => get the Vertical coordinate of the mouse
|
|
//window.innerWidth => get the browser width
|
|
//window.innerHeight => get the browser height
|
|
for(var i=0;i<2;i++){
|
|
balls[i].style.left = x;
|
|
balls[i].style.top = y;
|
|
balls[i].style.transform = "translate(-"+x+",-"+y+")";
|
|
}
|
|
} |