Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/components/drivers/pdf-viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Object.freeze(ZOOM_STEPS)

const MAX_ZOOM_INDEX = ZOOM_VALUES.length - 1
const DEFAULT_ZOOM_INDEX = 8 // 1.0 (100%)
const WIDTH_FIT_SCALE = 0.8 // 80% screen width

export default class PDFDriver extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -220,7 +221,7 @@ export default class PDFDriver extends React.Component {
scale: 1.0,
rotation: this.props.rotationValue || 0,
})
const scaleWidth = (containerWidth / viewport.width) * 0.8
const scaleWidth = (containerWidth / viewport.width) * WIDTH_FIT_SCALE
return this.findClosestZoomStep(scaleWidth)
}

Expand Down
13 changes: 4 additions & 9 deletions src/components/drivers/photo-viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ export default class PhotoViewer extends Component {
constructor(props) {
super(props)

const { originalHeight, originalWidth, width: viewerWidth } = props
const { originalWidth, width: viewerWidth } = props

const bestFitZoomIndex = this.calculateBestFitZoom(
originalWidth,
originalHeight,
viewerWidth
)

Expand Down Expand Up @@ -82,13 +81,9 @@ export default class PhotoViewer extends Component {
return closestIndex
}

calculateBestFitZoom(imageWidth, imageHeight, containerWidth) {
if (imageWidth > imageHeight) {
const scaleWidth = (containerWidth / imageWidth) * WIDTH_FIT_SCALE
return this.findClosestZoomStep(scaleWidth)
}

return this.findClosestZoomStep(1.0)
calculateBestFitZoom(imageWidth, containerWidth) {
const scaleWidth = (containerWidth / imageWidth) * WIDTH_FIT_SCALE
return this.findClosestZoomStep(scaleWidth)
}

setZoom(index) {
Expand Down
Loading