@wyxos/vibe 1.2.12 → 1.2.14
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 +37 -12
package/package.json
CHANGED
package/src/Masonry.vue
CHANGED
|
@@ -28,6 +28,10 @@ const props = defineProps({
|
|
|
28
28
|
skipInitialLoad: {
|
|
29
29
|
type: Boolean,
|
|
30
30
|
default: false
|
|
31
|
+
},
|
|
32
|
+
maxItems: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: 100
|
|
31
35
|
}
|
|
32
36
|
})
|
|
33
37
|
|
|
@@ -98,15 +102,32 @@ async function onScroll() {
|
|
|
98
102
|
if ((whitespaceVisible || reachedContainerBottom) && !isLoading.value) {
|
|
99
103
|
isLoading.value = true
|
|
100
104
|
|
|
101
|
-
if (
|
|
102
|
-
// get first item
|
|
105
|
+
if (masonry.value.length > props.maxItems) {
|
|
106
|
+
// get first item - only proceed if it exists
|
|
103
107
|
const firstItem = masonry.value[0]
|
|
108
|
+
|
|
109
|
+
if (!firstItem) {
|
|
110
|
+
// Skip removal logic if there are no items
|
|
111
|
+
await loadNext()
|
|
112
|
+
await nextTick()
|
|
113
|
+
isLoading.value = false
|
|
114
|
+
return
|
|
115
|
+
}
|
|
104
116
|
|
|
105
117
|
// get page number
|
|
106
118
|
const page = firstItem.page
|
|
107
119
|
|
|
108
120
|
// find all item with this page
|
|
109
121
|
const removedItems = masonry.value.filter(i => i.page !== page)
|
|
122
|
+
|
|
123
|
+
// Only proceed with removal if there are actually items to remove
|
|
124
|
+
if (removedItems.length === masonry.value.length) {
|
|
125
|
+
// All items belong to the same page, skip removal logic
|
|
126
|
+
await loadNext()
|
|
127
|
+
await nextTick()
|
|
128
|
+
isLoading.value = false
|
|
129
|
+
return
|
|
130
|
+
}
|
|
110
131
|
|
|
111
132
|
refreshLayout(removedItems)
|
|
112
133
|
|
|
@@ -116,16 +137,20 @@ async function onScroll() {
|
|
|
116
137
|
|
|
117
138
|
// find the last item in that column
|
|
118
139
|
const lastItemInColumn = masonry.value.filter((_, index) => index % columns.value === lowestColumnIndex).pop()
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
container.value.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
|
|
141
|
+
// Only proceed with scroll adjustment if we have a valid item
|
|
142
|
+
if (lastItemInColumn) {
|
|
143
|
+
const lastItemInColumnTop = lastItemInColumn.top + lastItemInColumn.columnHeight
|
|
144
|
+
const lastItemInColumnBottom = lastItemInColumnTop + lastItemInColumn.columnHeight
|
|
145
|
+
const containerTop = container.value.scrollTop
|
|
146
|
+
const containerBottom = containerTop + container.value.clientHeight
|
|
147
|
+
const itemInView = lastItemInColumnTop >= containerTop && lastItemInColumnBottom <= containerBottom
|
|
148
|
+
if (!itemInView) {
|
|
149
|
+
container.value.scrollTo({
|
|
150
|
+
top: lastItemInColumnTop - 10,
|
|
151
|
+
behavior: 'smooth'
|
|
152
|
+
})
|
|
153
|
+
}
|
|
129
154
|
}
|
|
130
155
|
}
|
|
131
156
|
|