iou90 / react-native-autoheight-webview

An auto height webview for React Native
ISC License
494 stars 162 forks source link

How to prevent double-clicking and scrolling? #145

Closed liuyunzyj closed 4 years ago

liuyunzyj commented 4 years ago

<AutoHeightWebView

            style={{ width: deviceWidth}}
            //customScript={`document.body.style.background = 'lightyellow';`}
            customStyle={`
              p {
                font-size: 32px;
              }
            `}
            //  customScript={`document.body.style.background = 'lightyellow';`}
            bounces={false}
            javaScriptEnabled={true}
            source={{ html: getnewsinfo.description }}
            scalesPageToFit={true}
            zoomable={false}
            //onMessage={this.onMessage}
            onLoadProgress={({ nativeEvent }) =>
              this.setState({ progress: nativeEvent.progress })
            }
          />
iou90 commented 4 years ago

The zoomable prop only works on iOS when disable scalesPageToFit.

scalesPageToFit={false}
zoomable={false}
liuyunzyj commented 4 years ago

scalesPageToFit={false}The view cannot hold the width and will display incomplete

liuyunzyj commented 4 years ago

@iou90 How do you get to a normal display that only shows half of the original content

iou90 commented 4 years ago

@liuyunzyj

scalesPageToFit
viewportContent={'width=device-width, user-scalable=no'}

Above codes should work on iOS from v1.4.0. Please note that 'width=device-width' with scalesPageToFit may cause some layout issues on Android, for these conditions, using customScript prop to apply custom viewport meta. FYI: https://github.com/react-native-community/react-native-webview/blob/master/docs/Reference.md#scalespagetofit https://github.com/react-native-community/react-native-webview/blob/5b0c634f15dbf8eb8210d4393da9ca86df1de453/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java

@ReactProp(name = "scalesPageToFit")
  public void setScalesPageToFit(WebView view, boolean enabled) {
    view.getSettings().setLoadWithOverviewMode(enabled);
    view.getSettings().setUseWideViewPort(enabled);
  }

https://developer.android.com/reference/android/webkit/WebSettings.html#setUseWideViewPort(boolean) https://developer.android.com/reference/android/webkit/WebSettings.html#setLoadWithOverviewMode(boolean)