0

I am working on mobile device app written in JavaScript. I am wondering if there is an option to get new value of element's width when orientation was changed. I know that I can use $(window).on("orientationchange",function(){}); to catch moment when orientation is changing, but css values are not recalculated here. I also try to use attrchange plugin, but orientation changes do not causes attrchange event.

Does someone overcome this issue?

krzyhub
  • 6,285
  • 11
  • 42
  • 68
  • Why don't use `$(window).on("resize",function(){});` – Aroniaina Nov 06 '15 at 14:18
  • With `console.log($('body').width())` I am getting narrower width when my device is in horizontal position and wider in opposite case, but I am looking for new, recalculated values... – krzyhub Nov 06 '15 at 14:25

1 Answers1

0

If the problem is css value use media query:

/* portrait */
@media screen and (orientation:portrait) {
    /* portrait-specific styles */
}
/* landscape */
@media screen and (orientation:landscape) {
    /* landscape-specific styles */
}
Germano Plebani
  • 3,461
  • 3
  • 26
  • 38
  • I also tried this but without effect :/ Lastly and sadly I use a time interval function with some code inside to catch moment of awaited change. – krzyhub Nov 12 '15 at 15:46
  • http://stackoverflow.com/questions/18747644/mobile-orientation-change-not-applying-css – Germano Plebani Nov 12 '15 at 17:28