Let's say we have a page with a div
at the center which can be dragged and moved anywhere by the user. I can get the position of this rectangle using getBoundingClientRect
. Everything is fine.
But now when I pinch-zoom (not ctrl
+ +
) into the page and scroll to a section, I was expecting the getBoundingClientRect
values to change but they don't, and that is understandable, as the values of window.scrollX
and window.scrollY
also remain the same, which is 0
in this case.
But the thing is, how can I calculate the x and y coordinates of the pinch-zoomed section of the page which is currently visible with respect to the origin of the page.