Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would it be possible to detect empty/imaginary cells #1

Closed
hassaannoor opened this issue Sep 30, 2022 · 4 comments
Closed

Would it be possible to detect empty/imaginary cells #1

hassaannoor opened this issue Sep 30, 2022 · 4 comments

Comments

@hassaannoor
Copy link

hassaannoor commented Sep 30, 2022

Maybe start by taking the mean width of the cells and taking the ratio of the container width to the mean width. This ratio is the number of total cells in it. Total cells - Visible Cells = empty/imaginary Cells.

Take this 1D grid for example
[***][ ][***]

Mean width = 3
Container Width = 10
Ratio = Math.round(10/3)=3

Not foolproof probably even stupid. But I wanted to throw it out there in case somebody else needs it.

@daun
Copy link
Owner

daun commented Oct 3, 2022

Do you have an example for how to use the generated data? I'm having a hard time picturing the use case here.

@hassaannoor
Copy link
Author

My use case is for detecting the type of justification.
e.g.
if row order like (space) (cell) (space) then 'justify-center'
if row order like (cell) (space) (cell) then 'justify-between'

I can't make use of the css justify property, because it's not there. The elements are absolutely positioned. I'm trying to make a flex + grid making helper tool. It allows you to freehand move the cells around and generates the css/html.

I'm aware it's a very niche use case.

I was stoked to learn about this library. But later I learned that my use case is gonna need some tweaking.

@daun
Copy link
Owner

daun commented Oct 3, 2022

Interesting. I have something similar on a custom site where I need to check whether one cell is higher than the next one, to then conditionally apply a border to the longer one of each pair. In that case, I just wrote a custom implementation.

If you have a suggestion on how to hook into the detection function to allow that kind of customization, let me know. As it stands, the library is actually quite simple and most things are faster to just write a custom helper for. Maybe there could be a separate new function here, e.g. detectGridJustification or similar.

@hassaannoor
Copy link
Author

I think I should also try to just do a custom implementation. Closing this!

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

No branches or pull requests

2 participants