🚀 [Story performance] Add css to show story from beginning#36333
🚀 [Story performance] Add css to show story from beginning#36333mszylkowski merged 17 commits intoampproject:mainfrom
Conversation
|
Hey @gmajoulet, @newmuis! These files were changed: |
| position: absolute !important; | ||
| top: 0; | ||
| left: 0; | ||
| } |
There was a problem hiding this comment.
How come you don't need width/height 100% too? Do you get them from some other CSS?
There was a problem hiding this comment.
ampshared.css provides them
There was a problem hiding this comment.
We don't really have any guarantee that ampshared is loaded if we inline this code in the HEAD of the document. We should add these statements.
There was a problem hiding this comment.
That's a good point, I missed that https://github.com/ampproject/amphtml/blob/main/extensions/amp-story/1.0/amp-story.css#L76 also provides them, so we're good. I don't think there are other styles we need from there, but it opens up the conversation of whether we'd need ampshared.css on stories, or we can save up those extra bytes
| position: absolute !important; | ||
| top: 0; | ||
| left: 0; | ||
| } |
There was a problem hiding this comment.
We don't really have any guarantee that ampshared is loaded if we inline this code in the HEAD of the document. We should add these statements.
| } | ||
|
|
||
| amp-story-page:not([active]) { | ||
| amp-story.i-amphtml-story-loaded amp-story-page:not([active]) { |
There was a problem hiding this comment.
Why do you need this change?
There was a problem hiding this comment.
Inactive pages get hidden with the style:
amp-story-page:not(:first-of-type):not([distance]):not([active]) {
transform: translateY(1000vh)!important;
}but we want to show the first page with CSS, so we need to say that we only want to hide the non-active pages when the story is loaded. This will make the first page visible, but all the other ones not. When the story loads, all the inactive pages will be hidden (due to this rule on line 235) but before the story is loaded, the CSS I showed above will only show the first page
There was a problem hiding this comment.
As seen offline, let's revisit this and only rely on [distance] and [active] attr
Closes #36050
Adds styles to display the first page of the story before the JS loads.