Skip to content

Commit

Permalink
fix: unnecessary scrollbars when zoom is fit-to-screen
Browse files Browse the repository at this point in the history
- fix: #1158
  • Loading branch information
MurakamiShinyu committed Apr 5, 2023
1 parent 8803acc commit bb504a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/core/src/vivliostyle/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const VivliostyleViewportScreenCss = `
}
[data-vivliostyle-viewer-viewport] {
box-sizing: border-box;
display: flex;
overflow: auto;
position: relative;
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/vivliostyle/vgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2906,8 +2906,16 @@ export class Viewport {
this.outerZoomBox = outerZoomBox as HTMLElement;
this.contentContainer = contentContainer as HTMLElement;
this.layoutBox = layoutBox as HTMLElement;
this.width = opt_width || this.root.offsetWidth || window.innerWidth;
this.height = opt_height || this.root.offsetHeight || window.innerHeight;
this.width =
opt_width ||
parseFloat(window.getComputedStyle(this.root).width) ||
this.root.offsetWidth ||
window.innerWidth;
this.height =
opt_height ||
parseFloat(window.getComputedStyle(this.root).height) ||
this.root.offsetHeight ||
window.innerHeight;

// Use the fallbackPageSize if window size is 0 or browser is in headless mode.
const fallbackPageSize = {
Expand Down

0 comments on commit bb504a6

Please sign in to comment.