Skip to content
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

Scroll the document when scrollTop message is sent from viewer #6679

Merged
merged 2 commits into from
Jan 17, 2017

Conversation

muxin
Copy link
Contributor

@muxin muxin commented Dec 14, 2016

Fix #6588

@muxin muxin added the WIP label Dec 14, 2016
@muxin muxin requested a review from dvoytenko December 15, 2016 20:36
@muxin muxin removed the WIP label Dec 15, 2016
@muxin muxin force-pushed the scroll-doc-from-viewer branch 2 times, most recently from 5ab1d96 to 57d94cb Compare December 15, 2016 22:09
@@ -130,6 +130,9 @@ export class Viewer {
/** @private {!Observable<!JSONType>} */
this.broadcastObservable_ = new Observable();

/** @private {!Observable<!JSONType>} */
this.scrollDocObservable_ = new Observable();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to introduce more API dependencies when we are in the process of moving them out? Let's just create a generic observable for all types of messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? Is there a PR where we are moving out the API dependencies? Do you mean changing this to the following?

/** @private {!Observable} */
this.scrollDocObservable_ = new Observable();

Copy link
Contributor

Choose a reason for hiding this comment

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

There'd be a map of observables: !Object<string, !Observable<!JSONType>>. The index is the type of message. The API will be viewer.onMessage(eventType, handler). The records in the map will be created from calls to this API. Thus we simply remove a switch if (eventType == 'x') {x.fire(payload);} to simply if (observables[eventType]) {observables[eventType].fire(payload)}.

@muxin
Copy link
Contributor Author

muxin commented Jan 14, 2017

Rebased after refactoring observables in viewer-impl. Tested in viewer.html.
@dvoytenko PTAL

@muxin muxin merged commit 5fddb61 into ampproject:master Jan 17, 2017
@muxin muxin deleted the scroll-doc-from-viewer branch January 17, 2017 18:44
jridgewell pushed a commit to jridgewell/amphtml that referenced this pull request Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants