When Im at the top of the page. The curose_div will follow the cursor perfectly. But when I start scrolling to the bottom the cursor_div position will not follow correctly.
Heres my code
<div id="cursor"</div></div id="cursor_border"></div>
`var cursor = $(‘#cursor’);
var cursor_border = $(‘#cursor_border’);
$(document).mousemove(function(e){
console.log(e.pageY + ' and '+ e.pageX ) ;
var x = e.pageX;
var y = e.pageY;
cursor.css("left",x+'px');
cursor.css("top",y+'px');
cursor_border.css("left",x+'px');
cursor_border.css("top",y+'px');`
2
Answers
this code may correct the error :
The use of classic Javascript can improve the performance, and may correct the error caused by jQuery !
I hope this helped you !
Use
event.clientX
andevent.clientY
together with#cursor { position: fixed; }
: