diff --git a/examples/amp-story/performance/splitcss.html b/examples/amp-story/performance/splitcss.html new file mode 100644 index 000000000000..146c9f28095a --- /dev/null +++ b/examples/amp-story/performance/splitcss.html @@ -0,0 +1,120 @@ + + + + + + + + Boilerplate test + + + + + + + + + + + + + + + + + + + + + + +

Story Prestyle + JS

+

This is how a story looks with the prestyle+JS

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+
+ +

This text is positioned with an aspect-ratio layer

+
+
+
+ + diff --git a/extensions/amp-story/1.0/amp-story-page.js b/extensions/amp-story/1.0/amp-story-page.js index d353bd4d755d..972e2c7364ba 100644 --- a/extensions/amp-story/1.0/amp-story-page.js +++ b/extensions/amp-story/1.0/amp-story-page.js @@ -627,9 +627,6 @@ export class AmpStoryPage extends AMP.BaseElement { state.width = width; state.vh = height / 100; state.vw = width / 100; - state.fiftyVw = Math.round(width / 2); - state.vmin = Math.min(state.vh, state.vw); - state.vmax = Math.max(state.vh, state.vw); }, mutate: (state) => { const {height, width} = state; @@ -645,11 +642,8 @@ export class AmpStoryPage extends AMP.BaseElement { } this.cssVariablesStyleEl_.textContent = `:root {` + - `--story-page-vh: ${px(state.vh)};` + - `--story-page-vw: ${px(state.vw)};` + - `--story-page-vmin: ${px(state.vmin)};` + - `--story-page-vmax: ${px(state.vmax)};` + - `--i-amphtml-story-page-50vw: ${px(state.fiftyVw)};` + + `--story-page-vh: ${px(state.vh)} !important;` + + `--story-page-vw: ${px(state.vw)} !important;` + `}`; }, }, diff --git a/extensions/amp-story/1.0/amp-story.css b/extensions/amp-story/1.0/amp-story.css index 58486a27a104..31bc948a1972 100644 --- a/extensions/amp-story/1.0/amp-story.css +++ b/extensions/amp-story/1.0/amp-story.css @@ -1,5 +1,3 @@ - - @import './amp-story-access.css'; @import './amp-story-affiliate-link.css'; @import './amp-story-desktop-one-panel.css'; @@ -11,6 +9,13 @@ @import './pagination-buttons.css'; /** Common */ +:root { + --story-page-vw: 1vw; + --story-page-vh: 1vh; + --story-page-vmin: min(var(--story-page-vw), var(--story-page-vh)); + --story-page-vmax: max(var(--story-page-vw), var(--story-page-vh)); + font-size: calc(2.5 * var(--story-page-vh, 8px)); +} amp-story, amp-story-page, amp-story-cta-layer { contain: strict !important; overflow: hidden !important; @@ -76,10 +81,6 @@ amp-story { touch-action: manipulation !important; } -html.i-amphtml-story-standalone { - font-size: calc(2.5 * var(--story-page-vmax, 8px)); -} - html.i-amphtml-story-standalone, html.i-amphtml-story-standalone body { font-size: calc(2.5 * var(--story-page-vh, 8px));