-
Notifications
You must be signed in to change notification settings - Fork 377
media queries not working in index #637
Comments
Hi @benoitchantre I found that media queries do work for the index, but the overall width/position of the index is always initialized at the dimensions for the portrait view. I worked out my styles so the total width of the index is the same for both portrait and landscape, you can set the height differently for each orientation. the media query I use to set iPad landscape rules is:
It would be great if Baker could initialize the index width independently for both orientations. |
Also, worth noting that device-width and device-height refer to the physical width/height of the device, regardless of orientation. min-width refers to the actual width, oriented. min-device-width refers to the narrowest dimension of a device screen. (on iPad and iPhone anyway.) |
Thanks for your infos @anjimi |
I dug into that a bit and it might be a problem, but not a technical one, but a logical one. The reason is that right now the index code for the WebView reads the size of the HTML page to determine its size (height and width) and position. This means that the page needs to have these informations loaded for us to position it correctly. As such... we either stop doing that, and allowing the index to "read" the width, or we find a way to work around it, somehow. This is however just my initial review, I didn't look too much yet into it. :) |
If we determine that an index page is displayed in full screen only, I think it would be easier: no need to read the size of the html page. You could then display the content of the index how do you want with css
What do you think @folletto ? |
It adds a lot of overload of configuration that way. Consider that right now all you need to do (if you don't want to do anything too fancy) is to write a HTML file. We need to keep it simple. :) |
You mean for the end user? A solution could be to let the user choice between a simple horizontal index (default) or a fullscreen index (new baker parameter that you can set in the book.json). |
I mean for the author, yes. The reason everyone is using Baker is also because we do a very hard work in making the things as simple as possible, so every single item that an author has to consider to write a book must be weighted very, very, very well. :) |
I understand. |
Just to be clear: we keep this issue open because we feel it is a problem that needs to be addressed, it's just that we haven't figured out how, so we're open to suggestion... let's try to find simple ones. :) |
When you set We cannot use media queries because the size of the index is always the same. Could it be possible to initialize the size of the index for both orientations when we use If you don't set the |
The reason is simple - and that's also the cause of the issue: the index picks up the size from the HTML, so first the HTML is there, then the box is sized. That's why media queries don't work. And that's also why if you specify a fixed size in This is the catch-22 here: by having currently the feature of the dynamic sizing, you lose the media queries. If we take away the dynamic sizing, you can use the media queries... except that however it will require a manual setup of the index for every orientation and device size, raising the complexity. Apart from this explanation of why it's not working, I can't add much before work is started on this issue. :) |
@folletto Would it be a good idea to add an extended property named |
What are you referring with |
The container of the index page would be always full-screen, like the content of the book. That would allow us to use media queries. Right now, the container of the index is sized from the values in This property would be an alternative to make a more sophisticated index with media-queries. |
Yes that's the issue, and that's an option we were evaluating, but we need to find then a way to do it properly, because if the page is full-screen, it means that we need to find a way to close it. Right now you just touch outside, but if it's full screen there's no "outside" to touch, thus making it difficult. But yes, it's an option. :) |
Right now, if you double-tap on the index it closes itself, even if you double-tap on a link. |
As I said above it's one of the solutions, but we are still evaluating the alternatives. ;) |
No problem. If you find a better solution and do not merge mine, I would not cry. |
It appears that we cannot use media queries with the index page.
The document orientation isn't recognized and we cannot use max-device-width, maybe because the device-width info isn't updated on orientation change?
My index page uses media queries like other pages from my book, but only the index page (fullscreen) has problems with it's resize on orientation change.
Here's an simple test:
And when using device-width instead of orientation in media queries
The text was updated successfully, but these errors were encountered: