Sie sind nicht angemeldet.

1

Montag, 25. März 2019, 11:19

how to get variables like "width.mobile"

Hi,
I wonder what will be the syntax of getting values of variables like the above mentioned.

Eg "trace(get(plugin[blabla].width.mobile));" will not work. How can I get these extended variables like x.mobile, y.tablet etc.?

Thanks!

2

Montag, 25. März 2019, 12:01

plugin[blabla].width="50" plugin[blabla].width.mobile="100"
means width will be normally 50, or 100 if device.mobile is true

after the xml is parsed you cant get to these device specific values anymore,
but you have the result in plugin[blabla].width
trace(plugin[blabla].width);

3

Montag, 25. März 2019, 12:31

ah, so with get(plugin[blabla].width) I will get mobile-width when using a mobile device and desktop-width when using desktop...

Thanks!

4

Montag, 25. März 2019, 13:34

yes normally you set a default and the specials
...
with="200" with.mobile="250"
...

5

Mittwoch, 27. März 2019, 16:44

Hi,

everything after the '.' dot in an attribute name is a kind of 'filter' for the xml parsing.
It decides if that attribute will be parsed and set or skipped.

Please see here for more:
https://krpano.com/docu/xml/#devicechecksforattributes


One additional note about:

Quellcode

1
2
plugin[blabla].width="50" plugin[blabla].width.mobile="100"
means width will be normally 50, or 100 if device.mobile is true


Attributes are parsed one after the other - and some browsers (only IE so far I known) are passing the arguments in RANDOM order to the application (=to krpano). According to the xml-specs this is allowed.

So it's not guaranteed that width.mobile="..." will be processed after width="...".

Therefore 'non-overlapping' declration should be used.
E.g. correct would be:
width.normal="..."
width.mobile="..."

The filter '.normal' will cover desktop and tablet devices and '.mobile' will cover mobile devices. So all cases are clear and the order doesn't matter.

Best regards,
Klaus