02 Jul Simple Widget with Auto Size
Quite a few developers in Famo.us ask about getting the size of the parent from their view. I have written a simple widget to show how you can update your widget based on the parent size changing.
In this case, the widget is added to the main context, so the size will be the size of my screen (window) in the browser. You could also add it to another parent that has a size that is constant but may change based on a change in the app.
The widget will track the size change and update accordingly:
- Changes the size based on the percentage of the parent size
- Changes font size
- On the mobile device, rotating the device will change the size of the screen
You can play with my “Queen Bee” demo I wrote that uses this widget as its background.
Here is Queen Bee on jsfiddle.
Hope this helps give you a hint to how to get sizing correct on your widgets and views.
NOTE: You can extend the ContextualView and use the .commit method as I have done here.