diff options
Diffstat (limited to 'beamer')
-rw-r--r-- | beamer/viewer/screen/screen.js | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/beamer/viewer/screen/screen.js b/beamer/viewer/screen/screen.js index 3d95acd..4bebab4 100644 --- a/beamer/viewer/screen/screen.js +++ b/beamer/viewer/screen/screen.js | |||
@@ -47,9 +47,32 @@ class Screen { | |||
47 | }; | 47 | }; |
48 | } | 48 | } |
49 | 49 | ||
50 | _getScreenOffsets(secondary, width, height) { | ||
51 | if (!secondary) return { xOffset: 0, yOffset: 0 }; | ||
52 | |||
53 | const viewport = this.page.getViewport(1); | ||
54 | if (viewport.width > viewport.height) | ||
55 | return { xOffset: -width, yOffset: 0 }; | ||
56 | else | ||
57 | return { xOffset: 0, yOffset: -height }; | ||
58 | } | ||
59 | |||
50 | _getSlideSizeRatio() { | 60 | _getSlideSizeRatio() { |
51 | const viewport = this.page.getViewport(1); | 61 | const viewport = this.page.getViewport(1); |
52 | return (viewport.width / 2) / viewport.height; | 62 | |
63 | if (viewport.width > viewport.height) | ||
64 | return (viewport.width / 2) / viewport.height; | ||
65 | else | ||
66 | return viewport.width / (viewport.height / 2); | ||
67 | } | ||
68 | |||
69 | _getScaleFactor(width, height) { | ||
70 | const viewport = this.page.getViewport(1); | ||
71 | |||
72 | if (viewport.width > viewport.height) | ||
73 | return height / viewport.height; | ||
74 | else | ||
75 | return width / viewport.width; | ||
53 | } | 76 | } |
54 | 77 | ||
55 | _newCanvas(width, height, xOffset, yOffset) { | 78 | _newCanvas(width, height, xOffset, yOffset) { |
@@ -86,9 +109,11 @@ class Screen { | |||
86 | 109 | ||
87 | const screenRatio = this._getSlideSizeRatio(); | 110 | const screenRatio = this._getSlideSizeRatio(); |
88 | const { width, height } = this._getScreenSize(screenRatio); | 111 | const { width, height } = this._getScreenSize(screenRatio); |
89 | const scaleFactor = height / this.page.getViewport(1).height; | 112 | const scaleFactor = this._getScaleFactor(width, height); |
90 | const xOffset = this.secondary ? -width : 0; | 113 | const { xOffset, yOffset } = |
91 | const { canvas, context } = this._newCanvas(width, height, xOffset, 0); | 114 | this._getScreenOffsets(this.secondary, width, height); |
115 | const { canvas, context } = | ||
116 | this._newCanvas(width, height, xOffset, yOffset); | ||
92 | this._render(canvas, context, scaleFactor); | 117 | this._render(canvas, context, scaleFactor); |
93 | } | 118 | } |
94 | } | 119 | } |