diff options
| author | Zephyrrus <[email protected]> | 2020-07-04 23:18:51 +0300 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2020-07-04 23:18:51 +0300 |
| commit | 1e1f3fbb27976a34f53a4e8d250da34dad4e6c20 (patch) | |
| tree | 4c2df144de7db279b752417e60dddecbb4bfc328 /src/site/components/grid/waterfall | |
| parent | fix: fix axios plugin throwing if no message from backend (diff) | |
| download | host.fuwn.me-1e1f3fbb27976a34f53a4e8d250da34dad4e6c20.tar.xz host.fuwn.me-1e1f3fbb27976a34f53a4e8d250da34dad4e6c20.zip | |
feat: experimental videos in grid
Diffstat (limited to 'src/site/components/grid/waterfall')
| -rw-r--r-- | src/site/components/grid/waterfall/Waterfall.vue | 2 | ||||
| -rw-r--r-- | src/site/components/grid/waterfall/WaterfallItem.vue | 37 |
2 files changed, 30 insertions, 9 deletions
diff --git a/src/site/components/grid/waterfall/Waterfall.vue b/src/site/components/grid/waterfall/Waterfall.vue index 8631ea5..af1bd72 100644 --- a/src/site/components/grid/waterfall/Waterfall.vue +++ b/src/site/components/grid/waterfall/Waterfall.vue @@ -170,7 +170,7 @@ export default { return; } child.el.style.top = `${offsetArr[position]}px`; - offsetArr[position] += (child.height + this.gutterHeight); + offsetArr[position] += child.height + this.gutterHeight; this.$el.style.height = `${Math.max.apply(Math, offsetArr)}px`; }); this.$emit('rendered', this); diff --git a/src/site/components/grid/waterfall/WaterfallItem.vue b/src/site/components/grid/waterfall/WaterfallItem.vue index a02ea1f..7c4d814 100644 --- a/src/site/components/grid/waterfall/WaterfallItem.vue +++ b/src/site/components/grid/waterfall/WaterfallItem.vue @@ -1,13 +1,15 @@ -<style> +<style scoped> .waterfall-item { position: absolute; } </style> + <template> <div class="waterfall-item"> <slot /> </div> </template> + <script> import imagesLoaded from 'imagesloaded'; export default { @@ -20,6 +22,10 @@ export default { width: { type: Number, default: 150 + }, + video: { + type: Boolean, + default: false } }, data() { @@ -35,13 +41,28 @@ export default { this.$el.style.display = 'none'; this.$el.style.width = `${this.width}px`; this.emit(); - imagesLoaded(this.$el, () => { - this.$el.style.left = '-9999px'; - this.$el.style.top = '-9999px'; - this.$el.style.display = 'block'; - this.height = this.$el.offsetHeight; - this.itemWidth = this.$el.offsetWidth; - }); + if (this.video) { + const videoEl = this.$slots.default.find(e => e.tag?.toLowerCase() === 'video'); + const el = videoEl.elm; + console.log(videoEl); + console.log(el); + el.onloadeddata = () => { + console.log('loaded'); + this.$el.style.left = '-9999px'; + this.$el.style.top = '-9999px'; + this.$el.style.display = 'block'; + this.height = el.offsetHeight + 5; + this.itemWidth = el.offsetWidth; + } + } else { + imagesLoaded(this.$el, () => { + this.$el.style.left = '-9999px'; + this.$el.style.top = '-9999px'; + this.$el.style.display = 'block'; + this.height = this.$el.offsetHeight; + this.itemWidth = this.$el.offsetWidth; + }); + } }, methods: { emit() { |