- 
                Notifications
    You must be signed in to change notification settings 
- Fork 53
fix: Fix content size #1227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix content size #1227
Conversation
| /compile amend / | 
The viewer contents are shown with a bottom margin used to "frame" them, but the PDF viewer is expected to cover that bottom margin and use the full height instead. In mobile devices the viewport height might be larger than the actual viewport, for example when special UI elements like the navigation bar are being shown. When that happens, the height of the PDF viewer is larger than the height of its parent plus the bottom margin (as the height of the PDF viewer is based on the viewport size, and the height of its parent is based on the available height), so as the PDF viewer is vertically centered it ends overlapping the header at the top and being cut by the end of the page at the bottom. To solve that, now the height of the PDF viewer is based instead on the height of its parent plus the bottom margin that needs to be covered. Besides that, the top margin in the PDF viewer is used to compensate for the bottom margin in its parent due to being vertically aligned. Although that works this is now also simplified by aligning the top of the PDF viewer to the top of its parent. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
917b3f9    to
    c2402e7      
    Compare
  
    | /backport to stable31 | 
| /backport to stable30 | 
| @pierluigizagaria Thanks for the analysis. But please note that by default the modal component in nextcloud-vue actually uses  | 
| I need to investigate where the height: auto comes from | 
| 
 It comes from the same Viewer component that sets the mentioned bottom margin (margin as in additional space, not as in CSS margin), as the height is implicitly defined by its top and bottom properties. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and seems to work. Thanks for fixing this! 

Fixes #660
Fixes #833
Fixes #981
Fixes #1020
The PDF viewer is meant to cover the full modal it is shown in, except for its header. And the modal is meant to use all the available height. The PDF viewer is inside a centered flexbox that is aligned with the bottom of the header, but that flexbox does not reach the bottom of the modal, as it is inside another element that "frames" it with a bottom margin equal to the header height. Therefore, the PDF viewer is expected to overflow its parent to cover that bottom margin, and as it is vertically centered in its parent it needs to use a top margin equal to the extra height at the bottom to "compensate" for that height and keep the alignment with the header.
In desktop computers this works fine, because the height of the modal matches the height of the viewport, so the height of the PDF viewer is the height of its parent plus the bottom margin. However, in mobile devices the viewport height might be larger than the actual viewport, for example when special UI elements like the navigation bar are being shown. When that happens, the height of the PDF viewer is larger than the height of its parent plus the bottom margin (as the height of the PDF viewer is based on the viewport size, and the height of its parent is based on the available height), so as the PDF viewer is vertically centered it ends overlapping the header at the top and being cut by the end of the page at the bottom.
Using dynamic viewport units (
dvh) instead of viewport units (vh) for the height would solve the issue. However, that just happens to work because the modal uses all the available height. If the modal itself had a different height then the PDF viewer height would be wrong also when usingdvhunits. Therefore, the height of the PDF viewer should be based instead on the size of its parent. As mentioned the parent has a bottom margin that needs to be covered by the PDF viewer, so its height should be the height of its parent plus the height of the margin; while this also requires using an "external" size it is a "closer" one and should be conceptually easier to understand.Besides all that, the top margin in the PDF viewer is used to compensate for the bottom margin in its parent, so it matches the header height only because the bottom margin in the parent is the header height. If a different height was used the top margin would be different than the header height, and it would be quite confusing. Therefore a better approach would be to explicitly align the PDF viewer with the top of its parent, which removes the need to use a top margin as it will be no longer vertically centered.
How to test
Result with this pull request
The PDF is below the header, and scrolling to the bottom shows the end of the PDF file
Result with this pull request
The PDF overlaps the header, and scrolling to the bottom shows the end of the PDF file as well as the scroll bar cut