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

Drag&Drop Drop List Dynamic Preview #16769

Open
jonatino opened this issue Aug 13, 2019 · 7 comments
Open

Drag&Drop Drop List Dynamic Preview #16769

jonatino opened this issue Aug 13, 2019 · 7 comments
Labels
area: cdk/drag-drop feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@jonatino
Copy link

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

  • Angular: latest
  • CDK/Material: latest
  • Browser(s): All
  • Operating System (e.g. Windows, macOS, Ubuntu): All
@jonatino jonatino added the troubleshooting This issue is not reporting an issue, but just asking for help label Aug 13, 2019
@crisbeto crisbeto added feature This issue represents a new feature or feature request rather than a bug or bug fix and removed troubleshooting This issue is not reporting an issue, but just asking for help labels Aug 19, 2019
@crisbeto
Copy link
Member

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 cdkDropList or on the drop item? Also at what point would it switch to the new preview (e.g. only when it's over the new container, half way through etc)?

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.

@jonatino
Copy link
Author

@crisbeto I'd imagine the preview would be set on the drop list and would switch the preview whenever an item enters the container.

@crisbeto
Copy link
Member

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.

@yim222
Copy link

yim222 commented Apr 21, 2020

I had also this problem .
Cannot change the preview content dynamically,
Think it's basic functionality that needed a lot

@mmalerba mmalerba added the needs triage This issue needs to be triaged by the team label May 20, 2020
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Jul 19, 2020
@Achilles1515
Copy link

@jonatino
Like crisbeto said, this can be done with template input variables and custom event methods.

Example:
https://stackblitz.com/edit/angular-suzb2h-vacqfr?file=app%2Fcdk-drag-drop-connected-sorting-group-example.html

Though it is not very pretty, and it is using private DragRef variables to access the preview view ref context.

@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

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.

@angular-robot
Copy link
Contributor

angular-robot bot commented Mar 13, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/drag-drop feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

6 participants