Any parameter to detect PORTRAIT or LANDSCAPE on mobiles?

  • Hi there,

    I'm dealing with a mobile layout which need to be adapted dynamically for PORTRAIT and LANDSCAPE modes. Currently I'm finding out the orientation of the device comparing "stageheight" with "stagewidth" which works fine but, I was wondering if there is some already existing parameter which indicates which orientation do we have at mobile/tablets. ¿Any idea?

    Thank you.

    Luis

  • Thanks Tuur, I didn't know about that one. And Nupsi, thank you also for the tip, it happens to be exactly the way I'm doing it right now. *wink*

    I just wondered if maybe the parameter itself had been incorporated to krpano, which I think would be perfect, since it's a common issue to be dealing with both landscape and portrait modes on mobile interface design.

    ¿What do you think Klaus? ¿How about integrating some global variable like "mobile.orientation" or something to krpano? There are at least those two ways mentioned by Tuur and Nupsi which reveal the orientation of the device but I think it would be nice that krpano already had that option integrated.

    Best regards

    Luis

  • Hi,

    ¿What do you think Klaus? ¿How about integrating some global variable like "mobile.orientation" or something to krpano?

    This will come with version 1.17.

    The current 1.17 pre-release already offers these additional device informations:

    Code
    device.screen.width
    device.screen.height
    device.screen.orientation

    But the orientation value will be only correct when the browser itself supports it - e.g. Android Firefox and IE10/IE11 aren't currently providing any orientation informations.

    Best regards,
    Klaus

  • Perfect Klaus, this is a must feature to have in Krpano.

    Quote

    But the orientation value will be only correct when the browser itself supports it - e.g. Android Firefox and IE10/IE11 aren't currently providing any orientation informations.

    Well, there is always the option that Nupsi mentions, by comparing stagewidth and stageheight internally in Krpano there's an alternative way to find out device orientation considering that in tablets/mobiles user's not free to resize window at will (in which case this option wouldn't have sense), but just to use portrait or landscape orientation. That may work as far as I can see, just a suggestion. *wink*

    Best regards

    Luis

  • I hate it to play the party pooper, but why should an orientation-query always run, even if it´s not necessary for a project?! From my pov Klaus would´nt do much more than integrating the postet event right into the krpano-code. Please correct me if I´m wrong, Klaus *smile*
    But I would love to still have the choice to use such query, or not. Because with every new implemented background-routine the performance of krpano goes down a little. And if you can add such a feature with a single code-line, it´s much better in my opinion.

    Sorry if this sounds a little negative or anti-progressive, which is not intended, but krpano is NOT PanoTour and I really love it that way *wink*

    Best regards
    Nupsi

  • Ohhh c'mon Nupsi, don't be anti-progressive! *tongue*

    Now, I understand your point, indeed what I'm proposing Klaus here is to integrate that instruction to KRPANO so we wont need anymore to be including this codeline every time. This is indeed another routine which krpano would be doing constantly so it may decrease it's performance, in that sense I agree with you that this is not the best way to do it.

    What I feel here is that it would be easier to have a global parameter like the one mentioned by Klaus: device.screen.orientation, which would simplify code. In the end if we have already parameters to detect device, html5, gyro and other stuff, ¿why not to have one parameter for device orientation? There's where I thought about integrating the calculation itself to krpano.

    I guess the best way to do this is the one that Klaus already is considering which is through the browser, avoiding internal calculations. In some point I guess all browsers will provide detailed info about this but in the meantime there's always this alternate fix to find it out. It's just a quotient calculation and compared with the huge panoramic projection operations in krpano to display images I don't feel it's a heavy load but that's my opinion, it's Klaus the one who knows here how much it does really affect performance.

    Is just an idea Klaus, you'll know if it's useful or just nonsense.

    Best regards

    Luis

  • Hi,

    this doesn't affect performance at all

    The updating of these variables is event driven (resize, orientationChange events).

    The device.screen.orientation variable holds the real orientation value that the browser is reporting. It can be 0, 180, 90 or -90.

    Automatically faking this variable when the browser isn't supporting, by comparing screen width and height, would be possible and I'm considering doing that of course...

    Best regards,
    Klaus

  • Sorry for the noob question.
    Is there a way to always stay in landscape orientation on mobile devices? I feel like it is a simple with all the help from those plugins/variables, but right now I can't find out it for myself. Maybe I need some more sleep. :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!