Answer the question
In order to leave comments, you need to log in
How to make path follow the cursor?
Hey!
How can you calculate the path element's cursor tracking?
I found this example, but it doesn't work to remake it under translate transform
$(function(){
var mouseX = 0, mouseY = 0, limitX = 150-10, limitY = 150-10;
$(window).mousemove(function(e){
var offset = $('.js-this-scroll').offset();
mouseX = Math.min(e.pageX - offset.left, limitX);
mouseY = Math.min(e.pageY - offset.top, limitY);
if (mouseX < 0) mouseX = 0;
if (mouseY < 0) mouseY = 0;
});
var follower = $(".js-eye");
var xp = 0, yp = 0;
var loop = setInterval(function(){
xp += (mouseX - xp) / 20;
yp += (mouseY - yp) / 20;
follower.css({left:xp, top:yp});
}, 10);
});
follower.css('transform', 'translate(' + xp + ', ' + yp + ')');/
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question