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

Support auto track definitions #7

Open
shyndman opened this issue Jan 25, 2020 · 3 comments
Open

Support auto track definitions #7

shyndman opened this issue Jan 25, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@shyndman
Copy link
Owner

Auto tracks are generated automatically when the placement algorithm places an item outside the range of the templated tracks. This could be useful in some cases.

@shyndman shyndman self-assigned this Jan 25, 2020
@shyndman shyndman added the enhancement New feature or request label Jan 25, 2020
@shyndman shyndman removed their assignment Jan 25, 2020
@erickok
Copy link

erickok commented Feb 3, 2021

Which type of track would you pick, though? The relatively heavy IntrinsicContentTrack? Or a FlexibleTrackSizeTrack(1)? Not sure if we can come up with an intuitive default.
Alternatively, in case of 'missing' tracks, we could not crash/error but instead show overflow bars (on debug builds) and otherwise ignore this content?

@shyndman
Copy link
Owner Author

shyndman commented Feb 3, 2021

Which type of track would you pick, though? The relatively heavy IntrinsicContentTrack? Or a FlexibleTrackSizeTrack(1)? Not sure if we can come up with an intuitive default.

No defaults! We let the user decide.

https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows

Alternatively, in case of 'missing' tracks, we could not crash/error but instead show overflow bars (on debug builds) and otherwise ignore this content?

Agreed that a crash is a little harsh. Let me think about it.

@nicoburns
Copy link

I think this should actually be quite straightforward to implement. All you'd need to do is resize to fit the item your placement grid instead of throwing an error. I have an implementation of this for my CSS Grid implementation here. As you can see, it's quite short and straightforward. And mine is actually quite a bit more complex than I think you'd need as it needs to support negative indexes (adding negative implicit tracks is a massive pain as it means the origin of grid moves!)

For performance reasons I also have some logic to estimate the required size ahead of time (by scanning through the grid placements and spans of every item and finding the min/max - you'd only need the max). The logic for that is here. This doesn't completely guarantee no resizes as auto-placement can still generate more tracks but it helps in the "explicitly placed out of bounds" case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants