Skip to content

feat(drag-drop): allow connecting containers via string ids, attaching data to drop instances and consolidate global event listeners #12315

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 1 commit into from
Jul 25, 2018

Conversation

crisbeto
Copy link
Member

  • Adds the ability to pass in strings to connectedTo when connecting multiple containers together. Previously we only accepted CdkDrop instances which can be inconvenient to pass while inside an ngFor.
  • Adds the ability to attach extra data to a CdkDrag, similarly to CdkDrop. This is mostly for consistency and convenience.
  • Introduces the CdkDragDropRegistry which is used to keep track of the active CdkDrag and CdkDrop instances. It also manages all of the events on the document in order to ensure that we only have one of each event at a given time. This will allow us to handle dragging multiple items at the same time, eventually.

@crisbeto crisbeto added pr: merge safe target: patch This PR is targeted for the next patch release labels Jul 22, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 22, 2018
@ngbot
Copy link

ngbot bot commented Jul 24, 2018

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@crisbeto crisbeto force-pushed the drag-drop-registry branch from 5e95071 to 2163dbb Compare July 24, 2018 17:46

/** Keeps track of the event listeners that we've bound to the `document`. */
private _globalListeners =
new Map<string, {handler: (event: TouchEvent | MouseEvent) => void, options?: any}>();
Copy link
Member

Choose a reason for hiding this comment

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

Alias (event: TouchEvent | MouseEvent) => void into something like PointerEventHandler?

const upEvent = isTouchEvent ? 'touchend' : 'mouseup';

// We explicitly bind __active__ listeners here, because newer browsers
// will default to passive ones for `mousemove` and `touchmove`
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need active handlers in the first place?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's because we use preventDefault to stop the user from scrolling the page or selecting text while they're dragging. If an event is passive, the browser will ignore the preventDefault calls.

@Optional() private _dir: Directionality) {
this._document = document;
_registry.register(this);
Copy link
Member

Choose a reason for hiding this comment

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

How about _dragDropRegistry?

@@ -36,40 +42,58 @@ import {CDK_DROP_CONTAINER} from './drop-container';
],
host: {
'class': 'cdk-drop',
'[attr.id]': 'id',
Copy link
Member

Choose a reason for hiding this comment

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

Just [id]?

@crisbeto crisbeto force-pushed the drag-drop-registry branch from 2163dbb to 87a430d Compare July 24, 2018 17:58
@crisbeto
Copy link
Member Author

Feedback has been addressed.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jul 24, 2018
@ngbot
Copy link

ngbot bot commented Jul 24, 2018

I see that you just added the pr: merge ready label, but the following checks are still failing:
    failure status "continuous-integration/travis-ci/pr" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@crisbeto crisbeto removed the action: merge The PR is ready for merge by the caretaker label Jul 24, 2018
…g data to drop instances and consolidate global event listeners

* Adds the ability to pass in strings to `connectedTo` when connecting multiple containers together. Previously we only accepted `CdkDrop` instances which can be inconvenient to pass while inside an `ngFor`.
* Adds the ability to attach extra data to a `CdkDrag`, similarly to `CdkDrop`. This is mostly for consistency and convenience.
* Introduces the `CdkDragDropRegistry` which is used to keep track of the active `CdkDrag` and `CdkDrop` instances. It also manages all of the events on the `document` in order to ensure that we only have one of each event at a given time. This will allow us to handle dragging multiple items at the same time, eventually.
@crisbeto crisbeto force-pushed the drag-drop-registry branch from 87a430d to 4af4c70 Compare July 24, 2018 19:18
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jul 24, 2018
@mmalerba mmalerba merged commit 5502e6f into angular:master Jul 25, 2018
mmalerba pushed a commit that referenced this pull request Jul 30, 2018
…g data to drop instances and consolidate global event listeners (#12315)

* Adds the ability to pass in strings to `connectedTo` when connecting multiple containers together. Previously we only accepted `CdkDrop` instances which can be inconvenient to pass while inside an `ngFor`.
* Adds the ability to attach extra data to a `CdkDrag`, similarly to `CdkDrop`. This is mostly for consistency and convenience.
* Introduces the `CdkDragDropRegistry` which is used to keep track of the active `CdkDrag` and `CdkDrop` instances. It also manages all of the events on the `document` in order to ensure that we only have one of each event at a given time. This will allow us to handle dragging multiple items at the same time, eventually.
josephperrott pushed a commit that referenced this pull request Aug 7, 2018
…g data to drop instances and consolidate global event listeners (#12315)

* Adds the ability to pass in strings to `connectedTo` when connecting multiple containers together. Previously we only accepted `CdkDrop` instances which can be inconvenient to pass while inside an `ngFor`.
* Adds the ability to attach extra data to a `CdkDrag`, similarly to `CdkDrop`. This is mostly for consistency and convenience.
* Introduces the `CdkDragDropRegistry` which is used to keep track of the active `CdkDrag` and `CdkDrop` instances. It also manages all of the events on the `document` in order to ensure that we only have one of each event at a given time. This will allow us to handle dragging multiple items at the same time, eventually.
@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 Sep 9, 2019
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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants