diff options
| author | Roger Braun <roger@rogerbraun.net> | 2017-03-09 10:33:21 +0100 |
|---|---|---|
| committer | Roger Braun <roger@rogerbraun.net> | 2017-03-09 10:33:21 +0100 |
| commit | 0eeccb87cef4d137710e3c7fd215b94e45aff3d1 (patch) | |
| tree | 584085071af589e58f79ffb67051c49b6bd883bb /src/components/attachment/attachment.js | |
| parent | 290180a987ecb4949fc877c512f3cff120bcbc70 (diff) | |
| parent | 64d71b75cfed41d82a99e3e478fc75d5f81f84bd (diff) | |
Merge branch 'develop' into feature/hash-routed
Diffstat (limited to 'src/components/attachment/attachment.js')
| -rw-r--r-- | src/components/attachment/attachment.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index f4f6aebf..7715add5 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -11,7 +11,9 @@ const Attachment = { return { nsfwImage, hideNsfwLocal: this.$store.state.config.hideNsfw, - showHidden: false + showHidden: false, + loading: false, + img: document.createElement('img') } }, computed: { @@ -20,6 +22,13 @@ const Attachment = { }, hidden () { return this.nsfw && this.hideNsfwLocal && !this.showHidden + }, + autoHeight () { + if (this.type === 'image' && this.nsfw) { + return { + 'min-height': '311px' + } + } } }, methods: { @@ -29,7 +38,16 @@ const Attachment = { } }, toggleHidden () { - this.showHidden = !this.showHidden + if (this.img.onload) { + this.img.onload() + } else { + this.loading = true + this.img.src = this.attachment.url + this.img.onload = () => { + this.loading = false + this.showHidden = !this.showHidden + } + } } } } |
