Skip to content

Wrong calculation in positionService#setItemsColumnSpan#37

Open
antony-k1208 wants to merge 1 commit into
tristanguigue:masterfrom
antony-k1208:patch-1
Open

Wrong calculation in positionService#setItemsColumnSpan#37
antony-k1208 wants to merge 1 commit into
tristanguigue:masterfrom
antony-k1208:patch-1

Conversation

@antony-k1208
Copy link
Copy Markdown
Contributor

items[i].width isn't absolutely safe, the return value has sometimes multiple decimal places, which leads to a wrong calculation of the actual columnSpan because Math.ceil will always return the smallest integer greater than or equal to a given number. Using this limitation seems to work great!

items[i].width isn't absolutely safe, the return value has sometimes multiple decimal places, which leads to a wrong calculation of the actual columnSpan because Math.ceil will always return the smallest integer greater than or equal to a given number. Using this limitation seems to work great!
@tristanguigue
Copy link
Copy Markdown
Owner

Thanks for your feedback, could you provide an example where that applies?

@antony-k1208
Copy link
Copy Markdown
Contributor Author

Using four different templates with different widths, i got this "Item too large" error many times, because sometimes item[i].width had multiple decimals, which led to a colSize of 5 instead of 4. I was using 25vw, 50vw, 75vw and 100vw for the different template widths.

@tristanguigue
Copy link
Copy Markdown
Owner

You mean the columnSpan was 5 instead of 4 I assume. I see how we can have errors due to the smallest element width being rounded up.

Using only 2 decimals doesn't fix this though. Imagine your 25vw element has a width of 30.009 and your 50vw 2 * 30.009 = 60.018, in this example keeping 2 decimals only will lead to Math.ceil(60.01 / 30.00) = 3 instead of 2.

@antony-k1208
Copy link
Copy Markdown
Contributor Author

I see, i see..mh well we dropped the usage of this plugin in our project, because we didn't need this fully dynamic grid system, so i'm currently not able to spent some time thinking of a good solution for that, sorry..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants