Skip to content
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
262 changes: 214 additions & 48 deletions js/viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer.js.map

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
}"
:src="data"
:style="{
height: zoomHeight + 'px',
width: zoomWidth + 'px',
height: minHeight,
width: minWidth,
marginTop: shiftY + 'px',
marginLeft: shiftX + 'px'
}"
Expand Down Expand Up @@ -68,6 +68,19 @@ export default {
},
zoomWidth() {
return Math.round(this.width * this.zoomRatio)
},

// prevent images smaller than 100px
minHeight() {
return this.zoomWidth < 100
? null
: this.zoomHeight + 'px'
},
// prevent images smaller than 100px
minWidth() {
return this.zoomHeight < 100
? null
: this.zoomWidth + 'px'
}
},
asyncComputed: {
Expand Down Expand Up @@ -103,11 +116,10 @@ export default {
updateImgSize() {
const naturalHeight = this.$el.naturalHeight
const naturalWidth = this.$el.naturalWidth
// displaying tiny images makes no sense,
// let's try to an least dispay them at 100x100

this.updateHeightWidth(
Math.max(naturalHeight, 100),
Math.max(naturalWidth, 100)
naturalHeight,
naturalWidth
)

this.doneLoading()
Expand Down