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 Drop List Dynamic Preview #16769
Comments
This has come up in issues in the past, but we haven't implemented it because it's not totally clear what the API would look like or what the UX would be. E.g. would you set the template for the preview on the A better approach here might be to try and make your example work a bit better. E.g. if the preview changes halfway through a drag sequence we should re-position it next to the user's cursor. |
@crisbeto I'd imagine the preview would be set on the drop list and would switch the preview whenever an item enters the container. |
My problem with setting it on the list is that then you won't have a way of distinguishing which item is currently being shown. Technically you could do it with template variables, but a lot of people aren't familiar with how they work. |
I had also this problem . |
@jonatino Though it is not very pretty, and it is using private DragRef variables to access the preview view ref context. |
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends. Find more details about Angular's feature request process in our documentation. |
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage. We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package. You can find more details about the feature request process in our documentation. |
What are you trying to do?
I want to be able to change the drag and drop preview depending on which container you're dropping into.
In my stackblitz I have three different containers. The first and third one have regular drag and drop previews, but the second one I'd like to customize the drag and drop preview. Using
<img *cdkDragPreview src="https://upload.wikimedia.org/wikipedia/en/4/40/Star_Wars_Phantom_Menace_poster.jpg">
works when dragging elements from the second container, but I'd like the preview to be dynamic depending on where you're dropping it.For example, if you grab an item from the first container and drag it over the second, I'd like the preview to be the image. But it you drag that same item over the third, it should switch back to the regular preview.
What troubleshooting steps have you tried?
I've tried to manually do it using cdkDragDropEntered and cdkDragDropExited events but it did not work as expected. Especially with the differences in the width of the previews.
Reproduction
https://stackblitz.com/edit/angular-suzb2h
Environment
The text was updated successfully, but these errors were encountered: