✨Implement rotate-to-fullscreen#14655
Conversation
build-system/tasks/compile.js
Outdated
| 'third_party/webcomponentsjs/ShadowCSS.js', | ||
| 'third_party/rrule/rrule.js', | ||
| 'third_party/react-dates/bundle.js', | ||
| 'node_modules/intersection-observer/intersection-observer.install.js', |
There was a problem hiding this comment.
Drive-by: Sorted these.
| * @param {string} prefix | ||
| * @param {string} sufix | ||
| */ | ||
| function patchWithWrapper(originalName, patchedName, prefix, sufix) { |
There was a problem hiding this comment.
Drive-by: Factored this out.
build-system/tasks/compile.js
Outdated
| 'third_party/css-escape/css-escape.js', | ||
| 'third_party/d3/**/*.js', | ||
| 'third_party/mustache/**/*.js', | ||
| 'third_party/react-dates/bundle.js', |
There was a problem hiding this comment.
we already have an intersection-observer-polyfill (and I don't think we need direct access to InOb anyway) see comments below.
There was a problem hiding this comment.
Removed. Using synchronous method suggested.
src/service/video-manager-impl.js
Outdated
| * interaction. | ||
| * @private @const {string} | ||
| */ | ||
| const BLESSED = 'i-amphtml-blessed'; |
There was a problem hiding this comment.
I don't think this is needed. PlayingStates.PLAYING_MANUAL should cover what you need.
src/service/video-manager-impl.js
Outdated
| /** @private @const */ | ||
| this.boundSecondsPlaying_ = () => this.secondsPlaying_(); | ||
|
|
||
| /** @public @const {function():!Rot82xManager} */ |
There was a problem hiding this comment.
Rot82x sound like an RFC standard :) Maybe autoFullscreenManager ?
src/service/video-manager-impl.js
Outdated
| this.boundSecondsPlaying_ = () => this.secondsPlaying_(); | ||
|
|
||
| /** @public @const {function():!Rot82xManager} */ | ||
| this.getRot82xManager = once(() => this.createRot82xManager_()); |
There was a problem hiding this comment.
why once ? VideoService itself should not be constructed more than once anyway.
src/service/video-manager-impl.js
Outdated
| videoPlayed_() { | ||
| this.isPlaying_ = true; | ||
|
|
||
| if (!this.hasAutoplay) { |
There was a problem hiding this comment.
ditto, not needed as PlayingStates.PLAYING_MANUAL covers it.
src/service/video-manager-impl.js
Outdated
| * @param {!../video-interface.VideoInterface} impl | ||
| * @private | ||
| */ | ||
| maybeScrollTo_(impl) { |
There was a problem hiding this comment.
as disccused offline, using existing code from viewer
src/service/video-manager-impl.js
Outdated
| /** @private @const {function()} */ | ||
| const installOrientationObserver = | ||
| this.installOrientationObserver_.bind(this); | ||
| this.installOrientationObserver_ = once(installOrientationObserver); |
There was a problem hiding this comment.
do we need once here? given R82FullscreenManager also shouldn't be instantiated more than once.
src/service/video-manager-impl.js
Outdated
|
|
||
| /** @private */ | ||
| onRotation_() { | ||
| const root = this.ampdoc_.getRootNode(); |
There was a problem hiding this comment.
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)
src/service/video-manager-impl.js
Outdated
| resolve(); | ||
| return; | ||
| } | ||
| this.getViewport_() |
There was a problem hiding this comment.
would scrolling to center work? Like to avoid the calculations done here to figure out top vs bottom if possible
There was a problem hiding this comment.
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:
- Simplify this greatly by using
getIntersectionChangeEntry. - Scroll to center on exit (feels more natural).
|
|
||
| /** @private @return {!Promise} */ | ||
| onceOrientationChanges_() { | ||
| const magicNumber = 330; |
There was a problem hiding this comment.
is gonna need some comment explaining the magic :)
There was a problem hiding this comment.
Haven't experimented enough to have a good reason for it. :) Pending.
|
PTAL
|
| autoplayInteractiveVideoBuilt_() { | ||
| const toggleAnimation = playing => { | ||
| this.vsync_.mutate(() => { | ||
| this.getVideoForVsync_().mutateElement(() => { |
There was a problem hiding this comment.
Thanks for making these changes as well!
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.
Uh oh!
There was an error while loading. Please reload this page.