Add event listener on page resize
There is a special event listener in javascript that is called whenever a page resize is detected. The event listener is named 'resize' and can be used in the following way:
```
function onFrameResize(){
console.table(
{
Height: window.innerHeight,
Width: window.innerWidth
}
);
}
window.addEventListener("resize", onFrameResize);
```
"window.innerHeight" and "window.innerWidth" are functions to access the width and the height of the frame.
This functionality will come in handy when working with responsive components.
Mihai Barbu
08 Dec 2021
« Back to post