I have a component called StartAnimation that receives a parameter called HH and based on that its internals get resized, such as “Red” having the dimension HH x HH and “Green” being HH x (2 * HH) .
My questions are:
What is the optimal way to do this? (I’m pretty sure the way I did it isn’t the proper way)
Is there a way to add basic operations in an element’s property?
Such as
It would be easier to answer this question if you start by describing what you want to achieve, instead of posting a broken implementation with no explaination In general, components in fuse represent visual elements, not “animations” per se, so StartAnimation is a weird name for a component. What are you trying to do here? Also, it is bad practice to use JS to compute layout properties like you do here. It shouldn’t be neccessary. The component should be rewritten to use plain UX layout rules. Again, if you describe what you want to achieve, it will be easier to suggest a solution.
No, not in 0.28 - but! a full UX reactive expression system is implemented internally and currently in test/documentation phase and will be released soon. So stay tuned
You are getting NaN because you are initializing your observable with an undefined value. Use Observable(function() { if you depend on the value of another observable.
Alright, ignore the example at the top and let me rephrase:
what I want to make is a component that lays out its many children elements based on a single param.
Some elements are 9 x param wide, others are 2 x param high, etc. They are all relative to param (which could even be the component’s height if it makes things easier).
There are about 6 layout values that depend on param. So in order to avoid writing something like
To me it sounds like what you are describing is a Grid where you databind the column and row descriptors. Take a look at the examples and docs for Grid and see if something lights up.