[dx] Posted April 23, 2013 Share Posted April 23, 2013 (edited) 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 April 23, 2013 by Haris S Link to comment Share on other sites More sharing options...
justsomeguy Posted April 23, 2013 Share Posted April 23, 2013 I'm not sure what problem you're having. Link to comment Share on other sites More sharing options...
[dx] Posted April 24, 2013 Author Share Posted April 24, 2013 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 More sharing options...
justsomeguy Posted April 24, 2013 Share Posted April 24, 2013 So the value is correct, or not? Should you also change the scale? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now