03-11-2019 05:39
03-11-2019 05:39
I want to dynamical change how items are displayed on the screen under various conditions. i.e. in the case in question, I want text to change to a different font size; the color to change and the position on the screen to change if it is raining
I have achieved the first two requirements, but can not find out how to do the third - i.e. I want to set the position on the screen at 50% from the top if the condition is met (When it rains, the color of my font changes to light green, the font size increases to 60, but the position on the screen does not move)
Please can someone advise what the correct syntax for this is ?
myRain.style.fill = "lightgreen";
myRain.style.fontSize = 60;
myRain.style.top = "50 %"; // <---- This is the syntax that is not working
03-11-2019 06:00 - edited 03-11-2019 06:11
03-11-2019 06:00 - edited 03-11-2019 06:11
As far as I know it is not possible to use the percentage syntax in JavaScript. What I have done is the following:
import { me as device } from "device";
let x = device.screen.width / 2; // 50% screen position
lblTime.x = x;
This works fine for me. Same is possible for height and y.