@@ -51,10 +51,8 @@ export default {
5151 offsetTop : 0 ,
5252 lastScrollTop : 0 ,
5353 start : 0 ,
54- style : {
55- height : 0 ,
56- paddingTop : 0
57- } ,
54+ flowHeight : 0 ,
55+ paddingTop : 0 ,
5856 cache : { }
5957 }
6058 } ,
@@ -115,7 +113,7 @@ export default {
115113 */
116114 if ( scrollTop <= 0 ) {
117115 this . start = 0
118- this . style . paddingTop = 0
116+ this . paddingTop = 0
119117 return
120118 }
121119 /**
@@ -126,7 +124,7 @@ export default {
126124 * 触顶,数值修正
127125 */
128126 if ( this . start <= 0 ) {
129- this . style . paddingTop = 0
127+ this . paddingTop = 0
130128 this . start = 0
131129 return
132130 }
@@ -138,7 +136,7 @@ export default {
138136 cache [ start + remain - 1 ] . top > scrollTop + this . wrapHeight ||
139137 cache [ start ] . top > scrollTop
140138 ) {
141- this . style . paddingTop -= cache [ start - 1 ] . height
139+ this . paddingTop -= cache [ start - 1 ] . height
142140 this . start --
143141 }
144142 } else {
@@ -147,7 +145,7 @@ export default {
147145 */
148146 if ( start + remain >= total ) {
149147 this . start = total - remain
150- this . style . paddingTop = cache [ total - remain ] . top
148+ this . paddingTop = cache [ total - remain ] . top
151149 return
152150 }
153151 /**
@@ -158,16 +156,14 @@ export default {
158156 cache [ start ] . bottom < scrollTop ||
159157 cache [ start + remain - 1 ] . bottom < scrollTop + this . wrapHeight
160158 ) {
161- this . style . paddingTop += cache [ start ] . height
159+ this . paddingTop += cache [ start ] . height
162160 this . start ++
163161 }
164162 }
165163 } ,
166164 clear ( ) {
167- this . style = {
168- height : 0 ,
169- paddingTop : 0
170- }
165+ this . flowHeight = 0
166+ this . paddingTop = 0
171167 this . start = 0
172168 this . cache = { }
173169 } ,
@@ -184,7 +180,7 @@ export default {
184180 */
185181 const scrollTop = this . lastScrollTop - this . offsetTop
186182 if ( scrollTop <= 0 ) {
187- this . style . paddingTop = 0
183+ this . paddingTop = 0
188184 this . start = 0
189185 return
190186 }
@@ -194,7 +190,7 @@ export default {
194190 const scrollBottom = scrollTop + this . wrapHeight
195191 if ( scrollBottom >= cache [ total - 1 ] . bottom ) {
196192 this . start = total - remain
197- this . style . paddingTop = cache [ total - remain ] . top
193+ this . paddingTop = cache [ total - remain ] . top
198194 return
199195 }
200196
@@ -217,7 +213,7 @@ export default {
217213 */
218214 const decreaseCount = Math . abs ( Math . ceil ( deltaHeight / height / column ) )
219215 this . start -= decreaseCount
220- this . style . paddingTop -= decreaseCount * height
216+ this . paddingTop -= decreaseCount * height
221217 } else {
222218 /**
223219 * 如果元素不等高
@@ -226,9 +222,8 @@ export default {
226222 */
227223 for ( let i = start - 1 ; i >= 0 ; i -- ) {
228224 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
232227 break
233228 }
234229 }
@@ -252,7 +247,7 @@ export default {
252247 */
253248 const increaseCount = Math . abs ( Math . floor ( deltaHeight / height / column ) )
254249 this . start += increaseCount
255- this . style . paddingTop += increaseCount * height
250+ this . paddingTop += increaseCount * height
256251 } else {
257252 /**
258253 * 如果元素不等高
@@ -261,9 +256,8 @@ export default {
261256 */
262257 for ( let i = start + remain ; i < total ; i ++ ) {
263258 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
267261 break
268262 }
269263 }
@@ -292,7 +286,7 @@ export default {
292286 bottom : height + top
293287 }
294288 }
295- this . style . height = height * total / column
289+ this . flowHeight = height * total / column
296290 } else {
297291 if ( this . isSingleColumn ) {
298292 let beforeHeight = offset ? cache [ offset - 1 ] . bottom : 0
@@ -305,7 +299,7 @@ export default {
305299 }
306300 beforeHeight += hgt
307301 } )
308- this . style . height = beforeHeight
302+ this . flowHeight = beforeHeight
309303 } else {
310304 let offsets
311305 if ( offset ) {
@@ -327,7 +321,7 @@ export default {
327321 }
328322 offsets [ offsets . indexOf ( beforeHeight ) ] += hgt
329323 } )
330- this . style . height = Math . max ( ...offsets )
324+ this . flowHeight = Math . max ( ...offsets )
331325 }
332326 }
333327 } ,
@@ -354,8 +348,8 @@ export default {
354348 'style' : {
355349 boxSizing : 'border-box' ,
356350 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`
359353 } ,
360354 'class' : 'vue-flow-render'
361355 } , this . _filter ( h ) )
0 commit comments