You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Scott Witte

Intermediate

  • "Scott Witte" started this thread

Posts: 272

Location: Milwaukee, WI USA

Occupation: Professional Photographer

  • Send private message

1

Tuesday, December 8th 2015, 5:31am

How do you set device checked attributes dynamically?

Say you have an object and you want to dynamically change an attribute tied to certain devices. For example:

<layer name="button" x="100" x.mobile="200" x.tablet="150" />

This works:

set(layer[button].x, 50);

but this fails:

set(layer[button].x.mobile, 50);


Obviously you can have a single x value, then run a function that resets it depending on the current device, but is there a way to do it more like I was trying?

Tuur

Sage

Posts: 3,184

Location: Netherlands

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

  • Send private message

2

Tuesday, December 8th 2015, 11:36am

hi,

try:
if(device.mobile, set(layer[button].x, 50));

etc

hope it helps
Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

Scott Witte

Intermediate

  • "Scott Witte" started this thread

Posts: 272

Location: Milwaukee, WI USA

Occupation: Professional Photographer

  • Send private message

3

Tuesday, December 8th 2015, 8:36pm

try:
if(device.mobile, set(layer[button].x, 50));


Right. That is the option I mentioned at the end of my post above. Still wondering if something like my first approach is possible. As it could be useful.

4

Tuesday, December 15th 2015, 3:03pm

Hi,

here the related documentation:
http://krpano.com/docu/xml/#devicechecksforattributes

These 'device checks for attributes' are static filters that will checked during the xml attribute parsing/resolving. When the check fails the attribute will be skipped and not set.

For the dynamic device checks at runtime use expressions and if() or calc() like actions:
http://krpano.com/docu/actions/#expressions

Best regards,
Klaus

Scott Witte

Intermediate

  • "Scott Witte" started this thread

Posts: 272

Location: Milwaukee, WI USA

Occupation: Professional Photographer

  • Send private message

5

Tuesday, December 15th 2015, 5:26pm

Thanks for the clarification.