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