04-02-2018 05:49 - edited 04-02-2018 05:50
04-02-2018 05:49 - edited 04-02-2018 05:50
I've got a couple of blocks in the index.js for the watch face I've been playing with that operate on the onclick event of a hidden <rect> to toggle the visibility of elements. It's not the tidiest way of doing it, but it was the only way I could get it working. Anyway, is there an easy way of tidying up this code block to run it as a function so I can call it from a util.toggler(arg1, arg2) - where arg1 and arg2 are the "ArcFrame" parts in the current code - type arrangement? (Very) Basic javascripting I can muddle through but function construction I'm still just at the starting blocks.
if (stepArcFrame.style.display == "inline" && calArcFrame.style.display == "none") {
stepArcFrame.style.display = "none";
calArcFrame.style.display = "inline";
}
else
{
stepArcFrame.style.display = "inline";
calArcFrame.style.display = "none";
}
}
Best Answer04-25-2018 14:49
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.
04-25-2018 14:49
Something like this?
// util.js Toggle Show/Hide export function toggler(ele) { ele.style.display = (ele.style.display === "inline") ? "none" : "inline"; }util.toggler(stepArcFrame);
// index.js
import * as util from "util";
util.toggler(calArcFrame);
Best Answer