File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed
Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 33 <VirtualList
44 :itemHeight =" 30"
55 :remainItems =" 10"
6- v-on:toBottom =" onBottom"
6+ :onScroll =" onListScroll"
7+ v-on:end =" onEnd"
78 >
89 <Item v-for =" item in items" :item =" item" :key =" $index" />
910 </VirtualList >
2829
2930 data () {
3031 return {
31- items: fetchData (100 )
32+ items: fetchData (20000 )
3233 }
3334 },
3435
3536 methods: {
36- onBottom () {
37+ onEnd () {
3738 // let list = fetchData(20);
3839 // if (list.length) {
3940 // this.items = this.items.concat(list);
4041 // }
42+ },
43+
44+ onListScroll (offset , e ) {
45+ console .log (offset, e)
4146 }
4247 }
4348 }
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
1010 remainItems : {
1111 type : Number ,
1212 required : true
13- }
13+ } ,
14+ onScroll : Function
1415 } ,
1516
1617 // an object helping to calculate
@@ -25,8 +26,14 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
2526 } ,
2627
2728 methods : {
28- onScroll ( ) {
29- this . updateZone ( this . $refs . container . scrollTop ) ;
29+ handleScroll ( e ) {
30+ let scrollTop = this . $refs . container . scrollTop ;
31+
32+ this . updateZone ( scrollTop ) ;
33+
34+ if ( this . onScroll ) {
35+ this . onScroll ( e , scrollTop ) ;
36+ }
3037 } ,
3138
3239 updateZone ( offset ) {
@@ -41,6 +48,7 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
4148 if ( overs + this . remainItems >= delta . total ) {
4249 end = delta . total ;
4350 start = delta . total - delta . keeps ;
51+ this . $emit ( 'end' ) ;
4452 }
4553
4654 delta . end = end ;
@@ -85,7 +93,7 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
8593 'height' : viewHeight + 'px'
8694 } ,
8795 'on' : {
88- 'scroll' : this . onScroll
96+ 'scroll' : this . handleScroll
8997 }
9098 } , [
9199 createElement ( 'div' , {
You can’t perform that action at this time.
0 commit comments