10-11-2018 18:51
10-11-2018 18:51
Hopefully an easy one...
How do I assign a percentage value to the var.x value? I can assign it a number (pixel):
myVar.x = 100;
I have yet to crack how to assign a percentage like I do in the .css. Both of these fail:
myVar.x = 40%;
myVar.x = "40%";
What am I missing here?
Thanks.
Answered! Go to the Best Answer.
Best Answer10-12-2018 04:20
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-12-2018 04:20
Sorry, the percentage values aren't currently supported, but you can calculate the pixel value from the device screen dimensions.
import { me as device } from "device";
if (!device.screen) device.screen = { width: 348, height: 250 };
let percent = 40;
let pixels = percent / 100 * device.screen.width;
myVar.x = pixels;
Best Answer10-12-2018 04:20
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-12-2018 04:20
Sorry, the percentage values aren't currently supported, but you can calculate the pixel value from the device screen dimensions.
import { me as device } from "device";
if (!device.screen) device.screen = { width: 348, height: 250 };
let percent = 40;
let pixels = percent / 100 * device.screen.width;
myVar.x = pixels;
Best Answer10-13-2018 14:03
10-13-2018 14:03
Thanks JohnFitbit. I am doing something similar to your solution, but I was hoping there might be a cleaner/simpler way of doing it.
Jeff
Best Answer