Sizing a plugin on tablet/mobile with portrait/landscape considerations

  • Hi

    I am trying to show a graphic ( Help screen ) I would prefer it to be displayed reasonably large as possible, for example 75% of the smallest dimension
    of the device viewport

    My graphic is not square but to simplify lets say it is..

    If I could assume landscape I might write....

    width="prop" height="75%"

    However since the aspect ratio of tablets and smart phones can flip as the device is rotated I would in effect need to modify the above line to

    height="prop" width="75%"

    Any ideas how these two statements can be replaced with a statement that ensures that the graphic is not more than 75% of the device viewport
    in either direction?

    I was sure this would have been asked previously but I could not find any leads in the forum - perhaps being dumb or searching with the wrong words?

    Thanks in advance

    Jon

  • Hi,

    the direct detection of the device orientation is currently not possible (but I think I will had a variable for getting the origination),
    but the screen size could be used to decide how the device is orientated,
    e.g. width > height = landscape - or - height > width = portrait

    with xml:

    best regards,
    Klaus

  • Hi Klaus

    I used your code and it worked just fine - thanks.

    The only thing I added in addition was to add the line

    if(stagewidth GT stageheight, landscape(), portrait());


    into the krpano startup action.

    I figured it was simply easier to add this line rather than to risk the possibility that devices can start up in either
    portrait or landscape without the resize event handler being called.

    Thanks again

    Kind regards

    Jonnie

Participate now!

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