Skip to content

Commit 654d154

Browse files
committed
Temporarilly disable animation in ContentpassLayer
1 parent 69dec50 commit 654d154

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

packages/react-native-contentpass-ui/src/components/ContentpassLayer.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ import { useMemo, useState } from 'react';
66

77
const MESSAGE_PROTOCOL = 'contentpass-first-layer';
88

9+
const DISABLE_ANIMATIONS_JS = `
10+
(function () {
11+
var style = document.createElement('style');
12+
style.textContent = '*, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; } main, .backdrop { visibility: visible !important; transform: none !important; }';
13+
(document.head || document.documentElement).appendChild(style);
14+
15+
true;
16+
})();
17+
`;
18+
919
const GLUE_CODE_JS = `
1020
(function () {
1121
const originalPostMessage = window.postMessage;
@@ -150,9 +160,10 @@ export default function ContentpassLayer({
150160
source={{ uri: firstLayerUrl }}
151161
style={[styles.webview, !ready && { opacity: 0 }]}
152162
originWhitelist={['*']}
153-
startInLoadingState
154163
javaScriptEnabled
155164
domStorageEnabled
165+
automaticallyAdjustContentInsets={false}
166+
injectedJavaScriptBeforeContentLoaded={DISABLE_ANIMATIONS_JS}
156167
injectedJavaScript={GLUE_CODE_JS}
157168
onMessage={(event) => {
158169
handleMessage(event);

0 commit comments

Comments
 (0)