I am looking to implement custom styling on an element based on the current screenWidth of the window.
This can be achieved using the following @HostListener:
@HostListener('window:resize', ['$event'])
public resize() {
// Apply styles here depending on current window.innerWidth...
}
However, I only want the resize method to be triggered when the width of the window changes, and not when the height changes.
Currently, the resize method is called even if the user changes the window height, causing issues with my styling logic!
My question is: Is there a way in Angular to create something like ('window:resizeX') that will call resize() only when the window width changes, ignoring any changes in window height?