Skip to content
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 PDF blinks #24308

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/components/PDFView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class PDFView extends Component {
* Calculates a proper page height. The method should be called only when there are page viewports.
* It is based on a ratio between the specific page viewport width and provided page width.
* Also, the app should take into account the page borders.
* @param {*} pageIndex
* @param {Number} pageIndex
* @returns {Number}
*/
calculatePageHeight(pageIndex) {
Expand Down Expand Up @@ -178,13 +178,17 @@ class PDFView extends Component {
}

/**
* It is a currying method that returns a function that renders a specific page based on its index.
* The function includes a wrapper to apply virtualized styles.
* @param {Number} pageWidth
* Render a specific page based on its index.
* The method includes a wrapper to apply virtualized styles.
* @param {Object} page item object of the List
* @param {Number} page.index index of the page
* @param {Object} page.style virtualized styles
* @returns {JSX.Element}
*/
renderPage(pageWidth) {
return ({index, style}) => (
renderPage({index, style}) {
const pageWidth = this.calculatePageWidth();

return (
<View style={style}>
<Page
key={`page_${index}`}
Expand Down Expand Up @@ -240,7 +244,7 @@ class PDFView extends Component {
itemCount={this.state.numPages}
itemSize={this.calculatePageHeight}
>
{this.renderPage(pageWidth)}
{this.renderPage}
</List>
)}
</Document>
Expand Down
Loading