I am attempting to detect when a device changes it's orientation and update my component to reflect the new orientation.
The problem with my approach is that my event lives outside of the components life-cycle which in turn makes the component variable is undefined thus rendering the code inside the event absolutely useless.
Anyone that has some insight into what I could do to achieve this would great.
afterRender: function(component,helper){
this.superAfterRender();
window.addEventListener("orientationchange", function() {
window.setTimeout(function(){
if(window.innerWidth <= 768) {
component.set('v.deviceWidth','small');
} else if(window.innerWidth > 768 && window.innerWidth < 1440) {
component.set('v.deviceWidth','medium');
} else if(window.innerWidth >= 1440) {
component.set('v.deviceWidth','large');
}
},500);
});
}