coopjakob / memory

MIT License
0 stars 0 forks source link

Keep buddy cards together not on two rows #13

Closed coopjakob closed 4 years ago

coopjakob commented 4 years ago

Buddy card is an ad or an info card that is triggered by a product card and therefor belong to each other. We should not split them.

If the product card is the last one in a row. We don't want to add a new card before it, because then the product card will be pushed to the next row.

If this happens we want to get more space at the end of the row by rearrange the cards and change place with the previous card, then it will end up at the next row.

Clearification of decision: That a product with a buddy is more important and will be shown before a card that is sorted by our AI engine. That card will be pushed to the first position of the next line, which is of similar visibility.

benjick commented 4 years ago

Any suggestions on how to solve this technically?

coopjakob commented 4 years ago

I'll take a look

coopjakob commented 4 years ago

In both this issue and in #12 we need a way to find out how many cards there is on one row. I guess if we get the container size and the size for a card we can see how many fits. floor(fullWidth/itemWidth)

Then we can just find the "remainder" using "%", so for example: let itemsOnLastRow = this.productList.length % this.columns;

But in this case we will need the position for a specific card, so lets take the current position in array and use that instead of productList.length.

If it returns 0 it means that means that we're on the last position of the row, because the row is "full"