Implement Visibility API#2212
Conversation
|
Assigning to @dvoytenko, but we're waiting to merge this until later this week. |
2013b58 to
40bd5f7
Compare
src/service/viewer-impl.js
Outdated
There was a problem hiding this comment.
I think a better term for this might be "background". This state only triggers when the browser tab that displays the viewer/doc is not active (another tab is).
40bd5f7 to
aac902a
Compare
|
PTAL. |
|
Looking... |
src/service/viewer-impl.js
Outdated
There was a problem hiding this comment.
Let's store a single and correct this.visibilityState_ (point of reference) and recalculate it only when something changes.
|
Looks great! Some comments... |
f28fb6c to
dbda708
Compare
|
PTAL. |
dbda708 to
bffaf1a
Compare
src/service/viewer-impl.js
Outdated
There was a problem hiding this comment.
We don't need to worry about skipFire in this case (or maybe never?) - here we know that the list of listeners is empty :)
There was a problem hiding this comment.
Is fixedUnloaded really true here? Seems like the initial hidden would indicate instead the prerendering state, not unloaded.
|
@jridgewell this looks awesome! I just would like to do these few steps:
|
bffaf1a to
cc90d19
Compare
cc90d19 to
a5b7a0f
Compare
I had to backtrack a bit and do a bit of computation in |
src/service/viewer-impl.js
Outdated
There was a problem hiding this comment.
"but the browser tab or an AMP app is not"
|
Great! Some doc changes, clear up getter and setter and confirm if we need flush and we're at lgtm. |
40270a7 to
69e8e2a
Compare
src/service/viewer-impl.js
Outdated
There was a problem hiding this comment.
This line has to be called after this.recheckVisibilityState_() call, otherwise it will misreport. Probably just better to call recheckVisibilityState_() as soon as viewerVisibilityState_ and docState_ are initialized?
|
Great! It looks like there's one small bug to be fixed with the sequence of initializations. But otherwise LGTM! |
238307a to
1c63939
Compare
Implements a “standardized” visibility API with control from the viewer and browser document. - Allows the Viewer to send the `paused` state when the users swipes between AMP docs. (closes ampproject#1655, ampproject#1538) - Adds the `prerender` visibility state when the AMP document has not been shown yet. - Adds the `inactive` visibility state when the AMP document is not active. - Changes the `hidden` visibility to mean the AMP doc is active but the browser tab is not visible.
1c63939 to
0b66e51
Compare
Implements a “standardized” visibility API with control from the viewer
and browser document.
pausedstate when the users swipesbetween AMP docs. (closes Add PAUSED VisibilityState #1655, add a 'paused' visibility state #1538)
inactivevisibility state when the AMP document is notactive
hiddenvisibility to mean the AMP doc is active but thebrowser tab is not visible.