From b336c95f2078dd8c4111f8ce51246a4cc2ceb261 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Thu, 16 Apr 2020 23:03:57 +0200 Subject: [PATCH] Fixed body padding not applying on some cases --- src/components/Screens/WebViewScreen.js | 31 +++---------------------- src/screens/Websites/PlanexScreen.js | 1 - 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/src/components/Screens/WebViewScreen.js b/src/components/Screens/WebViewScreen.js index 2e808b6..043989a 100644 --- a/src/components/Screens/WebViewScreen.js +++ b/src/components/Screens/WebViewScreen.js @@ -114,7 +114,6 @@ class WebViewScreen extends React.PureComponent { onOpenClicked = () => Linking.openURL(this.props.url); injectJavaScript = (script: string) => { - // console.log(this.webviewRef.current.getNode().webViewRef.current); this.webviewRef.current.getNode().injectJavaScript(script); } @@ -125,46 +124,21 @@ class WebViewScreen extends React.PureComponent { */ getRenderLoading = () => ; -// document.getElementsByTagName('body')[0].style.paddingTop = '100px'; - -// $( 'body *' ).filter(function(){ -// var position = $(this).css('position'); -// var top = $(this).css('top'); -// if((position === 'fixed') && top !== 'auto'){ -// console.log(top); -// $(this).css('top', 'calc(' + top + ' + 100px)'); -// console.log($(this).css('top')); -// }; -// }); - -// document.querySelectorAll('body *').forEach(function(node){ -// var style = window.getComputedStyle(node); -// var position = style.getPropertyValue('position'); -// var top = style.getPropertyValue('top'); -// if((position === 'fixed') && top !== 'auto'){ -// console.log(top); -// node.style.top = 'calc(' + top + ' + 100px)'; -// console.log(node.style.top); -// console.log(node); -// }; -// }); - getJavascriptPadding(padding: number) { return ( - "document.getElementsByTagName('body')[0].style.paddingTop = '" + padding + "px';\n" + + "document.getElementsByTagName('body')[0].style.paddingTop = '" + padding + "px';" + "true;" ); } render() { const {containerPaddingTop, onScrollWithListener} = this.props.collapsibleStack; - const customJS = this.getJavascriptPadding(containerPaddingTop); return ( { this.canGoBack = navState.canGoBack; }} onMessage={this.props.onMessage} + onLoad={() => this.injectJavaScript(this.getJavascriptPadding(containerPaddingTop))} // Animations onScroll={onScrollWithListener(this.props.onScroll)} /> diff --git a/src/screens/Websites/PlanexScreen.js b/src/screens/Websites/PlanexScreen.js index 72fbb9a..5ec9e7e 100644 --- a/src/screens/Websites/PlanexScreen.js +++ b/src/screens/Websites/PlanexScreen.js @@ -204,7 +204,6 @@ class PlanexScreen extends React.Component { 'removeAlpha();' + '});' + EXEC_COMMAND - + "function cc(msg) {alert(msg)};" + 'true;'; // Prevents crash on ios }