File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { View } from "react-native";
33import { WebView } from "react-native-webview" ;
44
55import { FilePreviewLoading , FilePreviewNotice } from "../features/files/FilePreviewFeedback" ;
6+ import { webViewDecelerationRate } from "../lib/webViewDecelerationRate" ;
67
78export function PdfPreview ( props : { readonly uri : string } ) {
89 const [ error , setError ] = useState < string | null > ( null ) ;
@@ -13,6 +14,7 @@ export function PdfPreview(props: { readonly uri: string }) {
1314 source = { { uri : props . uri } }
1415 originWhitelist = { [ "*" ] }
1516 automaticallyAdjustContentInsets = { false }
17+ decelerationRate = { webViewDecelerationRate }
1618 contentInsetAdjustmentBehavior = "never"
1719 startInLoadingState
1820 onError = { ( event ) =>
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { ControlPill } from "../../components/ui/ControlPill";
1212import { useHardwareBack } from "../../lib/backHandler" ;
1313import { isPdfPreviewUri } from "../../lib/pdfPreview" ;
1414import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics" ;
15+ import { webViewDecelerationRate } from "../../lib/webViewDecelerationRate" ;
1516
1617export function WorkspaceFileWebPreview ( props : { readonly uri : string | null } ) {
1718 if ( props . uri === null ) {
@@ -61,6 +62,7 @@ function DocumentWebPreview(props: { readonly uri: string }) {
6162 source = { { uri : props . uri } }
6263 // react-native-webview defaults to "never", which starts the page under the header.
6364 contentInsetAdjustmentBehavior = "automatic"
65+ decelerationRate = { webViewDecelerationRate }
6466 originWhitelist = { [ "*" ] }
6567 allowsBackForwardNavigationGestures
6668 allowsFullscreenVideo
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { LoadingStrip } from "../../../components/ui/LoadingStrip";
1212import { SymbolView } from "../../../components/ui/AppSymbol" ;
1313import { NativeStackScreenOptions } from "../../../native/StackHeader" ;
1414import { isLegalDocumentUrl , LEGAL_URL } from "../lib/legal-document-url" ;
15+ import { webViewDecelerationRate } from "../../../lib/webViewDecelerationRate" ;
1516
1617export function SettingsLegalDocumentCloseHeaderButton ( ) {
1718 const navigation = useNavigation ( ) ;
@@ -121,6 +122,7 @@ export function SettingsLegalDocumentRouteScreen({
121122 cacheEnabled = { false }
122123 cacheMode = "LOAD_NO_CACHE"
123124 allowsBackForwardNavigationGestures
125+ decelerationRate = { webViewDecelerationRate }
124126 domStorageEnabled = { false }
125127 incognito
126128 javaScriptEnabled = { false }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import { mobileHtmlRenderTheme } from "../../lib/htmlRenderTheme";
1919import { tryOpenExternalUrl } from "../../lib/openExternalUrl" ;
2020import { useAssetUrlState , useRefreshAssetUrl } from "../../state/assets" ;
2121import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider" ;
22+ import { webViewDecelerationRate } from "../../lib/webViewDecelerationRate" ;
2223
2324const ROW_BOTTOM_MARGIN = 8 ;
2425const FULL_SCREEN_GUTTER = 16 ;
@@ -130,6 +131,7 @@ export function HtmlRenderWebView(props: {
130131 showsVerticalScrollIndicator = { ! props . nested }
131132 showsHorizontalScrollIndicator = { ! props . nested }
132133 scrollEnabled = { scrollable }
134+ decelerationRate = { webViewDecelerationRate }
133135 // Patched Android WebView hands vertical drags to the feed at its edges; horizontal-only overflow leaves them to the feed.
134136 nestedScrollEnabled = { props . nested && overflow . y }
135137 overScrollMode = { props . nested ? "never" : "always" }
Original file line number Diff line number Diff line change 1+ import { Platform } from "react-native" ;
2+
3+ // react-native-webview on Fabric leaves an unset rate at 0, which UIKit clamps to "fast"; Android crashes on the string.
4+ export const webViewDecelerationRate = Platform . OS === "ios" ? "normal" : undefined ;
You can’t perform that action at this time.
0 commit comments