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 Answer
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.
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 Answer
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.
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 AnswerThanks 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