mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
[api-minor] Add a new PageViewport
-getter to access the original, un-scaled, viewport dimensions
While reviewing recent patches, I couldn't help but noticing that we now have a lot of call-sites that manually access the `PageViewport.viewBox`-property. Rather than repeating that verbatim all over the code-base, this patch adds a lazily computed and cached getter for this data instead.
This commit is contained in:
parent
8e11cf9b1c
commit
cafdc48147
5 changed files with 45 additions and 41 deletions
|
@ -325,10 +325,10 @@ class TextLayerRenderTask {
|
|||
properties: null,
|
||||
ctx: getCtx(0, isOffscreenCanvasSupported),
|
||||
};
|
||||
const [pageLLx, pageLLy, pageURx, pageURy] = viewport.viewBox;
|
||||
this._transform = [1, 0, 0, -1, -pageLLx, pageURy];
|
||||
this._pageWidth = pageURx - pageLLx;
|
||||
this._pageHeight = pageURy - pageLLy;
|
||||
const { pageWidth, pageHeight, pageX, pageY } = viewport.rawDims;
|
||||
this._transform = [1, 0, 0, -1, -pageX, pageY + pageHeight];
|
||||
this._pageWidth = pageWidth;
|
||||
this._pageHeight = pageHeight;
|
||||
|
||||
setLayerDimensions(container, viewport);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue