Hey there! I stumbled upon something that could be beneficial to you. Check out this link: https://jsfiddle.net/Doroshenkomagic/z7mjag2t/, and unravel the concept behind it by visiting:
In essence:
var mouse_x = event.pageX - $(this).offset().left;
var mouse_y = event.pageY - $(this).offset().top;
A crucial component: This will consistently monitor the position of your cursor in relation to the top-left corner.
var center_x = Math.round(parseInt(element_w) / 2);
var center_y = Math.round(parseInt(element_h) / 2);
Another fundamental aspect: This will pinpoint the center of your image using the above code:
var element_w = $(this).width();
var element_h = $(this).height();
It identifies the height and width of the element. Subsequently, various calculations are carried out to determine the distance between the cursor and the image's center, enabling the adjustment of opacity. In your scenario, you'd need to tweak the element's opacity.
You can access the complete code here as well: https://github.com/rmmoul/jquery-opacity-by-mouse-location