Skip to content

✨Implement rotate-to-fullscreen#14655

Merged
alanorozco merged 29 commits intoampproject:masterfrom
alanorozco:r82x
Apr 19, 2018
Merged

✨Implement rotate-to-fullscreen#14655
alanorozco merged 29 commits intoampproject:masterfrom
alanorozco:r82x

Conversation

@alanorozco
Copy link
Copy Markdown
Member

@alanorozco alanorozco commented Apr 16, 2018

  1. Extracts everything AutoFullscreen into a separate class.
  2. Renames attr to "rotate-to-fullscreen" for consistency with Chrome.

'third_party/webcomponentsjs/ShadowCSS.js',
'third_party/rrule/rrule.js',
'third_party/react-dates/bundle.js',
'node_modules/intersection-observer/intersection-observer.install.js',
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.

Drive-by: Sorted these.

* @param {string} prefix
* @param {string} sufix
*/
function patchWithWrapper(originalName, patchedName, prefix, sufix) {
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.

Drive-by: Factored this out.

'third_party/css-escape/css-escape.js',
'third_party/d3/**/*.js',
'third_party/mustache/**/*.js',
'third_party/react-dates/bundle.js',
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.

we already have an intersection-observer-polyfill (and I don't think we need direct access to InOb anyway) see comments below.

Copy link
Copy Markdown
Member Author

@alanorozco alanorozco Apr 18, 2018

Choose a reason for hiding this comment

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

Removed. Using synchronous method suggested.

* interaction.
* @private @const {string}
*/
const BLESSED = 'i-amphtml-blessed';
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.

I don't think this is needed. PlayingStates.PLAYING_MANUAL should cover what you need.

/** @private @const */
this.boundSecondsPlaying_ = () => this.secondsPlaying_();

/** @public @const {function():!Rot82xManager} */
Copy link
Copy Markdown
Contributor

@aghassemi aghassemi Apr 17, 2018

Choose a reason for hiding this comment

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

Rot82x sound like an RFC standard :) Maybe autoFullscreenManager ?

this.boundSecondsPlaying_ = () => this.secondsPlaying_();

/** @public @const {function():!Rot82xManager} */
this.getRot82xManager = once(() => this.createRot82xManager_());
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 once ? VideoService itself should not be constructed more than once anyway.

videoPlayed_() {
this.isPlaying_ = true;

if (!this.hasAutoplay) {
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.

ditto, not needed as PlayingStates.PLAYING_MANUAL covers it.

* @param {!../video-interface.VideoInterface} impl
* @private
*/
maybeScrollTo_(impl) {
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.

as disccused offline, using existing code from viewer

/** @private @const {function()} */
const installOrientationObserver =
this.installOrientationObserver_.bind(this);
this.installOrientationObserver_ = once(installOrientationObserver);
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.

do we need once here? given R82FullscreenManager also shouldn't be instantiated more than once.


/** @private */
onRotation_() {
const root = this.ampdoc_.getRootNode();
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.

do, instead of using intersectionObserver, can we just call getIntersectionChangeEntry on video elements and calculate based on that?

If orientation event happens too late ( e.g. after getIntersectionChangeEntry values have been updated based on landscape, then you can do the calculations in a viewer.onScroll event. All getIntersectionChangeEntry values are cached by runtime so there is no perf hit. autoplay does it this way)

resolve();
return;
}
this.getViewport_()
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.

would scrolling to center work? Like to avoid the calculations done here to figure out top vs bottom if possible

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.

I'm hesitant.

  • This scrolls "as little as possible". I find this to be a proxy for matching browser behavior without looking out of place.
  • I think this logic goes with the spirit of preventing the page from shifting unexpectedly, like AMP is supposed to.

I did change two things:

  1. Simplify this greatly by using getIntersectionChangeEntry.
  2. Scroll to center on exit (feels more natural).


/** @private @return {!Promise} */
onceOrientationChanges_() {
const magicNumber = 330;
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 gonna need some comment explaining the magic :)

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.

Haven't experimented enough to have a good reason for it. :) Pending.

@alanorozco
Copy link
Copy Markdown
Member Author

alanorozco commented Apr 18, 2018

@aghassemi

PTAL

  1. Removed polyfill.
  2. Added tests.
  3. Did some unrelated housekeeping around vsync in anticipation. Can move to a separate PR if needed.

autoplayInteractiveVideoBuilt_() {
const toggleAnimation = playing => {
this.vsync_.mutate(() => {
this.getVideoForVsync_().mutateElement(() => {
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.

Thanks for making these changes as well!

@alanorozco alanorozco merged commit 47a082d into ampproject:master Apr 19, 2018
@alanorozco alanorozco deleted the r82x branch April 19, 2018 22:20
glevitzky pushed a commit that referenced this pull request Apr 27, 2018
1. Extracts everything AutoFullscreen into a separate class.
2. Renames attr to "rotate-to-fullscreen" for consistency with Chrome.
3. Does some unrelated housekeeping around vsync in anticipation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants