有没有办法在 react-native-webview 中禁用 hapticFeedback
Is there any way to disable hapticFeedback in 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>
还有
source.replace(
'<img',
'<img ontouchend="window.ReactNativeWebView.postMessage(`imgsrc__`+this.src)"',
)
所以问题是 当我在 html img 上滚动此滚动视图时,它得到触摸并且 phone 振动。有没有办法从源端(html)或从 react-native-webview 端禁用 webview 触觉反馈?
我认为这是因为在滚动时 img 标签将交互作为 longtouch,因此它在 webview 中启用了 longtouch。
这将禁用对 Webview 的任何触摸,并确保将 pointerEvents 应用于视图,因为 Webview 不支持 pointerEvents。
<ScrollView>
<View pointerEvents="none">
<WebView
style={{ height: HEIGHT, width: WIDTH }}
source={{ getHtml(final, scale) }}
/>
</View>
</ScrollView>
其实我已经找到了解决办法
我确实扩展了 react-native-webview 并添加了一个自定义道具 setHapticFeedbackEnabled
reference
webview.setHapticFeedbackEnabled(false);
// this is the solution in android;
我已经尝试了许多其他方法,例如 window.contextmenu
的 html 脚本,长按等,但 none 有效。
<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>
还有
source.replace(
'<img',
'<img ontouchend="window.ReactNativeWebView.postMessage(`imgsrc__`+this.src)"',
)
所以问题是 当我在 html img 上滚动此滚动视图时,它得到触摸并且 phone 振动。有没有办法从源端(html)或从 react-native-webview 端禁用 webview 触觉反馈?
我认为这是因为在滚动时 img 标签将交互作为 longtouch,因此它在 webview 中启用了 longtouch。
这将禁用对 Webview 的任何触摸,并确保将 pointerEvents 应用于视图,因为 Webview 不支持 pointerEvents。
<ScrollView>
<View pointerEvents="none">
<WebView
style={{ height: HEIGHT, width: WIDTH }}
source={{ getHtml(final, scale) }}
/>
</View>
</ScrollView>
其实我已经找到了解决办法
我确实扩展了 react-native-webview 并添加了一个自定义道具 setHapticFeedbackEnabled reference
webview.setHapticFeedbackEnabled(false);
// this is the solution in android;
我已经尝试了许多其他方法,例如 window.contextmenu
的 html 脚本,长按等,但 none 有效。