Sie sind nicht angemeldet.

1

Donnerstag, 21. Dezember 2017, 09:22

textfield devicedepending attributes

I just startet to use "attribute.xxx=..." xml-definition code in future for better readable code (xxx means e.g. "normar", "desktop.or.tablet", and so on).
But i have problems with this using dynamic added layers type "text":

definitions like:
set(plugin[myText].autowidth.normal, true);
set(plugin[myText].css.mobile, 'css here...');
set(plugin[myText].width.desktop.or.tablet, 200);
don´t work.

Is it not possible to use those device attributes within layers of the plugin type text?
Or is it not possible to use them within any dynamic added code?
best regards from www.PanAustria.com

2

Donnerstag, 21. Dezember 2017, 10:16

i dont think that works in dynamic code
guess you must do it like this
if(device.desktop OR device.tablet, set(plugin[myText].width, 200));

toosten

Fortgeschrittener

Beiträge: 428

Wohnort: Berlin

Beruf: freier Software-Entwickler ( HTML, JS, PHP, JSP, Flash, AS3, C++, Java, krpano, ---)

  • Nachricht senden

3

Donnerstag, 21. Dezember 2017, 10:18

https://krpano.com/docu/actions/#device.normal

if( device.normal, set(plugin[myText].autowidth, true));
if( device.mobile, set(plugin[myText].css, 'css here...'));


if( device.desktop, set(plugin[myText].width, 200));
if( device.tablet, set(plugin[myText].width, 200));

or

if((device.desktop) OR (device.tablet), set(plugin[myText].width, 200));

4

Freitag, 29. Dezember 2017, 09:23

Thank you both for your reply!
I know the workaround as well -
...would be fine to here from Klaus if this is a (known/unknown) bug or part of the concept.
Consequently I would expect this to work because it eases coding as well as readability and in my understanding those were the goals for the new syntax...

Best regards,
Panaustria
best regards from www.PanAustria.com

toosten

Fortgeschrittener

Beiträge: 428

Wohnort: Berlin

Beruf: freier Software-Entwickler ( HTML, JS, PHP, JSP, Flash, AS3, C++, Java, krpano, ---)

  • Nachricht senden

5

Freitag, 29. Dezember 2017, 11:14

Wenn Du das direkt in XML definierst, dann funktioniert es, aber nicht im dynamischen Actions-Bereich.
Du könntest diese Parameter auch in einem https://krpano.com/docu/xml/#style definieren und dann per https://krpano.com/docu/xml/#layer.loadstyle laden.

6

Freitag, 29. Dezember 2017, 11:18

the condition-appendix desktop.or.tablet gets evaluated when the xml gets parsed
and plugin[myText].width gets set depending on the condition

but in an action / dynamic code you cannot use this form anymore,
this is part of the concept and not a bug, i m sure.

7

Freitag, 29. Dezember 2017, 18:41

the condition-appendix desktop.or.tablet gets evaluated when the xml gets parsed
and plugin[myText].width gets set depending on the condition


Thx, that answered my question. I was not aware i gets resolved while parseing - you are right! So it is no bug.
best regards from www.PanAustria.com

8

Montag, 8. Januar 2018, 17:38

Personally I think using the calc() action and the Ternary operator is a nice way to do dynamic device checks:

Quellcode

1
set(variable, calc(ifcheck ? thenvalue : elsevalue));
or this way (is the same):

Quellcode

1
calc(variable, ifcheck ? thenvalue : elsevalue);
First write the variable to check, then the value that should be used when this check is true, and then the value that should be used when not.

E.g.

Quellcode

1
set(plugin[test].width, calc(device.normal ? 300 : 200));


Btw - device.normal is the same as 'device.desktop OR device.tablet'.