-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Drag Drop Sortable, mixed orientation support #13372
Comments
@jelbourn hey ,have any progress about this issue now? |
Are there any workarounds for drag and drop in mat-grid-list (reordering items in the grid)? I have an idea, to mark each item in the grid as 'cdkDropList', and handle reordering as dropping item from one cdkDropList to another
If it will work, I will provide demo |
How come the demo gif shows different with what it can provide ? https://cdn-images-1.medium.com/max/800/1*i30ZQdBC7CKbXXdOrUNQcg.gif |
@vupham-zingbox +1 , i want to know how to implement what the demo shows |
@IhorHolovatsky Nice idea |
Would be nice if what's shown in the demos was actually backed up by the framework code. |
Copy and pasting my comment from #13889 since it was a duplicate: To give an example of the issue, I have a horizontal list of photos that needs to wrap (using |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@MrSnappingTurtle Do you have demo code of multiple list wrap? Thanks :) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This is difficult to implement in the current way it was implemented in the CdkDrag directive. The positioning of the placeholder, and the positions of each item that is clearing way for the placeholder, are done by setting inline CSS transforms to each of the involved elements. This is done in a predictable fashion, meaning that since the dimensions of the dragged element are known from the moment it is dragged, it can be calculated for each of the elements in the list how many pixels they should be shifting back/forth. The calculation is eased further by limiting the transforms to a single axis, allowing the transforms to ignore the widths (or heights in horizontal mode) of elements in the list. On the other hand, when a list is wrapping, the wrapped elements are being wrapped in an arbitrary manner, calculated by the browser. When so, it is impossible to translate (transform) list elements in a similar predictability, because it is not known (upon drag event) which list elements are wrapping, and where they are positioned relatively within the list. To circumvent that, upon every drag event, a new snapshot of the list (and all connected lists) must be generated, where the list DOM is being traversed, and each list element gets registered for width and height (practically creating a matrix). Considering that Material devs tried to solve this directive through a performative approach, traversing the DOM and registering each element is not an option as it taxes the browser significantly, and veers from the predictability approach. Alternatively, a middle ground can be implemented. It is less performative than current solution, but at the same time does not require any heavy calculations. Instead of shifting elements via transform, the placeholder element should be moved (currently it remains in the place of the original dragging element), to be positioned before or after the target drop element. It then could animate the max-height property (or max-width for horizontal). This, as I mentioned, is less performative, but it does allow to shift the placeholder anywhere in the list - even in a wrapping list. |
for time being you can take a look this - https://github.com/smnbbrv/angular-sortablejs-demo/tree/master/src/app/examples/multiple-lists |
Thank you! I appreciate your help, I'll check it out.
Best regards, Flo
|
here is a workaround with using multiple lists |
@c3rber That was wonderful! You are my best friend! Thanks a lot ! i will try it. |
@c3rber Wow, it's work for me, thx. But.... Any OFFICIAL progress about this issue? It's for make and standar to this. Thx |
Don't work correcty. If u add a button, for example, for add new items and after reorder the items doesn't work. If you move the ultimate element in tother place don't reorganize correctly I think that the problem is |
With a little change, it's possible, but not perfect. An adaptation of the c3rber solution, in this example with this open source project: |
Me neither |
It works, thx! Here's a little optimization in drop method:
|
do you have a stackblitz? @jsculsp thanks a lot |
I tried it but not working for me, would have an example this optimization? |
This is what @Zefling was refering to:
|
This is the best solution for me, thanks |
Angular/material team, we are waiting for the fix for 5 years. For my team this is the only issue that prevents us from replacing jquery draggable with material drag-drop. |
Hello, I have been subscribed to this issue for more than 4 years, I even made an approximation of what this issue is intended to solve in this codepen. I have recently released Opire and I think this issue is ideal for the use cases it solves. With Opire anyone can create rewards on issues (as long as the repository has the bot installed) so all the people affected by this issue, like me, could put up money for someone to solve it. Without a doubt, this would be an issue in which I would put a reward |
I think at some point I'll do my version. I had to extend and break the code to successfully create a mix between the 2 drap'n drop modes, but it's not satisfactory: |
"@angular/cdk": "^17.3.4",
when the content is one line then the value for index is correct. |
Thanks i
It worked as well for me. |
Currently the drop list sorts items by moving them using a `transform` which keeps the DOM stable and allows for the sorting to be animated, but has the drawback of only allowing sorting in one direction. These changes implement a new `DropListSortStrategy` that allows sorting of lists that can wrap by moving the DOM nodes around directly, rather than via a `transform`. It has the caveat that it can't animate the sorting action. The new strategy can be enabled by setting `cdkDropListOrientation="mixed"`. Fixes angular#13372.
Currently the drop list sorts items by moving them using a `transform` which keeps the DOM stable and allows for the sorting to be animated, but has the drawback of only allowing sorting in one direction. These changes implement a new `DropListSortStrategy` that allows sorting of lists that can wrap by moving the DOM nodes around directly, rather than via a `transform`. It has the caveat that it can't animate the sorting action. The new strategy can be enabled by setting `cdkDropListOrientation="mixed"`. Fixes angular#13372.
Currently the drop list sorts items by moving them using a `transform` which keeps the DOM stable and allows for the sorting to be animated, but has the drawback of only allowing sorting in one direction. These changes implement a new `DropListSortStrategy` that allows sorting of lists that can wrap by moving the DOM nodes around directly, rather than via a `transform`. It has the caveat that it can't animate the sorting action. The new strategy can be enabled by setting `cdkDropListOrientation="mixed"`. Fixes angular#13372.
Currently the drop list sorts items by moving them using a `transform` which keeps the DOM stable and allows for the sorting to be animated, but has the drawback of only allowing sorting in one direction. These changes implement a new `DropListSortStrategy` that allows sorting of lists that can wrap by moving the DOM nodes around directly, rather than via a `transform`. It has the caveat that it can't animate the sorting action. The new strategy can be enabled by setting `cdkDropListOrientation="mixed"`. Fixes #13372.
Thank you so much! Long-awaited feature. |
I have tried and realized the solutions above don't work perfectly. So I make my own solution using |
I made version 2 based on the pull request of the feature for angular 18.1.0-next 4 |
I have refactored the code before |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Feature request,
Mixed direction support, such as items placed by
flex-wrap: wrap
What is the expected behavior?
Should be able to use sortable drag drop on both vertical and horizontal axis at the same time
What is the current behavior?
Only vertical or horizontal is supported
What are the steps to reproduce?
https://stackblitz.com/github/vbwioxyq
Github repo link
https://github.com/abdulkareemnalband/ng-drag-drop/tree/prebuilt-css
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
The text was updated successfully, but these errors were encountered: