1

I am using elevatezoom for a project and I need to get the mouse position while the picture is zoomed in. I tried a lot of different ideas but I always get undefined or NaN. Can you tell me why?

Look at this example:

$('#zoomPicture').elevateZoom({
  scrollZoom : true,
  zoomWindowFadeIn: 250,
  zoomWindowFadeOut: 500,
  responsive: true,
  easing: true,
  easingDuration: 50,
  borderSize: 1,
  zoomWindowWidth: 400,
  zoomWindowHeight: 400,
});

$("#zoomPicture").bind("click", function(e) {
  console.log(e.pageX);
  console.log(e.pageY);
}); // -> undefined
a1xon
  • 85
  • 1
  • 1
  • 6

2 Answers2

1

Could you please let me know if the below code works for you

$(document).bind("click", "#zoomPicture", function(e) {
  console.log(e.pageX);
  console.log(e.pageY);
});

Does this link help you with your question: Understanding Event Delegation

Daniel Netto
  • 387
  • 5
  • 18
0

The object ElevateZoom.self.nzOffset contain the x and y coordinates of the image.

You can see the values by using:

console.log( ElevateZoom.self.nzOffset );

With this information you can implement the jQuery.on("click", function(){ //stuff here })

Hope I have helped.

Cya