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

Multiple track registration constructor vs add api (split-grid) #781

Open
njaldea opened this issue Apr 18, 2023 · 1 comment
Open

Multiple track registration constructor vs add api (split-grid) #781

njaldea opened this issue Apr 18, 2023 · 1 comment

Comments

@njaldea
Copy link

njaldea commented Apr 18, 2023

Please refer to reproduction below:
Reproduction

It has two versions (Constructor and Api)
both are doing the same thing:

  • 2 column 3 rows
  • tries to register multiple elements per track

For Constructor, it works fine (but i guess i am doing something I should not be doing)
For Api, only the last div for track works (3rd div for column. and 3rd div for row 1 and row 3)

Constructor works because it does not "cleanup" duplicates.

        this.options.columnGutters.forEach(gutterOptions => {
            this.columnGutters[gutterOptions.track] = createGutter(
                'column',
                this.options,
            )(gutterOptions)
        })

if gutterOptins.track has duplicates, it does not destroy the previous one, though i guess, based on code, that i should not do this (?)

For Api, it is a different story

    addColumnGutter(element, track) {
        if (this.columnGutters[track]) {
            this.columnGutters[track].destroy() // <-- this one
        }

        this.columnGutters[track] = createGutter(
            'column',
            this.options,
        )({
            element,
            track,
        })
    }

Is it intentional that there can only be one element per track?
My intention is to add an orthogonal control (so that intersection can control both directions at the same time when resizing)

@njaldea
Copy link
Author

njaldea commented Apr 18, 2023

I think either one of the following should happen.

  1. Support multiple element per track (i like this one but i don't know if it conflicts with the goals and design of the library)
  2. Constructor should just call addColumnGutter/addRowGutter so it will cleanup the duplicates automatically. Though maybe this restriction might be good to be added in the documentation so users (me) would be informed

Thank you!

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

1 participant