-
Notifications
You must be signed in to change notification settings - Fork 6.8k
refactor(sidenav): switch to the angular animations API #4959
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
Conversation
src/lib/sidenav/sidenav.ts
Outdated
* rejected if it didn't). */ | ||
open(): Promise<MdSidenavToggleResult> { | ||
/** Open the sidenav. */ | ||
open(): void { | ||
return this.toggle(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since these are all void
now the return
isn't necessary
src/lib/sidenav/sidenav.ts
Outdated
*/ | ||
close(): Promise<MdSidenavToggleResult> { | ||
/** Close the sidenav. */ | ||
close(): void { | ||
return this.toggle(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
not needed
src/lib/sidenav/sidenav.ts
Outdated
return this._toggleAnimationPromise || | ||
Promise.resolve(new MdSidenavToggleResult(isOpen ? 'open' : 'close', true)); | ||
} | ||
toggle(isOpen: boolean = !this.opened): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the animation API provides some way for people to still hook into these events without returning the promise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have an observable that emits in the done
callback, but I'm not sure that it's worth the trouble.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just asking since I don't know much about the animations API, how do I as a user who is currently doing this:
snav.toggle().then(() => doStuff())
change it to work after this PR? I would guess something like this?
<md-sidenav (@transform.start)="doStuff()"></md-sidenav>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That won't work, because the Angular animation events don't propagate IIRC. The way to do it would be:
snav.onOpen.subscribe(() => doStuff());
snav.open();
I guess we could return the onOpen
and onClose
observables from the open/close methods, but I'm not sure whether it's necessary. The promises that were a part of the old API looked like they were there only there for synchronizing the animations internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sg, just wanted to make sure we weren't taking away functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crisbeto Let's add back these promises because they are used pretty extensively throughout Google's code. We can leave a comment to remove them in the future. (I can do so as part of my other upcoming breaking sidenav changes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Addressed the feedback @mmalerba. |
324ed27
to
d958c8a
Compare
Note: need to update some tests that rely on |
83559bb
to
38d5ff8
Compare
Please rebase |
Seems like the tests are failing after a rebase. Will look into it tomorrow. |
38d5ff8
to
32d12ff
Compare
sorry, needs more rebasing |
32d12ff
to
aee2e86
Compare
@crisbeto Lint is failing right now; can you update? |
aee2e86
to
25894e1
Compare
25894e1
to
f86b7b2
Compare
@andrewseguin Return values have been added back to toggle & friends, want to try another presubmit |
aad41ca
to
4f96e56
Compare
Not sure what I'm seeing here, but it looks like you need to rebase. I see this in your
which differs from master:
|
4f96e56
to
522b894
Compare
Weird that GitHub didn't pick that one up as a conflict @andrewseguin. I've rebased it and fixed the issue. |
Sorry one more thing, the e2e is getting timeouts on the CI. I tried re-running and got the same error. Can you check it out? |
Switches the sidenav to use the `@angular/animations` API. This saves us a lot of code that was involved in orchestrating the various animations, in addition to making it easier to follow. It also makes it possible for the consumer to disable the animations by using the `NoopAnimationsModule`.
522b894
to
607262b
Compare
Sorted out all the failures @andrewseguin. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Switches the sidenav to use the
@angular/animations
API. This saves us a lot of code that was involved in orchestrating the various animations, in addition to making it easier to follow. It also makes it possible for the consumer to disable the animations by using theNoopAnimationsModule
.