@@ -34,7 +34,8 @@ export default {
34
34
} ,
35
35
total : {
36
36
type : Number ,
37
- required : true
37
+ required : true ,
38
+ default : 0
38
39
} ,
39
40
item : {
40
41
type : Object ,
@@ -213,25 +214,37 @@ export default {
213
214
}
214
215
if ( this . isSameHeight ) {
215
216
const height = this . height
216
- const end = items ? items . length : total - offset
217
- for ( let i = 0 ; i < end ; i ++ ) {
218
- const top = height * Math . floor ( ( i + offset ) / column )
219
- cache [ i + offset ] = {
220
- height,
221
- top,
222
- bottom : height + top
217
+ const end = items ? items . length + offset : total
218
+ if ( this . isSingleColumn ) {
219
+ for ( let i = offset ; i < end ; i ++ ) {
220
+ const top = height * Math . floor ( i / column )
221
+ cache [ i ] = {
222
+ top,
223
+ height,
224
+ bottom : height + top
225
+ }
223
226
}
227
+ this . flowHeight = height * Math . ceil ( total / column )
228
+ } else {
229
+ for ( let i = offset ; i < end ; i ++ ) {
230
+ const top = height * i
231
+ cache [ i ] = {
232
+ top,
233
+ height,
234
+ bottom : height + top
235
+ }
236
+ }
237
+ this . flowHeight = height * total
224
238
}
225
- this . flowHeight = height * total / column
226
239
} else {
227
240
if ( this . isSingleColumn ) {
228
241
let beforeHeight = offset ? cache [ offset - 1 ] . bottom : 0
229
242
items . forEach ( ( item , index ) => {
230
243
const hgt = parseInt ( item . data . style . height , 10 )
231
244
cache [ index + offset ] = {
232
- height : hgt ,
233
245
top : beforeHeight ,
234
- bottom : hgt + beforeHeight
246
+ bottom : hgt + beforeHeight ,
247
+ height : hgt
235
248
}
236
249
beforeHeight += hgt
237
250
} )
@@ -247,13 +260,12 @@ export default {
247
260
offsets = new Array ( column ) . fill ( 0 )
248
261
}
249
262
items . forEach ( ( item , index ) => {
250
- const realIndex = index + offset
251
263
const beforeHeight = Math . min ( ...offsets )
252
264
const hgt = parseInt ( item . data . style . height , 10 )
253
- cache [ realIndex ] = {
254
- height : hgt ,
265
+ cache [ index + offset ] = {
255
266
top : beforeHeight ,
256
- bottom : hgt + beforeHeight
267
+ bottom : hgt + beforeHeight ,
268
+ height : hgt
257
269
}
258
270
offsets [ offsets . indexOf ( beforeHeight ) ] += hgt
259
271
} )
0 commit comments