diff options
| author | taehoon <th.dev91@gmail.com> | 2019-10-21 15:13:11 -0400 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-10-22 07:17:02 -0400 |
| commit | ad0452220619960f4f19c4557691d2f8f3438df9 (patch) | |
| tree | 25746fd13138660a8f4e3d38741bc6046e8f3b8f /src/components/gallery/gallery.js | |
| parent | 0396c6f29d29f3c9d743e00955a25e2d844b02da (diff) | |
update flex-grow calculation logic
Diffstat (limited to 'src/components/gallery/gallery.js')
| -rw-r--r-- | src/components/gallery/gallery.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/components/gallery/gallery.js b/src/components/gallery/gallery.js index e8cbb526..4037da98 100644 --- a/src/components/gallery/gallery.js +++ b/src/components/gallery/gallery.js @@ -1,5 +1,5 @@ import Attachment from '../attachment/attachment.vue' -import { chunk, last, dropRight } from 'lodash' +import { chunk, last, dropRight, sumBy } from 'lodash' const Gallery = { props: [ @@ -39,13 +39,13 @@ const Gallery = { rowStyle (itemsPerRow) { return { 'padding-bottom': `${(100 / (itemsPerRow + 0.6))}%` } }, - itemStyle (id) { + itemStyle (id, row) { + const total = sumBy(row, item => this.getAspectRatio(item.id)) + return { flexGrow: this.getAspectRatio(id) / total } + }, + getAspectRatio (id) { const size = this.sizes[id] - if (size) { - return { flex: size.width / size.height } - } else { - return {} - } + return size ? size.width / size.height : 1 } } } |
