@@ -59,7 +59,7 @@ import {isPrerenderActivePage} from './prerender-active-page';
5959import { listen , listenOnce } from '#utils/event-helper' ;
6060import { CSS as pageAttachmentCSS } from '../../../build/amp-story-open-page-attachment-0.1.css' ;
6161import { propagateAttributes } from '#core/dom/propagate-attributes' ;
62- import { toggle } from '#core/dom/style' ;
62+ import { px , toggle } from '#core/dom/style' ;
6363import { renderPageAttachmentUI } from './amp-story-open-page-attachment' ;
6464import { renderPageDescription } from './semantic-render' ;
6565import { whenUpgradedToCustomElement } from '#core/dom/amp-element-helpers' ;
@@ -214,6 +214,9 @@ export class AmpStoryPage extends AMP.BaseElement {
214214 /** @private {?AdvancementConfig} */
215215 this . advancement_ = null ;
216216
217+ /** @private {?Element} */
218+ this . cssVariablesStyleEl_ = null ;
219+
217220 /** @const @private {!function(boolean)} */
218221 this . debounceToggleLoadingSpinner_ = debounce (
219222 this . win ,
@@ -610,13 +613,23 @@ export class AmpStoryPage extends AMP.BaseElement {
610613 const { height, width} = layoutBox ;
611614 state . height = height ;
612615 state . width = width ;
616+ state . vh = height / 100 ;
613617 } ,
614618 mutate : ( state ) => {
615619 const { height, width} = state ;
616620 if ( state . height === 0 && state . width === 0 ) {
617621 return ;
618622 }
619623 this . storeService_ . dispatch ( Action . SET_PAGE_SIZE , { height, width} ) ;
624+ if ( ! this . cssVariablesStyleEl_ ) {
625+ const doc = this . win . document ;
626+ this . cssVariablesStyleEl_ = doc . createElement ( 'style' ) ;
627+ this . cssVariablesStyleEl_ . setAttribute ( 'type' , 'text/css' ) ;
628+ doc . head . appendChild ( this . cssVariablesStyleEl_ ) ;
629+ }
630+ this . cssVariablesStyleEl_ . textContent = `:root {--story-page-vh: ${ px (
631+ state . vh
632+ ) } !important}`;
620633 } ,
621634 } ,
622635 { }
0 commit comments