window.innerWidth / innerHeight #591
-
Hello, up until v6 the size of the window object via innerWidth / innerHeight was reported as 1024 * 768. a) Was this change deliberate with the new addition of the various CSS interfaces? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I found this strolling the repo ... window.happyDOM.setInnerWidth(1024); |
Beta Was this translation helpful? Give feedback.
-
Hi @WebMechanic! 🙂 The change was intentional as it is now possible to send in "innerWidth" and "innerHeight" as properties to the constructor. Offset properties has not been changed. They are set to 0 as Happy DOM currently doesn't support calculating them yet, but I guess we could set them to the same as "innerWidth" and "innerHeight" on the document element. It is also possible to set "innerWidth" and "innerHeight" now through a method, which will trigger a "resize" event. I have just updated the documentation to cover this. Documentation: Example 1: const window = new Window({
innerWidth: 1024,
innerHeight: 768,
url: 'http://localhost:8080'
}); Example 2: window.happyDOM.setInnerWidth(1024);
window.happyDOM.setInnerHeight(1024); |
Beta Was this translation helpful? Give feedback.
Hi @WebMechanic! 🙂
The change was intentional as it is now possible to send in "innerWidth" and "innerHeight" as properties to the constructor.
Offset properties has not been changed. They are set to 0 as Happy DOM currently doesn't support calculating them yet, but I guess we could set them to the same as "innerWidth" and "innerHeight" on the document element.
It is also possible to set "innerWidth" and "innerHeight" now through a method, which will trigger a "resize" event.
I have just updated the documentation to cover this.
Documentation:
https://github.com/capricorn86/happy-dom/tree/master/packages/happy-dom
Example 1: