@@ -244,26 +244,48 @@ const numFrameworksPerRow = computed(
244
244
() => numBlocksPerRow .value - paddedBlocksPerSide .value * 2 ,
245
245
)
246
246
247
- /**
248
- * The indexes of the blocks on each row that support framework cards.
249
- */
250
- const centerIndexes: ComputedRef <{ start: number ; end: number }> = computed (
251
- () => {
252
- const startIndex = paddedBlocksPerSide .value
253
- return {
254
- start: startIndex ,
255
- end: numBlocksPerRow .value - paddedBlocksPerSide .value ,
256
- }
257
- },
258
- )
259
-
260
247
/**
261
248
* How many rows do we need to display all the frameworks?
262
249
*/
263
250
const numRows: ComputedRef <number > = computed (() => {
264
251
return Math .ceil (frameworks .length / numFrameworksPerRow .value )
265
252
})
266
253
254
+ /**
255
+ * The indexes of the blocks on each row that support framework cards.
256
+ *
257
+ * Note that the index of the returned array is 1-based.
258
+ */
259
+ const centerIndexes: ComputedRef <{ start: number ; end: number }[]> = computed (
260
+ () => {
261
+ const firstRowsStartIndex = paddedBlocksPerSide .value
262
+ const frameworksPerFirstRows =
263
+ numBlocksPerRow .value - 2 * paddedBlocksPerSide .value
264
+ const lastRowStartIndex =
265
+ paddedBlocksPerSide .value +
266
+ Math .floor (
267
+ (frameworksPerFirstRows -
268
+ (frameworks .length % frameworksPerFirstRows )) /
269
+ 2 ,
270
+ )
271
+ return new Array (numRows .value + 1 ).fill (0 ).map ((_ , i ) => {
272
+ return i < numRows .value ||
273
+ frameworks .length % frameworksPerFirstRows === 0
274
+ ? {
275
+ start: firstRowsStartIndex ,
276
+ end: numBlocksPerRow .value - paddedBlocksPerSide .value ,
277
+ }
278
+ : {
279
+ start: lastRowStartIndex ,
280
+ end:
281
+ lastRowStartIndex +
282
+ (frameworks .length % frameworksPerFirstRows ) +
283
+ 1 ,
284
+ }
285
+ })
286
+ },
287
+ )
288
+
267
289
/**
268
290
* Generate CSS transformations for each row, to gracefully slide between horizontal positions.
269
291
*/
@@ -289,16 +311,16 @@ const rowStyle: ComputedRef<{ transform: string }> = computed(() => {
289
311
<template v-for =" columnIndex in numBlocksPerRow + 2 " >
290
312
<template
291
313
v-if ="
292
- columnIndex - 1 >= centerIndexes .start &&
293
- columnIndex - 1 < centerIndexes .end
314
+ columnIndex - 1 >= centerIndexes [ rowIndex ] .start &&
315
+ columnIndex - 1 < centerIndexes [ rowIndex ] .end
294
316
"
295
317
>
296
318
<FrameworkCard
297
319
:framework ="
298
320
frameworks[
299
321
(rowIndex - 1) * numFrameworksPerRow +
300
322
(columnIndex - 1) -
301
- centerIndexes.start
323
+ centerIndexes[rowIndex] .start
302
324
]
303
325
"
304
326
/>
0 commit comments