Skip to content

feat(drag-drop): add support for sorting animations #12530

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
Aug 7, 2018

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Aug 4, 2018

Reworks the drag&drop to use transform to swap the positions of items in a sortable list. This allows for items to be animated as they're being sorted.

Live demo: https://material-cb7ec.firebaseapp.com/drag-drop

demo

@crisbeto crisbeto added pr: merge safe target: patch This PR is targeted for the next patch release labels Aug 4, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 4, 2018
this.entered.emit({item, container: this});
this.start();

const newIndex = this._getItemIndexFromPointerPosition(item, xOffset, yOffset);
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment here that's something like...

// We use the coordinates of where the item entered the drop container in order to ...

// We need to clone the `clientRect` here, because all the values on it are readonly
// and we need to be able to update them. Also we can't use a spread here, because
// the values on a `ClientRect` aren't own properties. See:
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
Copy link
Member

Choose a reason for hiding this comment

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

This is a great comment

@@ -227,7 +299,47 @@ export class CdkDrop<T = any> implements OnInit, OnDestroy {
/** Resets the container to its initial state. */
private _reset() {
this._dragging = false;

// TODO: may have to wait for the animations to finish.
Copy link
Member

Choose a reason for hiding this comment

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

TODO(crisbeto)

Reworks the drag&drop to use `transform` to swap the positions of items in a sortable list. This allows for items to be animated as they're being sorted.
@crisbeto crisbeto force-pushed the drag-drop-sorting-animation branch from 034edbb to 884ecf7 Compare August 6, 2018 18:30
@crisbeto
Copy link
Member Author

crisbeto commented Aug 6, 2018

I've addressed the feedback @jelbourn.

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 Aug 6, 2018
@josephperrott josephperrott merged commit adcac36 into angular:master Aug 7, 2018
@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.

4 participants