Skip to content

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

Merged
muxin merged 2 commits intoampproject:masterfrom
muxin:scroll-doc-from-viewer
Jan 17, 2017
Merged

Scroll the document when scrollTop message is sent from viewer#6679
muxin merged 2 commits intoampproject:masterfrom
muxin:scroll-doc-from-viewer

Conversation

@muxin
Copy link
Copy Markdown
Contributor

@muxin muxin commented Dec 14, 2016

Fix #6588

@muxin muxin added the WIP label Dec 14, 2016
@muxin muxin force-pushed the scroll-doc-from-viewer branch from 966919d to 8bfd935 Compare December 15, 2016 20:34
@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
Comment thread src/service/viewer-impl.js Outdated
this.broadcastObservable_ = new Observable();

/** @private {!Observable<!JSONType>} */
this.scrollDocObservable_ = new Observable();
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.

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
Copy Markdown
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
Copy Markdown
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 muxin force-pushed the scroll-doc-from-viewer branch from 57d94cb to a6078a4 Compare January 11, 2017 23:06
@muxin muxin force-pushed the scroll-doc-from-viewer branch 2 times, most recently from a7bfa7a to b164d49 Compare January 13, 2017 22:47
@muxin muxin force-pushed the scroll-doc-from-viewer branch from b164d49 to b9298b8 Compare January 14, 2017 00:02
@muxin
Copy link
Copy Markdown
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.

2 participants