A few minutes ago, I announced a new node: node-red-contrib-ui-joystick. This node is based on nipplejs, which expects me to specify the size of the joystick widget in pixels:
var options = {
...
size: size, // Default size is 100 (px)
...
};
nipplejs.create(options);
When I started today with that node, I thought it would be best to set the node automatically as a percentage of the parent div element:
var size = Math.min($scope.containerDiv.clientWidth, $scope.containerDiv.clientHeight) * 0.49;
Because I thought: when the user increases the widget size in Node-RED, then the joystick circle will increase:
But at the end - as you can see above - I had to calculate the size of the widget as 49% of the parent div, otherwise nipplejs starts behaving very weird. But this means that I always have a lot of empty space around the joystick .
So I'm now wondering whether it is better to set a fixed size (e.g. 100px) on such a widget. If so, I don't know whether it is user-friendly to make this size adjustable as a property on the node's config screen? Or is a fixed size not good, because scrollbars will occur when the widget size is set too small?? But due to the empty space, I think a fixed size is much better ...
Any advise is welcome, because I'm stuck with this decision...
Thanks !
Bart
For something like your joystick then I would say something like a default of 3x3 would make sense as it's naturally a square - But yes everything inside needs to scale probably based on the smaller of width or height, and indeed if you need to fit a label in as well. (Currently I would probably try to avoid that for now)
Now the nipplejs widget is nicely scaled into the available area of my parent div, and I get no scrollbars when I start dragging the small circle around:
Hopefully other UI node developers can learn from our discussion ...