Jump to content

Correct value but something with scale [iPad]


Recommended Posts

Hi, I'm trying to get new width and height when orientation is changed on iPad. So, I'm usinng this function:

var ratio = 1; var orientationChanged = function() { 	if (window.orientation == 0 || window.orientation == 180) {			return {					browser_width: screen.width,					browser_height: (ratio == 1 ? window.innerHeight : (screen.width / ratio))			}	}	else if (window.orientation == 90 || window.orientation == -90) {			return {					browser_width: screen.height,					browser_height: (ratio == 1 ? window.innerHeight : (screen.height * ratio))			}	}} var dimensions = orientationChanged(); if (!dimensions) {	var dimensions = {			browser_width: window.innerWidth,			browser_height: window.innerHeight	}} ratio = (dimensions.browser_width / dimensions.browser_height);

$(window).bind('orientationchange', function() { 	dimensions = orientationChanged(); 		.		.		.});

Also, I'm using this meta tag:

<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1, maximum-scale=1" />

Problem is that I get correct values but when I try set with .css() or .width() it sets another value. I guess it sets good value, but problem lies in scale. I checked width after setting and it's good. So I need some advice.. Best regards..

Edited by Haris S
Link to comment
Share on other sites

It sets correct value but page is somehow rescaled like it's zoomed to 90%. If I set border on div which width is changed, I can see right border offset from right about 100px.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...