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

Feature: PreventCollision move rows #66

Open
AntoninoBonanno opened this issue Dec 23, 2022 · 5 comments
Open

Feature: PreventCollision move rows #66

AntoninoBonanno opened this issue Dec 23, 2022 · 5 comments
Labels
feature New feature

Comments

@AntoninoBonanno
Copy link

AntoninoBonanno commented Dec 23, 2022

Hi, I'm using this setup

  • compactType = "horizontal"
  • preventCollision = "true"

Cattura

I would like that by moving element 8 above element 11, it positions itself between element 5 and element 11 moving the whole row down (both element 11 and element 7 move down)

Cattura2

I would like to have this functionality without giving up the other functionality given by the attributes compactType = "horizontal" and preventCollision = "true". Or in any case I would need the lines to be locked: if I move an element up it must be possible to insert it only if there is space in that line otherwise it creates a new line. Same reasoning below if I move the element up the elements of the rows down shouldn't move. (Items in a row must be locked to that row and not move to other rows)

I thought of implementing this by catching the "dragStarted", "dragEnded" events and updating the layout manually, but the y of the element doesn't change when you drop it on another element (with preventCollision="true") and there is no event that is triggered on each change of x/y (dragging)

Surely there is a better way to implement this within the library

Thank you

@AntoninoBonanno AntoninoBonanno changed the title PreventCollision move rows Feature: PreventCollision move rows Dec 23, 2022
@llorenspujol
Copy link
Contributor

Hi @AntoninoBonanno !

I understand what you want. IMO your use case is quite niche and specific, so the only solution that comes to my mind is giving you the tools to write your own moveElement and compact functions. This would be a quite hardcore solution, but you will be able to do what you want... Said that, this solution is not to my liking, but we should solve your issue somehow.

What are your feelings about it?

@llorenspujol llorenspujol added the feature New feature label Jan 2, 2023
@AntoninoBonanno
Copy link
Author

I think it could be a useful feature for many people to keep rows sorted even when moving an element from below.

If your point of view is different, your solution might be fine.
A dragging event, which tells you what position the dragged element is in as it moves can also help.

Thank you

@llorenspujol
Copy link
Contributor

If this could be a useful better, it would be better integrated within the library, I agree. "Plugin" ways to solve features are always the worst and most problematic, but sometimes is the only way...

Let's see, you say to move entire rows if there is collision, this sounds good, but what do you do in a layout like this for example?

image

Here rows are not that well defined, In your examples, each grid item had the same height, but this may not happen in other layouts. What are your thoughts on a layout like this?
Maybe this configuration should not be possible in a layout like you describe, so things get easier.

@AntoninoBonanno
Copy link
Author

You are right, I use elements with the same height (I block the element height from code, minH = maxH = h = 2)

With a more complex template like this it is more difficult to maintain this logic. I would probably move all elements below the new element position down, thus creating a row in the new element position with the same height as the element.

So if I move element 20 above element 14, elements 14,9, 0, 15, 16, 19, 7, 13, 4 move down. But I don't know if this is a good use case for this kind of template.

@AntoninoBonanno
Copy link
Author

@llorenspujol any updates for this?

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

No branches or pull requests

2 participants