2

$(window).height() gets the height of the window when the page is loaded. However, when zooming in/out, I want the new viewpoint height. Is this possible?

It works fine resizing normal browsers, but I guess zooming in/out on a mobile doesn't fire $(window).resize()? or at least it doesn't update the window's size

Just to clarify, I'm talking about zooming on mobile browsers. I'm simulating the css attribute position:fixed using jQuery.

$(elements).css('top', $("body").scrollTop() - 42 + $(window).height() / 2) is the code I'm using. It basically makes the elements centred vertically on the screen. This is being fired on $(window).resize and $(window).scroll. The code works correctly to begin with, but zooming doesn't update the $(window).height()


Edit

So I suppose another way of asking: Any ideas of how to get the centre of the viewpoint in javascript/jQuery?

paulslater19
  • 5,553
  • 1
  • 25
  • 24

1 Answers1

2

Well, although I don't know exactly, check this link out because it might be helpful.

I did try something like this though and it works on resize but not for zoom. Zoom does not change the window height but only the the size of the inside elements so that's why perhaps the jQuery does not make any changes.

What's your code right now though and what would you like to change exactly? The inner elements?

Community
  • 1
  • 1
Dimitris Damilos
  • 2,157
  • 5
  • 21
  • 44