Skip to content

Commit

Permalink
Merge pull request #80 from MattApril/0_height_fix
Browse files Browse the repository at this point in the history
0 height bug: temporary patch
  • Loading branch information
alessiomaffeis authored May 3, 2022
2 parents 2ec5a01 + b623749 commit df6d10c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions PictureInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ export default {
this.canvasWidth = this.width
this.canvasHeight = this.height
if( this.width != Number.MAX_SAFE_INTEGER && this.height != Number.MAX_SAFE_INTEGER ) {
this.previewWidth = this.width
this.previewHeight = this.height
}
this.$on('error', this.onError)
},
Expand Down Expand Up @@ -232,9 +236,7 @@ export default {
this.$emit('click')
},
onResize () {
this.resizeCanvas()
if (this.imageObject) {
if (this.resizeCanvas() && this.imageObject) {
this.drawImage(this.imageObject)
}
},
Expand Down Expand Up @@ -416,12 +418,14 @@ export default {
resizeCanvas () {
let previewRatio = this.canvasWidth / this.canvasHeight
let newWidth = this.$refs.container.clientWidth
if( !newWidth ) return false;
if (!this.toggleAspectRatio && newWidth === this.containerWidth) {
return
return false;
}
this.containerWidth = newWidth
this.previewWidth = Math.min(this.containerWidth - this.margin * 2, this.canvasWidth)
this.previewHeight = this.previewWidth / previewRatio
return true;
},
getOrientation (width, height) {
let orientation = 'square'
Expand Down

0 comments on commit df6d10c

Please sign in to comment.