Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Proposal regarding the window size #23

Open
andyvalerio opened this issue Nov 26, 2019 · 3 comments
Open

Proposal regarding the window size #23

andyvalerio opened this issue Nov 26, 2019 · 3 comments

Comments

@andyvalerio
Copy link

Hi Mobius1,
thanks a lot for creating this! I'm playing with it these days and I started wondering about the window size.
I see that you are defining it using the window's inner dimensions:
width: window.innerWidth,
height: window.innerHeight

I wonder whether, especially for mobile, it wouldn't be better to use something else. For example I'm getting more consistent results using the body's dimensions:
width: document.body.clientWidth,
height: document.body.clientHeight

The issue with using window's dimensions on mobile is that most of the time part of the window is covered by the address bar (on Chrome at least) and even using innerWidth/innerHeight as you are doing, it doesn't seem to consistently return the available space, but rather the dimensions of the whole window. At least for me this makes the content quite often look not centered and it even goes out of the view.

Would you consider making this configurable somehow?

Again, thanks a lot for this library.

@Mobius1
Copy link
Owner

Mobius1 commented Feb 3, 2020

Sorry, I've only just seen this. For some reason I'm not getting notifications for new issues.

I agree there needs to be a different calculation for mobile window dimensions. I'll do a bit more testing and what happens. Pull requests are welcome.

@andyvalerio
Copy link
Author

Hi, no worries!
A few months have gone but I actually ended up using this in production, I modified it a bit like I said mainly using document.body.clientWidth and with a bit of hardcoding here and there if I recall correctly. It does its job anyway, I'm grateful you created this.

I don't have much time over lately so I won't be able to create a proper pull request (I did sent a little donation instead, to clean my conscience :'D) and if you think it can be useful I can send you the file I changed "as is".

@Mobius1
Copy link
Owner

Mobius1 commented Feb 20, 2020

Much appreciated. I'm glad you find the lib helpful. If you you can send me the changes you made it'll help!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants