I can’t figure out how to calculate the percentage of the containers width a component is occupying. What I’d like to do is check on ready if the sidebar is taking up more than %25 of its’ container, and start it out collapsed.
Thanks for any suggestions!
Currently doing this, but using the app not the parent. Any way to access parent width?
ready: function(){
var parentWidth = app.config.container.clientWidth;
if (this.$width > parentWidth*0.25) {
this.toggle();
}
}
You can use collapsed: true
in Sidebar configuration.
Setting collapsed: true would certainly make it collapsed.
My question was more about how to make it responsive to the screen size.
You can set collapsed
property depending on the rule you need:
function getScreenWidth(){
var size = ...;
return size;
}
...
collapsed: (getScreenWidth()>700),
...