Skip to content

Conversation

@mszylkowski
Copy link
Contributor

@mszylkowski mszylkowski commented Oct 29, 2021

On the experiment to story-disable-animations-first-page it 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-initial for the initial page, and using i-amphtml-visited to 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-visited used 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).

@mszylkowski mszylkowski requested a review from gmajoulet November 3, 2021 18:46
@mszylkowski mszylkowski marked this pull request as ready for review November 3, 2021 18:46
@amp-owners-bot
Copy link

amp-owners-bot bot commented Nov 3, 2021

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story/1.0/amp-story.js
extensions/amp-story/1.0/animation.js
extensions/amp-story/1.0/test/test-amp-story.js

@gmajoulet
Copy link
Contributor

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}
*/
Copy link
Contributor

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(
Copy link
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 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))
);
}
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor Author

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', '');
Copy link
Contributor

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

@mszylkowski mszylkowski changed the title 🐛 [Story performance] Disabling animations when first loaded only 🐛 [Story performance] Disabling animations on initial page when first loaded Nov 8, 2021
@stale
Copy link

stale bot commented Nov 12, 2022

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.

@stale stale bot added the Stale Inactive for one year or more label Nov 12, 2022
@stale stale bot closed this Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale Inactive for one year or more

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants