-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
✨Manual management of amp-next-page
document visibility
#25388
Conversation
@wassgha qq:
Can you clarify this? Are we bumping version? Is this component really launched? |
@dvdyakonov let's talk about versioning offline but here's the (very incomplete) design doc https://docs.google.com/document/d/1x-TD4qWr3hWm2BzqUfrv4hHJyTJ4HBb6H3EcJUDDmyY/edit |
c586180
to
346e3d8
Compare
1dc9bd6
to
986ed28
Compare
Ping on this question. |
…#25388) * Manual management of document visibility * Edge cases and tests * Fixed types * Requested changes * Fixed types * Removed unnecessary cast * Switched to using refs instead of indices * Fixed non-nullable type * Manual management of document visibility * Edge cases and tests * Fixed types * Requested changes * Fixed types * Removed unnecessary cast * Switched to using refs instead of indices * Fixed non-nullable type
Closes #25069 , Partial for #15807 & #14059
Changes
amp-next-page v0.1
(the change will land inv0.2
) to allow it to override document visibility for the added shadow docs, fixing interactions withamp-pixel
and possiblyamp-analytics
(previously all added "next" documents would be given the "visible" state even during pre-rendering which would immediately trigger anamp-pixel
hit before the user reaches the next page).e2e
testing is implemented, see Adde2e
tests foramp-next-page
#24610 )ShadowDoc
which defines the Shadow document object (already generated by the AMP runtime but typed asObject
)Implementation details
Previous to this change, shadow docs appended by
amp-next-page
would follow their parent's visibility state which in most cases would bevisible
as the user is scrolling down the page. This causes multiple problems during the time between the pre-render phase (user is scrolling and the next page is loaded) and the visible phase (the user scrolled to the next page and is reading it).One of the problems that have surfaced is the interaction with
amp-pixel
where the analytics call is gated by the document's visibility state. In this case, as the next page has been loaded (and thus adopts its parent'svisible
state), theamp-pixel
triggers preemptively, before the user actually scrolls to the next page.This change corrects the behavior by having
amp-next-page
manually override the visibility state of the next pages as follows:PRERENDER
(as opposed to the parent's visibility state)VISIBLE
while other documents (excluding the host/first document) are either in thePRERENDER
orHIDDEN
statesHIDDEN
,PAUSED
orINACTIVE
but restore the previous states when the parent/first document becomesVISIBLE
Todo
e2e
)PRERENDER
visibility state when scrolling back/cc @nainar @kristoferbaxter