Har*_*gra 6 html javascript css react-native react-native-webview
<ScrollView
ref={scrollRef}
horizontal
scrollEnabled={isScroll}
contentContainerStyle={{height: HEIGHT, overflow: 'hidden'}}
style={{
width: metrics.screenWidth - widthOffset,
}}
onScroll={_onScroll}>
<WebView
ref={webviewRef}
automaticallyAdjustContentInsets={false}
scrollEnabled={false}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
onLoadEnd={_loadEnd}
bounces={false}
source={{
html: getHtml(final, scale),
}}
style={{
height: HEIGHT,
width: WIDTH,
backgroundColor: 'transparent',
}}
onMessage={_onMessage}
javaScriptEnabled={true}
textZoom={90}
/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
还有
source.replace(
'<img',
'<img ontouchend="window.ReactNativeWebView.postMessage(`imgsrc__`+this.src)"',
)
Run Code Online (Sandbox Code Playgroud)
所以问题是当我在 html img 上滚动这个滚动视图时,它会得到触摸并且手机会振动。有没有办法从源端(html)或 react-native-webview 端禁用 webview 触觉反馈?
我认为这是因为在滚动 img 标签时将交互视为 longtouch,因此它在 webview 中启用 longtouch。
我实际上已经找到了解决方案
我确实扩展了react-native-webview并添加了自定义道具setHapticFeedbackEnabled 参考
webview.setHapticFeedbackEnabled(false);
// this is the solution in android;
Run Code Online (Sandbox Code Playgroud)
我尝试过许多其他方法,例如在 html 脚本中window.contextmenu长按等,但没有任何效果。
| 归档时间: |
|
| 查看次数: |
388 次 |
| 最近记录: |