-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
feat(viewport-ruler): add common window resize handler #6680
Conversation
src/cdk/scrolling/viewport-ruler.ts
Outdated
merge<Event>( | ||
fromEvent(window, 'resize'), | ||
fromEvent(window, 'orientationchange') | ||
).subscribe(event => this._changed.next(event.type)); |
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.
Why subscribe and emit instead of exposing this Observable
?
src/cdk/scrolling/viewport-ruler.ts
Outdated
@@ -20,9 +28,22 @@ export class ViewportRuler { | |||
/** Cached document client rectangle. */ | |||
private _documentRect?: ClientRect; | |||
|
|||
constructor(scrollDispatcher: ScrollDispatcher) { | |||
/** Stream of viewport change events. */ | |||
private _changed = new Subject<string>(); |
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.
Is the difference between resize
and orientationchange
useful here? If we make it void
we can change it to a more robust object later without it being a breaking change
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.
The intention was to let people react differently depending on the event, but we can always change it if somebody asks for it.
src/cdk/scrolling/viewport-ruler.ts
Outdated
// Subscribe to scroll and resize events and update the document rectangle on changes. | ||
scrollDispatcher.scrolled(0, () => this._cacheViewportGeometry()); | ||
this.change().subscribe(() => this._cacheViewportGeometry()); |
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.
Need to unsubscribe in ngOnDestroy
?
Addressed the feedback @jelbourn. |
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.
LGTM- can you amend your commit to include a breaking change message?
db65d66
to
6b09cb4
Compare
|
6b09cb4
to
2b4871d
Compare
Fixed @jelbourn. |
@crisbeto looks like prerender CI task is failing |
Adds the `change` method to the `ViewportRuler`, allowing for components to hook up to a common window resize handler. BREAKING CHANGE: Previously the `ScrollDispatcher.scrolled` subscription would react both on scroll events and on window resize events. Now it only reacts to scroll events. To react to resize events, subscribe to the `ViewportRuler.change()` stream.
2b4871d
to
0748fb4
Compare
Sorted out the prerender failure. |
* Revert "Revert "fix(menu): multiple close events for a single close" (#7036)" This reverts commit dcfe515. * Revert "feat(datepicker): Add Moment.js adapter (#6860)" This reverts commit 9545427. * Revert "fix(menu): multiple close events for a single close (#6961)" This reverts commit 1cccd4b. * Revert "fix(menu): nested trigger staying highlighted after click (#6853)" This reverts commit 04bf3d1. * Revert "feat(viewport-ruler): add common window resize handler (#6680)" This reverts commit 881630f.
Adds the `change` method to the `ViewportRuler`, allowing for components to hook up to a common window resize handler. BREAKING CHANGE: Previously the `ScrollDispatcher.scrolled` subscription would react both on scroll events and on window resize events. Now it only reacts to scroll events. To react to resize events, subscribe to the `ViewportRuler.change()` stream.
…lar#7054) * Revert "Revert "fix(menu): multiple close events for a single close" (angular#7036)" This reverts commit dcfe515. * Revert "feat(datepicker): Add Moment.js adapter (angular#6860)" This reverts commit 9545427. * Revert "fix(menu): multiple close events for a single close (angular#6961)" This reverts commit 1cccd4b. * Revert "fix(menu): nested trigger staying highlighted after click (angular#6853)" This reverts commit 04bf3d1. * Revert "feat(viewport-ruler): add common window resize handler (angular#6680)" This reverts commit 881630f.
Is this public? And it's listed in beta 11, but I cannot seem to find the |
@rolandjitsu it was reverted and reopened #7113. I think that is an oversight in the changelog |
@willshowell thanks, I'll keep an eye on that. |
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. |
Adds the
change
method to theViewportRuler
, allowing for components to hook up to a common window resize handler.BREAKING CHANGE: Previously the
ScrollDispatcher.scrolled
subscription would react both on scroll events and on window resize events. Now it only reacts to scroll events. To react to resize events, subscribe to theViewportRuler.change()
stream.