Skip to content

Commit

Permalink
🐛 Handle image loading race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
BetaHuhn committed Jan 6, 2022
1 parent c5a318d commit 68ab7ce
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client/components/ImageDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export default {
this.$emit('fail')
},
onLoad() {
// Prevent edge case where img and wrapper don't exist yet
if (!this.$refs.img || !this.$refs.wrapper) return
// Set/limit the elements height to the default height after load
const imageHeight = this.$refs.img.offsetHeight
if (imageHeight < this.defaultHeight) {
Expand Down

0 comments on commit 68ab7ce

Please sign in to comment.