I have received jQuery code to determine the position of the user's mouse and adjust the opacity of elements on the page based on how close it is to the center. The goal is to create a fading effect as the mouse moves closer to the center, with a full-screen logo fading to opacity: 0, the background transitioning from black to white, and white text becoming visible. Take a look at the code snippet below:
$('body').on('mousemove', function(e) {
var x_val = 2 *(e.pageX - $(window).scrollLeft()) / $(window).width() - 1,
y_val = 2 * (e.pageY - $(window).scrollTop()) / $(window).height() - 1,
opacity = (1 - Math.abs(x_val)) * (1 - Math.abs(y_val));
console.log(opacity)
});
As I am still learning jQuery, any guidance on applying this code to achieve the desired CSS effects would be greatly appreciated! Wishing you all a Merry Christmas!