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.

1

Monday, February 25th 2019, 4:51pm

Nested Tenary operator

Hi,
just tried nested Tenary operators, but it seems not to work.
EXAMPLE:
Sometimes I have different sizes on desktop, tablet or mobile.
To keep code small, I tried a nested tenary operator like:

width="calc:device.desktop ? 100 : device.tablet ? 150 : 100"

Does someone have similar experiences?


Would be a great feature...
Best regards,
Steve

toosten

Intermediate

Posts: 448

Location: Berlin

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

  • Send private message

2

Monday, February 25th 2019, 5:29pm

width="calc:(device.desktop ? 100 : calc(device.tablet ? 150 : 100))"

3

Monday, February 25th 2019, 6:08pm

width="calc:(device.desktop ? 100 : calc(device.tablet ? 150 : 100))"
aaaahhhhh.....one more calc() FU!
Thank you very much Toosten, that was the trick... *thumbsup*

Works perfect - so it is already a great feature... *g*

4

Tuesday, February 26th 2019, 5:28pm

Hi,

no need for a second calc, but parenthesis would need to be used for nesting:

Source code

1
width="calc:(device.desktop ? 100 : (device.tablet ? 150 : 100))"

Best regards,
Klaus