From 3a9382ac0bd70c393bd5f2308ad7b766b67bb81f Mon Sep 17 00:00:00 2001 From: alexandrecoin Date: Thu, 15 Oct 2020 14:10:40 +0200 Subject: [PATCH] Update functions and variables names for easier readability --- components/slices/MultipleBlock.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/slices/MultipleBlock.vue b/components/slices/MultipleBlock.vue index 193bcce46..1631eead5 100644 --- a/components/slices/MultipleBlock.vue +++ b/components/slices/MultipleBlock.vue @@ -108,7 +108,7 @@ export default { const isObjectConstructor = item.item_image.constructor === Object return isLengthDifferentThanZero && isObjectConstructor }, - findNbItemsInRow() { + numberItemsPerRowForScreenWidth() { if (process.client) { const isLargeScreen = document.body.clientWidth >= DESKTOP_MIN_WIDTH const isExtraLargeScreen = @@ -130,9 +130,17 @@ export default { }, splitItemsIntoRows() { const rows = [] - const chunkSize = this.findNbItemsInRow() - for (let i = 0; i < this.items.length; i += chunkSize) { - rows.push(this.items.slice(i, i + chunkSize)) + const numberOfItemsPerRow = this.numberItemsPerRowForScreenWidth() + for ( + let item = 0; + item < this.items.length; + item += numberOfItemsPerRow + ) { + const screenSizedItems = this.items.slice( + item, + item + numberOfItemsPerRow + ) + rows.push(screenSizedItems) } return rows },