aboutsummaryrefslogtreecommitdiff
path: root/src/site/components
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-07 02:02:59 +0300
committerZephyrrus <[email protected]>2020-07-07 02:02:59 +0300
commitfb0bc57542a44dcc94149f393d8a4ff0c2e7902b (patch)
treec80b075e1d53a1c381a9f40195a1fd72c7b69922 /src/site/components
parentchore: eslint stores (diff)
downloadhost.fuwn.me-fb0bc57542a44dcc94149f393d8a4ff0c2e7902b.tar.xz
host.fuwn.me-fb0bc57542a44dcc94149f393d8a4ff0c2e7902b.zip
feat: try fixing THE SHITTY WATERFALL
Diffstat (limited to 'src/site/components')
-rw-r--r--src/site/components/grid/Grid.vue28
-rw-r--r--src/site/components/grid/waterfall/Waterfall.vue47
-rw-r--r--src/site/components/grid/waterfall/WaterfallItem.vue12
-rw-r--r--src/site/components/imageInfo/ImageInfo.vue0
4 files changed, 54 insertions, 33 deletions
diff --git a/src/site/components/grid/Grid.vue b/src/site/components/grid/Grid.vue
index d4fe067..e6a8c64 100644
--- a/src/site/components/grid/Grid.vue
+++ b/src/site/components/grid/Grid.vue
@@ -24,12 +24,10 @@
<Waterfall
v-if="showWaterfall"
:gutterWidth="10"
- :gutterHeight="4">
- <WaterfallItem
- v-for="(item, index) in gridFiles"
- :key="item.id"
- :width="width"
- move-class="item-move">
+ :gutterHeight="4"
+ :itemWidth="width"
+ :items="gridFiles">
+ <template v-slot="{item}">
<template v-if="isPublic">
<a
:href="`${item.url}`"
@@ -81,7 +79,7 @@
</a>
</b-tooltip>
<b-tooltip label="Delete" position="is-top">
- <a class="btn" @click="deleteFile(item, index)">
+ <a class="btn" @click="deleteFile(item)">
<i class="icon-editorial-trash-a-l" />
</a>
</b-tooltip>
@@ -92,7 +90,7 @@
</b-tooltip>
</div>
</template>
- </WaterfallItem>
+ </template>
</Waterfall>
</template>
<div v-else>
@@ -185,12 +183,10 @@
import { mapState } from 'vuex';
import Waterfall from './waterfall/Waterfall.vue';
-import WaterfallItem from './waterfall/WaterfallItem.vue';
export default {
components: {
Waterfall,
- WaterfallItem,
},
props: {
files: {
@@ -253,13 +249,13 @@ export default {
const data = await this.$search.do(this.searchTerm, ['name', 'original', 'type', 'albums:name']);
console.log('> Search result data', data);
},
- deleteFile(file, index) {
- this.$buefy.dialog.confirm({
+ deleteFile(file) {
+ this.$emit('delete', file);
+ /* this.$buefy.dialog.confirm({
title: 'Deleting file',
message: 'Are you sure you want to <b>delete</b> this file?',
confirmText: 'Delete File',
type: 'is-danger',
- hasIcon: true,
onConfirm: async () => {
const response = await this.$axios.$delete(`file/${file.id}`);
if (this.showList) {
@@ -274,7 +270,7 @@ export default {
}
return this.$buefy.toast.open(response.message);
},
- });
+ }); */
},
isAlbumSelected(id) {
if (!this.showingModalForFile) return false;
@@ -311,10 +307,6 @@ export default {
const foundIndex = this.hoveredItems.indexOf(id);
if (foundIndex > -1) return;
this.hoveredItems.push(id);
- /// XXX: THIS IS NOT OK!
- this.$nextTick(() => {
- this.$refs.video.forEach((e) => e.play().catch(() => {}));
- });
},
mouseOut(id) {
console.log('out', id);
diff --git a/src/site/components/grid/waterfall/Waterfall.vue b/src/site/components/grid/waterfall/Waterfall.vue
index cccc3ac..a83a275 100644
--- a/src/site/components/grid/waterfall/Waterfall.vue
+++ b/src/site/components/grid/waterfall/Waterfall.vue
@@ -1,14 +1,14 @@
-<style>
- .waterfall {
- position: relative;
- }
-</style>
<template>
<div class="waterfall">
- <slot />
+ <WaterfallItem v-for="(item, index) in items" :key="item.id" :ref="`item-${item.id}`" :width="itemWidth">
+ <slot :item="item" />
+ </WaterfallItem>
</div>
</template>
+
<script>
+import WaterfallItem from './WaterfallItem.vue';
+
const quickSort = (arr, type) => {
const left = [];
const right = [];
@@ -49,6 +49,9 @@ const sum = (arr) => arr.reduce((acc, val) => acc + val, 0);
export default {
name: 'Waterfall',
+ components: {
+ WaterfallItem,
+ },
props: {
gutterWidth: {
type: Number,
@@ -82,6 +85,14 @@ export default {
type: Array,
default: null,
},
+ itemWidth: {
+ type: Number,
+ default: 150,
+ },
+ items: {
+ type: Array,
+ default: () => [],
+ },
},
data() {
return {
@@ -89,15 +100,21 @@ export default {
colNum: 0,
lastWidth: 0,
percentWidthArr: [],
+ readyChildCount: 0,
};
},
+ watch: {
+ items() {
+ this.$nextTick(() => this.render('watch'));
+ },
+ },
created() {
this.$on('itemRender', () => {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
- this.render();
+ this.render('created');
}, 0);
});
},
@@ -105,6 +122,10 @@ export default {
this.resizeHandle();
this.$watch('resizable', this.resizeHandle);
},
+ beforeDestroy() {
+ this.$off('itemRender');
+ _.off(window, 'resize', this.render);
+ },
methods: {
calulate(arr) {
const pageWidth = this.fixWidth ? this.fixWidth : this.$el.offsetWidth;
@@ -135,10 +156,12 @@ export default {
_.off(window, 'resize', this.render, false);
}
},
- render() {
+ render(context) {
+ console.log(context);
+ if (!this.items) return;
// 重新排序
let childArr = [];
- childArr = this.$children.map((child) => child.getMeta());
+ childArr = this.items.map(({ id }) => this.$refs[`item-${id}`][0].getMeta());
childArr = quickSort(childArr, 'order');
// 计算列数
this.calulate(childArr[0]);
@@ -180,3 +203,9 @@ export default {
},
};
</script>
+
+<style>
+ .waterfall {
+ position: relative;
+ }
+</style>
diff --git a/src/site/components/grid/waterfall/WaterfallItem.vue b/src/site/components/grid/waterfall/WaterfallItem.vue
index 2a5c69a..a49c58c 100644
--- a/src/site/components/grid/waterfall/WaterfallItem.vue
+++ b/src/site/components/grid/waterfall/WaterfallItem.vue
@@ -1,9 +1,3 @@
-<style scoped>
- .waterfall-item {
- position: absolute;
- }
-</style>
-
<template>
<div class="waterfall-item">
<slot />
@@ -80,3 +74,9 @@ export default {
},
};
</script>
+
+<style scoped>
+ .waterfall-item {
+ position: absolute;
+ }
+</style>
diff --git a/src/site/components/imageInfo/ImageInfo.vue b/src/site/components/imageInfo/ImageInfo.vue
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/site/components/imageInfo/ImageInfo.vue