You are not logged in.

360boy

Intermediate

  • "360boy" started this thread

Posts: 249

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

1

Thursday, August 8th 2013, 8:32pm

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

Tuur

Sage

Posts: 3,839

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

3

Friday, August 9th 2013, 8:59am

Or even much simpler:
if(stagewidth GT stageheight, action(is_horizontal), action(is_vertical));

Best regards,
Nupsi

360boy

Intermediate

  • "360boy" started this thread

Posts: 249

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

4

Saturday, August 10th 2013, 10:43pm

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. ;-)

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

5

Saturday, August 10th 2013, 11:01pm

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:

Source code

1
2
3
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

360boy

Intermediate

  • "360boy" started this thread

Posts: 249

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

6

Tuesday, August 13th 2013, 9:20pm

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

Quoted

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. ;-)

Best regards

Luis

7

Wednesday, August 14th 2013, 8:40am

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 ;-)

Best regards
Nupsi

360boy

Intermediate

  • "360boy" started this thread

Posts: 249

Location: Mexico City

Occupation: Virtual tours, Krpano coding, Graphic Design, Photographer, Panographer

  • Send private message

8

Thursday, August 15th 2013, 6:55pm

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

9

Friday, August 16th 2013, 4:50pm

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

10

Friday, April 4th 2014, 2:22pm

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. :)

11

Friday, April 4th 2014, 6:46pm

Is there a way to always stay in landscape orientation on mobile devices?
No, that's not possible from Javascipt code side.

Best regards,
Klaus

12

Saturday, April 5th 2014, 1:40pm

Is there a way to always stay in landscape orientation on mobile devices?
No, that's not possible from Javascipt code side.

Best regards,
Klaus

Can I ask for this feature if it is possible? Maybe some view parameter in xml for example.

13

Monday, April 7th 2014, 9:28am

Okay, more precise - that's technically not possible .