Skip to content

feat(viewport-ruler): add common window resize handler - #6680

Merged
mmalerba merged 1 commit into
angular:masterfrom
crisbeto:viewport-ruler-change-event
Sep 12, 2017
Merged

mmalerba merged 1 commit into
angular:masterfrom
crisbeto:viewport-ruler-change-event

Conversation

@crisbeto

@crisbeto crisbeto commented Aug 28, 2017 •

Copy link
Copy Markdown
Member

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.

@crisbeto
crisbeto requested a review from andrewseguin as a code owner August 28, 2017 21:19
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 28, 2017
Comment thread src/cdk/scrolling/viewport-ruler.ts Outdated
merge<Event>(
fromEvent(window, 'resize'),
fromEvent(window, 'orientationchange')
).subscribe(event => this._changed.next(event.type));

Copy link
Copy Markdown
Contributor

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?

Comment thread src/cdk/scrolling/viewport-ruler.ts Outdated

constructor(scrollDispatcher: ScrollDispatcher) {
/** Stream of viewport change events. */
private _changed = new Subject<string>();

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member Author

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.

Comment thread 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());

Copy link
Copy Markdown
Contributor

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?

@crisbeto

Copy link
Copy Markdown
Member Author

Addressed the feedback @jelbourn.

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

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?

@crisbeto
crisbeto force-pushed the viewport-ruler-change-event branch from db65d66 to 6b09cb4 Compare August 31, 2017 18:16
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Aug 31, 2017
@jelbourn jelbourn added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Sep 1, 2017
@jelbourn

jelbourn commented Sep 1, 2017

Copy link
Copy Markdown
Contributor

@crisbeto

src/cdk/scrolling/viewport-ruler.ts(40,7): error TS2322: Type 'Observable<Event>' is not assignable to type 'Subject<void>'.
  Property 'observers' is missing in type 'Observable<Event>'.

@crisbeto
crisbeto force-pushed the viewport-ruler-change-event branch from 6b09cb4 to 2b4871d Compare September 1, 2017 16:38
@crisbeto

crisbeto commented Sep 1, 2017

Copy link
Copy Markdown
Member Author

Fixed @jelbourn.

@crisbeto crisbeto removed the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Sep 1, 2017
@mmalerba

Copy link
Copy Markdown
Contributor

@crisbeto looks like prerender CI task is failing

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label Sep 12, 2017
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.
@crisbeto
crisbeto force-pushed the viewport-ruler-change-event branch from 2b4871d to 0748fb4 Compare September 12, 2017 17:46
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Sep 12, 2017
@crisbeto

Copy link
Copy Markdown
Member Author

Sorted out the prerender failure.

@mmalerba
mmalerba merged commit 881630f into angular:master Sep 12, 2017
mmalerba added a commit that referenced this pull request Sep 13, 2017
mmalerba added a commit that referenced this pull request Sep 13, 2017
* 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.
josephperrott pushed a commit to josephperrott/components that referenced this pull request Sep 15, 2017
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.
josephperrott pushed a commit to josephperrott/components that referenced this pull request Sep 15, 2017
…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.
@rolandjitsu

Copy link
Copy Markdown

Is this public? And it's listed in beta 11, but I cannot seem to find the .change() method.

@willshowell

Copy link
Copy Markdown
Contributor

@rolandjitsu it was reverted and reopened #7113. I think that is an oversight in the changelog

@rolandjitsu

Copy link
Copy Markdown

@willshowell thanks, I'll keep an eye on that.

@angular-automatic-lock-bot

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants