diff options
| author | taehoon <th.dev91@gmail.com> | 2019-10-18 15:27:51 -0400 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-10-22 07:17:01 -0400 |
| commit | 6c4d23714a42dd59843a8fb905150eed2d5db29d (patch) | |
| tree | f6e34692090ab8d5506660daed24fddffa1fd78c /src/components/gallery/gallery.js | |
| parent | cd956185207aca84666d38f516b6c4b666ee846b (diff) | |
populate gallery row height without getting width
Diffstat (limited to 'src/components/gallery/gallery.js')
| -rw-r--r-- | src/components/gallery/gallery.js | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/components/gallery/gallery.js b/src/components/gallery/gallery.js index 7f33a81b..3610f53d 100644 --- a/src/components/gallery/gallery.js +++ b/src/components/gallery/gallery.js @@ -2,22 +2,12 @@ import Attachment from '../attachment/attachment.vue' import { chunk, last, dropRight } from 'lodash' const Gallery = { - data: () => ({ - width: 500 - }), props: [ 'attachments', 'nsfw', 'setMedia' ], components: { Attachment }, - mounted () { - this.resize() - window.addEventListener('resize', this.resize) - }, - destroyed () { - window.removeEventListener('resize', this.resize) - }, computed: { rows () { if (!this.attachments) { @@ -33,22 +23,12 @@ const Gallery = { } return rows }, - rowHeight () { - return itemsPerRow => ({ 'height': `${(this.width / (itemsPerRow + 0.6))}px` }) + rowStyle () { + return itemsPerRow => ({ 'padding-bottom': `${(100 / (itemsPerRow + 0.6))}%` }) }, useContainFit () { return this.$store.state.config.useContainFit } - }, - methods: { - resize () { - // Quick optimization to make resizing not always trigger state change, - // only update attachment size in 10px steps - const width = Math.floor(this.$el.getBoundingClientRect().width / 10) * 10 - if (this.width !== width) { - this.width = width - } - } } } |
