@@ -50,7 +50,7 @@ const VirtualList = Vue.component(NAME, {
5050 } , this . onRangeChanged )
5151
5252 // just for debug
53- // window.virtual = this.virtual
53+ window . virtual = this . virtual
5454
5555 // also need sync initial range first.
5656 this . range = this . virtual . getRange ( )
@@ -108,8 +108,16 @@ const VirtualList = Vue.component(NAME, {
108108 }
109109
110110 const offset = root [ this . directionKey ]
111+ const offsetShape = root [ this . isHorizontal ? 'clientWidth' : 'clientHeight' ]
112+ const scrollShape = root [ this . isHorizontal ? 'scrollWidth' : 'scrollHeight' ]
113+
114+ // iOS scrolling spring-back behavior will make direction mistake.
115+ if ( offset + offsetShape > scrollShape ) {
116+ return
117+ }
118+
111119 this . virtual . handleScroll ( offset )
112- this . emitEvent ( offset , evt )
120+ this . emitEvent ( offset , offsetShape , scrollShape , evt )
113121 } ,
114122
115123 getUniqueIdFromDataSources ( ) {
@@ -125,18 +133,14 @@ const VirtualList = Vue.component(NAME, {
125133 } ,
126134
127135 // emit event in special position.
128- emitEvent ( offset , evt ) {
129- // ref element is definitely available here.
130- const { root } = this . $refs
136+ emitEvent ( offset , offsetShape , scrollShape , evt ) {
131137 const range = this . virtual . getRange ( )
132138 const isFront = this . virtual . isFront ( )
133139 const isBehind = this . virtual . isBehind ( )
134- const offsetShape = root [ this . isHorizontal ? 'clientWidth' : 'clientHeight' ]
135- const scrollShape = root [ this . isHorizontal ? 'scrollWidth' : 'scrollHeight' ]
136140
137- if ( isFront && ! ! this . dataSources . length && offset - this . upperThreshold <= 0 ) {
141+ if ( isFront && ! ! this . dataSources . length && offset - this . topThreshold <= 0 ) {
138142 this . $emit ( 'totop' , evt , range )
139- } else if ( isBehind && offset + offsetShape + this . lowerThreshold >= scrollShape ) {
143+ } else if ( isBehind && offset + offsetShape + this . bottomThreshold >= scrollShape ) {
140144 this . $emit ( 'tobottom' , evt , range )
141145 } else {
142146 this . $emit ( 'scroll' , evt , range )
0 commit comments