File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -70,20 +70,19 @@ const VirtualList = Vue.component('virtual-list', {
70
70
71
71
// in page mode we bind scroll event to document
72
72
if ( this . pageMode ) {
73
+ this . updatePageModeFront ( )
74
+
73
75
document . addEventListener ( 'scroll' , this . onScroll , {
74
76
passive : false
75
77
} )
76
-
77
- // taking root offsetTop or offsetLeft as slot header size
78
- const { root } = this . $refs
79
- if ( root ) {
80
- this . virtual . updateParam ( 'slotHeaderSize' , root [ this . isHorizontal ? 'offsetLeft' : 'offsetTop' ] )
81
- }
82
78
}
83
79
} ,
84
80
85
81
beforeDestroy ( ) {
86
82
this . virtual . destroy ( )
83
+ if ( this . pageMode ) {
84
+ document . removeEventListener ( 'scroll' , this . onScroll )
85
+ }
87
86
} ,
88
87
89
88
methods : {
@@ -170,6 +169,18 @@ const VirtualList = Vue.component('virtual-list', {
170
169
}
171
170
} ,
172
171
172
+ // when using page mode we need update slot header size manually
173
+ // taking root offset relative to the browser as slot header size
174
+ updatePageModeFront ( ) {
175
+ const { root } = this . $refs
176
+ if ( root ) {
177
+ const rect = root . getBoundingClientRect ( )
178
+ const { defaultView } = root . ownerDocument
179
+ const offsetFront = this . isHorizontal ? ( rect . left + defaultView . pageXOffset ) : ( rect . top + defaultView . pageYOffset )
180
+ this . virtual . updateParam ( 'slotHeaderSize' , offsetFront )
181
+ }
182
+ } ,
183
+
173
184
// reset all state back to initial
174
185
reset ( ) {
175
186
this . virtual . destroy ( )
You can’t perform that action at this time.
0 commit comments