Skip to content

Commit df6d10c

Browse files
Merge pull request alessiomaffeis#80 from MattApril/0_height_fix
0 height bug: temporary patch
2 parents 2ec5a01 + b623749 commit df6d10c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

PictureInput.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ export default {
204204
205205
this.canvasWidth = this.width
206206
this.canvasHeight = this.height
207+
if( this.width != Number.MAX_SAFE_INTEGER && this.height != Number.MAX_SAFE_INTEGER ) {
208+
this.previewWidth = this.width
209+
this.previewHeight = this.height
210+
}
207211
208212
this.$on('error', this.onError)
209213
},
@@ -232,9 +236,7 @@ export default {
232236
this.$emit('click')
233237
},
234238
onResize () {
235-
this.resizeCanvas()
236-
237-
if (this.imageObject) {
239+
if (this.resizeCanvas() && this.imageObject) {
238240
this.drawImage(this.imageObject)
239241
}
240242
},
@@ -416,12 +418,14 @@ export default {
416418
resizeCanvas () {
417419
let previewRatio = this.canvasWidth / this.canvasHeight
418420
let newWidth = this.$refs.container.clientWidth
421+
if( !newWidth ) return false;
419422
if (!this.toggleAspectRatio && newWidth === this.containerWidth) {
420-
return
423+
return false;
421424
}
422425
this.containerWidth = newWidth
423426
this.previewWidth = Math.min(this.containerWidth - this.margin * 2, this.canvasWidth)
424427
this.previewHeight = this.previewWidth / previewRatio
428+
return true;
425429
},
426430
getOrientation (width, height) {
427431
let orientation = 'square'

0 commit comments

Comments
 (0)