Is there a way to target an img tag object-position x and y?

140 Views Asked by At

I have included my codepen for an example. I need to have the image move around with cursor. Is there an attribute like object-position Y or something that i can use?

I know i could do background-position x or y , but why not object-position X or Y?

image hover effect

const images = document.querySelectorAll('.image');

images.forEach((image) => image.addEventListener('mousemove', (e) => {

image.style.objectPosition = -e.offsetX + "px"<--works but I want both directions??


  //image.style.objectPositionX = -e.offsetX + "px"//why cant i do these?
  //image.style.objectPositionY = -e.offsetY + "px"
}));
0

There are 0 best solutions below