Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

fix(): fix sidenav scroll subscription #284

Merged
merged 1 commit into from
Oct 6, 2017
Merged

Conversation

kara
Copy link
Contributor

@kara kara commented Oct 6, 2017

No description provided.

// to subscribe to its scroll event until next tick (when it does exist).
Promise.resolve().then(() => {
this._scrollContainer = this.container ?
this._document.querySelectorAll(this.container)[0] : window;
Copy link
Member

Choose a reason for hiding this comment

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

You can use querySelector instead of querySelectorAll(...)[0].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm just copy-pasting what was there before into a Promise, but I can update if you want.

.subscribe(() => this.onScroll());
// On init, the sidenav content element doesn't yet exist, so it's not possible
// to subscribe to its scroll event until next tick (when it does exist).
Promise.resolve().then(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't you do this in one of the other lifecycle hooks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. I can move to ngAfterViewInit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Edit: this appears not to work.

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

@kara kara merged commit 1f537eb into angular:master Oct 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants