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

Sorting a grids is not smooth #530

Open
orionseye opened this issue Mar 16, 2020 · 5 comments
Open

Sorting a grids is not smooth #530

orionseye opened this issue Mar 16, 2020 · 5 comments
Labels
bug help wanted PR needed This issue requires a PR to be fixed. If you have time to help, please send a PR.

Comments

@orionseye
Copy link

I am trying to implement the sortable to existing grid layout.
If you have a look at the grid demo, it has nothing in common with the initial fork, where sorting is smooth and without issues. Any items can be dragged around, back & forth where placeholder & target are easy to understand
http://farhadi.ir/projects/html5sortable/

While on your demo, the grid items are jumping around, once dragstart is initialized, difficult to follow the logic (for an average user). Furthermore, (e.g) once you drag item 1 after item 2 , it becomes a mess to drag it back to its initial position
Is it as it has to be, or just a bug?

Same happens on my own grid layout

@lukasoppermann lukasoppermann changed the title Sortable Grid issue Sorting a grids is not smooth Mar 23, 2020
@lukasoppermann
Copy link
Owner

Hey, this is somewhat of a bug, yes. To allow for other features and fix some issues we had to change a lot of things which lead to the current behaviour.

To fix this I assume you would have to improve the logic for dead zone calculation and for targeting which item is before the current.

I would very much appreciate if you could look into it and send a PR to fix this.

@lukasoppermann lukasoppermann added the PR needed This issue requires a PR to be fixed. If you have time to help, please send a PR. label Jul 3, 2020
@heyyo-droid
Copy link

heyyo-droid commented Dec 17, 2021

I made a cope pen to better identify the bugs I also have with drag and drop with CSS grid.
https://codepen.io/heyyoyo/pen/LYzyWMB

  1. Moving Block 1, we can see the placeholder lost the width of the dragged element
  2. Moving Block 2, placeholder displayed is correct, but it seems only half height is used, because other elements move as if the dragged element was half height.

I suppose it will be great, if the placeholder could use the same css class than the dragged element. and keep exact dimension of the dragged element.

@heyyo-droid
Copy link

heyyo-droid commented Dec 19, 2021

  1. Was fixed by using last version of the library 0.13.3, i was using old one.
  2. What do you think of adding an option to list all css class which should be kept from the dragged element ?
// set placeholder height if forcePlaceholderSize option is set
if (options.forcePlaceholderSize) {
    store(sortableElement).placeholder.style.height = draggingHeight + 'px';
    store(sortableElement).placeholder.style.width = draggingWidth + 'px';
}
// Should be in option
options.keepCssClass = ['grid-col-2','grid-row-2'];

options.keepCssClass.forEach(className => {
    // Only needed because placeholder is global we need to reiniatilize it to avoid keeping previously added class
    store(sortableElement).placeholder.classList.remove(className) 
    if(element.classList.contains(className)) {
        store(sortableElement).placeholder.classList.add(className)
    }
});

@lukasoppermann
Copy link
Owner

Hey @heyyo-droid that is an interesting ideas,
If you want to send a PR that would be great.

@heyyo-droid
Copy link

Hi @lukasoppermann
I just opened one(my first one on github), #854
Waiting for your review.
Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted PR needed This issue requires a PR to be fixed. If you have time to help, please send a PR.
Projects
None yet
Development

No branches or pull requests

3 participants