-
Notifications
You must be signed in to change notification settings - Fork 4.1k
🐛 [Story performance] Disabling animations on initial page when first loaded #36668
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
Conversation
…l; branch 'main' of github.com:ampproject/amphtml into noanimation_firstpage
|
Hey @gmajoulet, @newmuis! These files were changed: |
|
I know this would make LCP better for documents using animations, but I think as a first step we should run this ONLY for transformed / optimized documents, as doing it for ALL documents would be a larger decision. |
| /** | ||
| * Whether to skip the animations on the page, due to reduced motion or first page. | ||
| * @return {boolean} | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@private
| skipAnimations_() { | ||
| return ( | ||
| prefersReducedMotion(this.ampdoc_.win) || | ||
| (isExperimentOn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we're planning on launching this experiment, and we should not repurpose them it makes old data, dashboards, and documents very confusing.
| ) && | ||
| matches(this.page_, DISABLE_ANIMATIONS_FIRST_PAGE_SELECTOR)) | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still disables animations on non transformed documents
| // desktop view. | ||
| switchPromise.then(() => { | ||
| this.pages_.forEach((page) => | ||
| removeAttributeInMutate(page, Attributes.VISITED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replay_() is really trying to reset everything, including this, like a page reload. We should still remove the attributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR I want to make the removal of animations more targeted:
- Current: first page of each story (independently of whether it was visited before or not).
- New: initial page of the story on the first visit of the page.
This means that when the story is replayed we don't need to skip the animations, especially because we're not on the initial page any more on some cases.
However, I understand your point so I'll re-implement this feature with better semantics (and probably remove this attribute altogether).
| `amp-story-page#${escapeCssSelectorIdent(pageId)}` | ||
| ); | ||
| page.setAttribute('active', ''); | ||
| page.setAttribute('i-amphtml-initial', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute is very broad and could mean literally anything, please be a bit more specific and/or consistent with how things are named in the JavaScript to make it easier
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
On the experiment to
story-disable-animations-first-pageit would always prevent the first page from running the animations, but we only want to disable them if the initial page is being initially loaded (when you return to the first page, it should play the animations).This PR only disables the animations when you initially open the story, but when you navigate to the first page it should play the animation.
I'm adding an attribute
i-amphtml-initialfor the initial page, and usingi-amphtml-visitedto know if this is the first time that the page is viewed (we don't want to disable animations if you're coming back to the page).The attribute
i-amphtml-visitedused to guide what side on the screen an inactive page is (visited pages would be on the left). However, with the one panel layout, this is unnecessary so I removed that part of the logic, so that the attribute now informs whether the user has visited to the page (regardless of whether it's on the left or right).