@@ -51,10 +51,8 @@ export default {
51
51
offsetTop : 0 ,
52
52
lastScrollTop : 0 ,
53
53
start : 0 ,
54
- style : {
55
- height : 0 ,
56
- paddingTop : 0
57
- } ,
54
+ flowHeight : 0 ,
55
+ paddingTop : 0 ,
58
56
cache : { }
59
57
}
60
58
} ,
@@ -115,7 +113,7 @@ export default {
115
113
*/
116
114
if ( scrollTop <= 0 ) {
117
115
this . start = 0
118
- this . style . paddingTop = 0
116
+ this . paddingTop = 0
119
117
return
120
118
}
121
119
/**
@@ -126,7 +124,7 @@ export default {
126
124
* 触顶,数值修正
127
125
*/
128
126
if ( this . start <= 0 ) {
129
- this . style . paddingTop = 0
127
+ this . paddingTop = 0
130
128
this . start = 0
131
129
return
132
130
}
@@ -138,7 +136,7 @@ export default {
138
136
cache [ start + remain - 1 ] . top > scrollTop + this . wrapHeight ||
139
137
cache [ start ] . top > scrollTop
140
138
) {
141
- this . style . paddingTop -= cache [ start - 1 ] . height
139
+ this . paddingTop -= cache [ start - 1 ] . height
142
140
this . start --
143
141
}
144
142
} else {
@@ -147,7 +145,7 @@ export default {
147
145
*/
148
146
if ( start + remain >= total ) {
149
147
this . start = total - remain
150
- this . style . paddingTop = cache [ total - remain ] . top
148
+ this . paddingTop = cache [ total - remain ] . top
151
149
return
152
150
}
153
151
/**
@@ -158,16 +156,14 @@ export default {
158
156
cache [ start ] . bottom < scrollTop ||
159
157
cache [ start + remain - 1 ] . bottom < scrollTop + this . wrapHeight
160
158
) {
161
- this . style . paddingTop += cache [ start ] . height
159
+ this . paddingTop += cache [ start ] . height
162
160
this . start ++
163
161
}
164
162
}
165
163
} ,
166
164
clear ( ) {
167
- this . style = {
168
- height : 0 ,
169
- paddingTop : 0
170
- }
165
+ this . flowHeight = 0
166
+ this . paddingTop = 0
171
167
this . start = 0
172
168
this . cache = { }
173
169
} ,
@@ -184,7 +180,7 @@ export default {
184
180
*/
185
181
const scrollTop = this . lastScrollTop - this . offsetTop
186
182
if ( scrollTop <= 0 ) {
187
- this . style . paddingTop = 0
183
+ this . paddingTop = 0
188
184
this . start = 0
189
185
return
190
186
}
@@ -194,7 +190,7 @@ export default {
194
190
const scrollBottom = scrollTop + this . wrapHeight
195
191
if ( scrollBottom >= cache [ total - 1 ] . bottom ) {
196
192
this . start = total - remain
197
- this . style . paddingTop = cache [ total - remain ] . top
193
+ this . paddingTop = cache [ total - remain ] . top
198
194
return
199
195
}
200
196
@@ -217,7 +213,7 @@ export default {
217
213
*/
218
214
const decreaseCount = Math . abs ( Math . ceil ( deltaHeight / height / column ) )
219
215
this . start -= decreaseCount
220
- this . style . paddingTop -= decreaseCount * height
216
+ this . paddingTop -= decreaseCount * height
221
217
} else {
222
218
/**
223
219
* 如果元素不等高
@@ -226,9 +222,8 @@ export default {
226
222
*/
227
223
for ( let i = start - 1 ; i >= 0 ; i -- ) {
228
224
if ( cache [ i ] . top <= scrollTop ) {
229
- const index = Math . max ( i - ( remain / 2 | 0 ) , 0 )
230
- this . style . paddingTop = cache [ index ] . top
231
- this . start = index
225
+ this . paddingTop = cache [ i ] . top
226
+ this . start = i
232
227
break
233
228
}
234
229
}
@@ -252,7 +247,7 @@ export default {
252
247
*/
253
248
const increaseCount = Math . abs ( Math . floor ( deltaHeight / height / column ) )
254
249
this . start += increaseCount
255
- this . style . paddingTop += increaseCount * height
250
+ this . paddingTop += increaseCount * height
256
251
} else {
257
252
/**
258
253
* 如果元素不等高
@@ -261,9 +256,8 @@ export default {
261
256
*/
262
257
for ( let i = start + remain ; i < total ; i ++ ) {
263
258
if ( cache [ i ] . bottom >= scrollBottom ) {
264
- const index = Math . min ( i - ( remain / 2 | 0 ) , total - remain )
265
- this . style . paddingTop = cache [ index ] . top
266
- this . start = index
259
+ this . paddingTop = cache [ i - remain ] . top
260
+ this . start = i - remain
267
261
break
268
262
}
269
263
}
@@ -292,7 +286,7 @@ export default {
292
286
bottom : height + top
293
287
}
294
288
}
295
- this . style . height = height * total / column
289
+ this . flowHeight = height * total / column
296
290
} else {
297
291
if ( this . isSingleColumn ) {
298
292
let beforeHeight = offset ? cache [ offset - 1 ] . bottom : 0
@@ -305,7 +299,7 @@ export default {
305
299
}
306
300
beforeHeight += hgt
307
301
} )
308
- this . style . height = beforeHeight
302
+ this . flowHeight = beforeHeight
309
303
} else {
310
304
let offsets
311
305
if ( offset ) {
@@ -327,7 +321,7 @@ export default {
327
321
}
328
322
offsets [ offsets . indexOf ( beforeHeight ) ] += hgt
329
323
} )
330
- this . style . height = Math . max ( ...offsets )
324
+ this . flowHeight = Math . max ( ...offsets )
331
325
}
332
326
}
333
327
} ,
@@ -354,8 +348,8 @@ export default {
354
348
'style' : {
355
349
boxSizing : 'border-box' ,
356
350
willChange : 'padding-top' ,
357
- paddingTop : `${ this . style . paddingTop } px` ,
358
- height : `${ this . style . height } px`
351
+ paddingTop : `${ this . paddingTop } px` ,
352
+ height : `${ this . flowHeight } px`
359
353
} ,
360
354
'class' : 'vue-flow-render'
361
355
} , this . _filter ( h ) )
0 commit comments