@@ -34,7 +34,8 @@ export default {
3434 } ,
3535 total : {
3636 type : Number ,
37- required : true
37+ required : true ,
38+ default : 0
3839 } ,
3940 item : {
4041 type : Object ,
@@ -213,25 +214,37 @@ export default {
213214 }
214215 if ( this . isSameHeight ) {
215216 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+ }
223226 }
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
224238 }
225- this . flowHeight = height * total / column
226239 } else {
227240 if ( this . isSingleColumn ) {
228241 let beforeHeight = offset ? cache [ offset - 1 ] . bottom : 0
229242 items . forEach ( ( item , index ) => {
230243 const hgt = parseInt ( item . data . style . height , 10 )
231244 cache [ index + offset ] = {
232- height : hgt ,
233245 top : beforeHeight ,
234- bottom : hgt + beforeHeight
246+ bottom : hgt + beforeHeight ,
247+ height : hgt
235248 }
236249 beforeHeight += hgt
237250 } )
@@ -247,13 +260,12 @@ export default {
247260 offsets = new Array ( column ) . fill ( 0 )
248261 }
249262 items . forEach ( ( item , index ) => {
250- const realIndex = index + offset
251263 const beforeHeight = Math . min ( ...offsets )
252264 const hgt = parseInt ( item . data . style . height , 10 )
253- cache [ realIndex ] = {
254- height : hgt ,
265+ cache [ index + offset ] = {
255266 top : beforeHeight ,
256- bottom : hgt + beforeHeight
267+ bottom : hgt + beforeHeight ,
268+ height : hgt
257269 }
258270 offsets [ offsets . indexOf ( beforeHeight ) ] += hgt
259271 } )
0 commit comments