I was looking for a div to follow up the mouse cursor, i've found solution here but the div now doesn't follow up the mouse while scrolling, any ideas?
<script type="text/javascript">
function getMouseCoords(e) {
var e = e || window.event;
document.getElementByTagName('body').innerHTML = e.clientX + ', ' +
e.clientY + '<br>' + e.screenX + ', ' + e.screenY;
}
var followCursor = (function() {
var s = document.createElement('div');
s.style.position = 'absolute';
s.style.margin = '0';
s.style.padding = '10px';
s.style.border = '1px solid black';
s.style.animationTime = "2.5s";
s.style.webkitTransform = "rotate(45deg)";
s.style.zIndex = "9999999999";
return {
init: function() {
document.body.appendChild(s);
},
run: function(e) {
var e = e || window.event;
s.style.left = (e.clientX - 15) + 'px';
s.style.top = (e.clientY - 10) + 'px';
getMouseCoords(e);
}
};
}());
window.onload = function() {
followCursor.init();
document.body.onmousemove = followCursor.run;
}
</script>
i have no idea how to fix this at the moment, i just started studying, so any help would be appreciated.