Skip to content

Commit 2a01a8f

Browse files
committed
RecycleList: fix an issue when changing the items array + misc
1 parent 9caa0f5 commit 2a01a8f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/components/RecycleList.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
>
88
<div
99
class="item-wrapper"
10-
:style="'height:' + totalHeight + 'px'"
10+
:style="{ height: totalHeight + 'px' }"
1111
>
1212
<div
1313
v-for="view of pool"
1414
:key="view.nr.id"
1515
class="item-view"
16-
:style="'transform:translateY(' + view.top + 'px)'"
16+
:style="{ transform: 'translateY(' + view.top + 'px)' }"
1717
>
1818
<slot
1919
:item="view.item"
@@ -238,8 +238,8 @@ export default {
238238
239239
if (this.$_continuous !== continuous) {
240240
if (continuous) {
241-
this.$_views.clear()
242-
this.$_unusedViews.clear()
241+
views.clear()
242+
unusedViews.clear()
243243
for (let i = 0, l = pool.length; i < l; i++) {
244244
view = pool[i]
245245
this.unuseView(view)
@@ -249,12 +249,18 @@ export default {
249249
} else if (continuous) {
250250
for (let i = 0, l = pool.length; i < l; i++) {
251251
view = pool[i]
252-
if (view.nr.used && (
253-
view.nr.index < startIndex ||
254-
view.nr.index > endIndex ||
255-
(checkItem && !items.includes(view.item))
256-
)) {
257-
this.unuseView(view)
252+
if (view.nr.used) {
253+
// Update view item index
254+
if (checkItem) view.nr.index = items.indexOf(view.item)
255+
256+
// Check if index is still in visible range
257+
if (
258+
view.nr.index === -1 ||
259+
view.nr.index < startIndex ||
260+
view.nr.index > endIndex
261+
) {
262+
this.unuseView(view)
263+
}
258264
}
259265
}
260266
}

0 commit comments

Comments
 (0)