aboutsummaryrefslogtreecommitdiff
path: root/src/site/components/grid/waterfall/WaterfallItem.vue
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-04 23:18:51 +0300
committerZephyrrus <[email protected]>2020-07-04 23:18:51 +0300
commit1e1f3fbb27976a34f53a4e8d250da34dad4e6c20 (patch)
tree4c2df144de7db279b752417e60dddecbb4bfc328 /src/site/components/grid/waterfall/WaterfallItem.vue
parentfix: fix axios plugin throwing if no message from backend (diff)
downloadhost.fuwn.me-1e1f3fbb27976a34f53a4e8d250da34dad4e6c20.tar.xz
host.fuwn.me-1e1f3fbb27976a34f53a4e8d250da34dad4e6c20.zip
feat: experimental videos in grid
Diffstat (limited to 'src/site/components/grid/waterfall/WaterfallItem.vue')
-rw-r--r--src/site/components/grid/waterfall/WaterfallItem.vue37
1 files changed, 29 insertions, 8 deletions
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() {