Skip to content

feat(cdk/drag-drop): added dropPoint to dropped event #22347

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

Merged
merged 6 commits into from
Apr 2, 2021

Conversation

timonkrebs
Copy link

@timonkrebs timonkrebs commented Mar 26, 2021

I need to be able to determine the exact point where the mouse pointer was when the Item was dropped. This is not possible to calculate from the distance, because it depends on the position where the item was grabbed at drag start.

CdkDragDrop.item.getFreeDragPosition(); does also not work because it gives the position of the element top/left corner at drag start.

@timonkrebs timonkrebs requested a review from crisbeto as a code owner March 26, 2021 08:00
@google-cla
Copy link

google-cla bot commented Mar 26, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla label Mar 26, 2021
@timonkrebs
Copy link
Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes PR author has agreed to Google's Contributor License Agreement and removed cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla labels Mar 26, 2021
@binerdy
Copy link

binerdy commented Mar 26, 2021

Ah yes, this has been confusing me. It would be nice if the drop position is decided based on the mouse pointer position. Is there an easy way to do this?

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release labels Mar 27, 2021
@wagnermaciel
Copy link
Contributor

@crisbeto Adding dropPoint causes ts errors. Here's an example:

error TS2741: Property 'dropPoint' is missing in type '{ container: CdkDropList<string[]>; previousContainer: CdkDropList<string[]>; currentIndex: number; previousIndex: number; item: CdkDrag<string>; isPointerOverContainer: true; distance: { ...; }; }' but required in type 'CdkDragDrop<string[], string[]>'

Should this be target: major?

@crisbeto
Copy link
Member

It's hard to tell why it's breaking from the error. Does the app try to type an event using our interface? I don't think that this includes any changes that would be considered breaking.

@wagnermaciel
Copy link
Contributor

wagnermaciel commented Mar 30, 2021

@crisbeto It breaks in cases like this:

function createDragDropEvent(...): CdkDragDrop<string[], string[]> {

    ...
  
    return {
        container,
        previousContainer,
        currentIndex,
        previousIndex,
        item,
        isPointerOverContainer,
        distance,
    };
}

CdkDragDrop<string[], string[]> is missing 'dropPoint' so people will start seeing errors

@crisbeto
Copy link
Member

I don't think that's something we cover with our breaking change policy. For g3 it could be patched as dropPoint: {x: 0, y: 0} and a TODO.

@annieyw annieyw merged commit 1d906b6 into angular:master Apr 2, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants