@@ -2,7 +2,7 @@ import { StyleSheet, Text, View } from 'react-native';
22import { WebView , type WebViewMessageEvent } from 'react-native-webview' ;
33import type { ContentpassLayerEvents } from './ContentpassLayerEvents' ;
44import buildFirstLayerUrl from './buildFirstLayerUrl' ;
5- import { useMemo } from 'react' ;
5+ import { useMemo , useState } from 'react' ;
66
77const MESSAGE_PROTOCOL = 'contentpass-first-layer' ;
88
@@ -70,6 +70,8 @@ export default function ContentpassLayer({
7070 } ) ;
7171 } , [ baseUrl , planId , propertyId , purposesList , vendorCount ] ) ;
7272
73+ const [ ready , setReady ] = useState ( false ) ;
74+
7375 function handleMessage ( event : WebViewMessageEvent ) {
7476 let msg : any ;
7577 try {
@@ -92,8 +94,12 @@ export default function ContentpassLayer({
9294 console . debug ( 'WebView message' , msg ) ;
9395
9496 switch ( msg . action ) {
97+ case 'FIRST_LAYER_READY' :
98+ setReady ( true ) ;
99+ break ;
95100 case 'ENABLE_SCROLL_ON_PROPERTY' :
96- // Ignore this message
101+ case 'DISABLE_SCROLL_ON_PROPERTY' :
102+ // ignore these messages
97103 break ;
98104 case 'GO_TO' :
99105 switch ( msg . payload ?. options ?. page ) {
@@ -142,7 +148,7 @@ export default function ContentpassLayer({
142148 < View style = { styles . container } >
143149 < WebView
144150 source = { { uri : firstLayerUrl } }
145- style = { styles . webview }
151+ style = { [ styles . webview , ! ready && { opacity : 0 } ] }
146152 originWhitelist = { [ '*' ] }
147153 startInLoadingState
148154 javaScriptEnabled
0 commit comments