Howdy. I’ve built a dynamic interface in which users may split panels to suit their needs. They can be resized using resizers. However, since they are created dynamically and I never know what panels are on either side of the resizer, I can’t use it’s event to catch an onResize event.
I’ve found a workaround for this that is placing 2 1pixel high/wide datatables in each non-datatable panel in order to catch the event but this seems to result in some inconsistent behaviour (besides feeling like a horrendous patchwork solution).
Any native way to get onResize to work with layouts?
Can you share the use-case, why do you need the onResize event at all?
Do you need to store the sizes of UI, or have a custom UI that need to be resized in some specific way? There are solutions for both scenarios that will work without onResize event.
Users can split panels vertically and horizontally at will and fill the panels with pre-defined components. One of these components is a d3-chart. I need the browser resize event because if the parent panel of the d3-chart resizes, the d3-chart itself does not automatically resize to fit the content, it has to be done manually because the svg inside the chart is also set manually and doesn’t adjust.
As is, I’m accomplishing this by detecting a window.onresize, finding all d3-chart components currently in the UI and calling the manual resize method.
All other components are not an issue because they’re based on datatables and I can just use the native onResize, which detects both the resizer resize and browser resize.
You can subclass view and redefine $setSizes to have a full control over resizing. $setSize is called each time when new size is applied to the view.
if the next code, change the oldview to the name of view where you need to have a custom logic.
webix.protoUI({
name:"newview",
$setSize:function(x,y){
//will be called after each resize
return webix.ui.oldview.prototype.$setSize(x,y);
}
}, webix.ui.oldview);
//later
webix.ui({ view:"newview" })