Skip to content

Commit 2a7bfd4

Browse files
davidaricoAkryum
andauthored
feat: Emit events for scroll to begin and end of list (#364)
Co-authored-by: Guillaume Chau <[email protected]>
1 parent 6b623b5 commit 2a7bfd4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ When the user scrolls inside RecycleScroller, the views are mostly just moved ar
205205
- `visible`: emitted when the scroller considers itself to be visible in the page.
206206
- `hidden`: emitted when the scroller is hidden in the page.
207207
- `update (startIndex, endIndex, visibleStartIndex, visibleEndIndex)`: emitted each time the views are updated, only if `emitUpdate` prop is `true`
208+
- `scroll-start`: emitted when the first item is rendered.
209+
- `scroll-end`: emitted when the last item is rendered.
208210

209211
### Default scoped slot props
210212

Diff for: docs-src/src/components/RecycleScrollerDemo.vue

+10
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
@update="onUpdate"
8585
@visible="onVisible"
8686
@hidden="onHidden"
87+
@scroll-start="onScrollStart"
88+
@scroll-end="onScrollEnd"
8789
>
8890
<template v-slot="props">
8991
<div
@@ -206,6 +208,14 @@ export default {
206208
onHidden () {
207209
console.log('hidden')
208210
},
211+
212+
onScrollStart () {
213+
console.log('scroll start')
214+
},
215+
216+
onScrollEnd () {
217+
console.log('scroll end')
218+
},
209219
},
210220
}
211221
</script>

Diff for: src/components/RecycleScroller.vue

+3
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,9 @@ export default {
499499
500500
// No view assigned to item
501501
if (!view) {
502+
if (i === items.length - 1) this.$emit('scroll-end')
503+
if (i === 0) this.$emit('scroll-start')
504+
502505
type = item[typeField]
503506
unusedPool = unusedViews.get(type)
504507

0 commit comments

Comments
 (0)