Dynamically update the side menu width


#1

Hello,
I need to have a different side menu width on portrait and landscape modes. (screen size - 50 pixels)
I know how to init the side menu with a dynamic width using the following code:

$rootScope.getMenuWidth = function() {
var deviceWidth = document.querySelector(‘body’).offsetWidth;
var menuWidth = deviceWidth - 50;
return menuWidth;
};

This function is called on app run and init the menu width correctly.
But calling the same function on screen rotation doesn’t update the menu width.

I also tried the following without success:
document.querySelector(’.menu.menu-right’).setAttribute(‘width’, menuWidth);

Thank you for your help!


#2

Any idea? :smile:

Thanks