@wyxos/vibe 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Masonry.vue +26 -30
package/package.json
CHANGED
package/src/Masonry.vue
CHANGED
|
@@ -18,23 +18,7 @@ const props = defineProps({
|
|
|
18
18
|
default: () => []
|
|
19
19
|
},
|
|
20
20
|
layout: {
|
|
21
|
-
type: Object
|
|
22
|
-
default: () => ({
|
|
23
|
-
sizes: {
|
|
24
|
-
base: 1, // mobile-first default
|
|
25
|
-
sm: 2, // ≥ 640px
|
|
26
|
-
md: 3, // ≥ 768px
|
|
27
|
-
lg: 4, // ≥ 1024px
|
|
28
|
-
xl: 5, // ≥ 1280px
|
|
29
|
-
'2xl': 6 // ≥ 1536px
|
|
30
|
-
},
|
|
31
|
-
gutterX: 10,
|
|
32
|
-
gutterY: 10,
|
|
33
|
-
header: 0,
|
|
34
|
-
footer: 0,
|
|
35
|
-
paddingLeft: 0,
|
|
36
|
-
paddingRight: 0
|
|
37
|
-
})
|
|
21
|
+
type: Object
|
|
38
22
|
},
|
|
39
23
|
paginationType: {
|
|
40
24
|
type: String,
|
|
@@ -43,6 +27,25 @@ const props = defineProps({
|
|
|
43
27
|
}
|
|
44
28
|
})
|
|
45
29
|
|
|
30
|
+
const defaultLayout = {
|
|
31
|
+
sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, '2xl': 6 },
|
|
32
|
+
gutterX: 10,
|
|
33
|
+
gutterY: 10,
|
|
34
|
+
header: 0,
|
|
35
|
+
footer: 0,
|
|
36
|
+
paddingLeft: 0,
|
|
37
|
+
paddingRight: 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const layout = computed(() => ({
|
|
41
|
+
...defaultLayout,
|
|
42
|
+
...props.layout,
|
|
43
|
+
sizes: {
|
|
44
|
+
...defaultLayout.sizes,
|
|
45
|
+
...(props.layout?.sizes || {})
|
|
46
|
+
}
|
|
47
|
+
}))
|
|
48
|
+
|
|
46
49
|
const emits = defineEmits(['update:items'])
|
|
47
50
|
|
|
48
51
|
const masonry = computed({
|
|
@@ -130,14 +133,7 @@ async function onScroll() {
|
|
|
130
133
|
function getColumnCount() {
|
|
131
134
|
const width = window.innerWidth
|
|
132
135
|
|
|
133
|
-
const sizes =
|
|
134
|
-
base: 1, // mobile-first default
|
|
135
|
-
sm: 2, // ≥ 640px
|
|
136
|
-
md: 3, // ≥ 768px
|
|
137
|
-
lg: 4, // ≥ 1024px
|
|
138
|
-
xl: 5, // ≥ 1280px
|
|
139
|
-
'2xl': 6 // ≥ 1536px
|
|
140
|
-
}
|
|
136
|
+
const sizes = layout.value.sizes
|
|
141
137
|
|
|
142
138
|
if (width >= 1536 && sizes['2xl']) return sizes['2xl']
|
|
143
139
|
if (width >= 1280 && sizes.xl) return sizes.xl
|
|
@@ -147,18 +143,18 @@ function getColumnCount() {
|
|
|
147
143
|
return sizes.base
|
|
148
144
|
}
|
|
149
145
|
|
|
150
|
-
function calculateHeight(
|
|
151
|
-
containerHeight.value =
|
|
146
|
+
function calculateHeight(content) {
|
|
147
|
+
containerHeight.value = content.reduce((acc, item) => {
|
|
152
148
|
return Math.max(acc, item.top + item.columnHeight)
|
|
153
149
|
}, 0)
|
|
154
150
|
}
|
|
155
151
|
|
|
156
152
|
function refreshLayout(items) {
|
|
157
|
-
const
|
|
153
|
+
const content = calculateLayout(items, container.value, columns.value, layout.value);
|
|
158
154
|
|
|
159
|
-
calculateHeight(
|
|
155
|
+
calculateHeight(content)
|
|
160
156
|
|
|
161
|
-
masonry.value =
|
|
157
|
+
masonry.value = content
|
|
162
158
|
}
|
|
163
159
|
|
|
164
160
|
async function getContent(page) {
|