react-fast-pdf
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -11,2 +11,4 @@ import React, { type CSSProperties } from 'react'; | ||
getDevicePixelRatio: (width: number, height: number) => number | undefined; | ||
numPages: number; | ||
containerHeight: number; | ||
}; | ||
@@ -30,2 +32,6 @@ }; | ||
getDevicePixelRatio: PropTypes.Validator<(...args: any[]) => any>; | ||
/** The number of pages in the document */ | ||
numPages: PropTypes.Validator<number>; | ||
/** The height of the container view */ | ||
containerHeight: PropTypes.Validator<number>; | ||
}>>>; | ||
@@ -32,0 +38,0 @@ /** Additional style props passed by VariableSizeList */ |
@@ -47,2 +47,6 @@ "use strict"; | ||
getDevicePixelRatio: prop_types_1.default.func.isRequired, | ||
/** The number of pages in the document */ | ||
numPages: prop_types_1.default.number.isRequired, | ||
/** The height of the container view */ | ||
containerHeight: prop_types_1.default.number.isRequired, | ||
}).isRequired, | ||
@@ -54,3 +58,3 @@ /** Additional style props passed by VariableSizeList */ | ||
function PageRenderer({ index, style, data }) { | ||
const { pageWidth, estimatedPageHeight, calculatePageHeight, getDevicePixelRatio } = data; | ||
const { pageWidth, estimatedPageHeight, calculatePageHeight, getDevicePixelRatio, numPages, containerHeight } = data; | ||
/** | ||
@@ -62,3 +66,4 @@ * Render a specific page based on its index. | ||
const devicePixelRatio = getDevicePixelRatio(pageWidth, pageHeight); | ||
return (react_1.default.createElement("div", { style: Object.assign(Object.assign(Object.assign({}, styles_1.pdfPreviewerStyles.pageWrapper), style), { top: `${parseFloat(style.top) + constants_1.PAGE_BORDER}px` }) }, | ||
const topPadding = numPages > 1 ? parseFloat(style.top) + constants_1.PAGE_BORDER : containerHeight - parseFloat(style.height) / 2; | ||
return (react_1.default.createElement("div", { style: Object.assign(Object.assign(Object.assign({}, styles_1.pdfPreviewerStyles.pageWrapper), style), { top: `${topPadding}px` }) }, | ||
react_1.default.createElement(react_pdf_1.Page, { key: `page_${index}`, width: pageWidth, height: pageHeight || estimatedPageHeight, pageIndex: index, | ||
@@ -65,0 +70,0 @@ // This needs to be empty to avoid multiple loading texts which show per page and look ugly |
@@ -197,3 +197,3 @@ "use strict"; | ||
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles_1.pdfPreviewerStyles.innerContainer), (shouldRequestPassword ? styles_1.pdfPreviewerStyles.invisibleContainer : {})) }, | ||
react_1.default.createElement(react_pdf_1.Document, { file: file, options: constants_1.DEFAULT_DOCUMENT_OPTIONS, externalLinkTarget: constants_1.DEFAULT_EXTERNAL_LINK_TARGET, error: shouldShowErrorComponent ? ErrorComponent : null, onLoadError: onLoadError, loading: LoadingComponent, onLoadSuccess: onDocumentLoadSuccess, onPassword: initiatePasswordChallenge }, pageViewports.length > 0 && (react_1.default.createElement(react_window_1.VariableSizeList, { style: Object.assign(Object.assign({}, styles_1.pdfPreviewerStyles.list), contentContainerStyle), outerRef: helpers_1.setListAttributes, width: isSmallScreen ? pageWidth : containerWidth, height: containerHeight, itemCount: numPages, itemSize: calculatePageHeight, estimatedItemSize: calculatePageHeight(0), itemData: { pageWidth, estimatedPageHeight, calculatePageHeight, getDevicePixelRatio } }, PageRenderer_1.default)))), | ||
react_1.default.createElement(react_pdf_1.Document, { file: file, options: constants_1.DEFAULT_DOCUMENT_OPTIONS, externalLinkTarget: constants_1.DEFAULT_EXTERNAL_LINK_TARGET, error: shouldShowErrorComponent ? ErrorComponent : null, onLoadError: onLoadError, loading: LoadingComponent, onLoadSuccess: onDocumentLoadSuccess, onPassword: initiatePasswordChallenge }, pageViewports.length > 0 && (react_1.default.createElement(react_window_1.VariableSizeList, { style: Object.assign(Object.assign({}, styles_1.pdfPreviewerStyles.list), contentContainerStyle), outerRef: helpers_1.setListAttributes, width: isSmallScreen ? pageWidth : containerWidth, height: containerHeight, itemCount: numPages, itemSize: calculatePageHeight, estimatedItemSize: calculatePageHeight(0), itemData: { pageWidth, estimatedPageHeight, calculatePageHeight, getDevicePixelRatio, containerHeight, numPages } }, PageRenderer_1.default)))), | ||
shouldRequestPassword && internalRenderPasswordForm())); | ||
@@ -200,0 +200,0 @@ } |
{ | ||
"name": "react-fast-pdf", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "react-fast-pdf", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
67989
1435