@office-iss/react-native-win32 0.71.5 → 0.72.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +15 -3
- package/CHANGELOG.json +302 -47
- package/CHANGELOG.md +141 -27
- package/IntegrationTests/IntegrationTestHarnessTest.js +1 -0
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +1 -1
- package/Libraries/Alert/Alert.d.ts +4 -4
- package/Libraries/Alert/Alert.win32.js +1 -0
- package/Libraries/Animated/Animated.d.ts +17 -6
- package/Libraries/Animated/NativeAnimatedHelper.js +18 -6
- package/Libraries/Animated/NativeAnimatedHelper.win32.js +606 -0
- package/Libraries/Animated/bezier.js +1 -1
- package/Libraries/Animated/components/AnimatedFlatList.js +8 -3
- package/Libraries/Animated/components/AnimatedScrollView.js +4 -1
- package/Libraries/Animated/components/AnimatedSectionList.js +12 -3
- package/Libraries/Animated/createAnimatedComponent.js +26 -239
- package/Libraries/Animated/nodes/AnimatedColor.js +47 -80
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +167 -121
- package/Libraries/Animated/nodes/AnimatedNode.js +3 -5
- package/Libraries/Animated/nodes/AnimatedProps.js +7 -6
- package/Libraries/Animated/nodes/AnimatedStyle.js +42 -8
- package/Libraries/Animated/nodes/AnimatedTransform.js +1 -1
- package/Libraries/Animated/nodes/AnimatedValue.js +8 -12
- package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -1
- package/Libraries/Animated/useAnimatedProps.js +7 -10
- package/Libraries/BatchedBridge/MessageQueue.js +2 -1
- package/Libraries/BatchedBridge/NativeModules.d.ts +1 -1
- package/Libraries/BatchedBridge/NativeModules.js +1 -0
- package/Libraries/Blob/Blob.js +4 -0
- package/Libraries/Blob/FileReader.js +30 -2
- package/Libraries/Blob/URL.js +3 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +2 -2
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -3
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -3
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +6 -4
- package/Libraries/Components/Button.js +3 -2
- package/Libraries/Components/Button.win32.js +451 -0
- package/Libraries/Components/Clipboard/Clipboard.js +1 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -0
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -0
- package/Libraries/Components/Pressable/Pressable.d.ts +1 -1
- package/Libraries/Components/Pressable/Pressable.js +1 -1
- package/Libraries/Components/RefreshControl/RefreshControl.js +1 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +1 -2
- package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +1 -2
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +12 -6
- package/Libraries/Components/ScrollView/ScrollView.d.ts +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +149 -91
- package/Libraries/Components/ScrollView/ScrollView.win32.js +1939 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +16 -6
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +5 -7
- package/Libraries/Components/ScrollView/ScrollViewViewConfig.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +3 -0
- package/Libraries/Components/Switch/Switch.js +3 -1
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +21 -11
- package/Libraries/Components/TextInput/InputAccessoryView.d.ts +1 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +11 -5
- package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +51 -0
- package/Libraries/Components/TextInput/TextInput.Types.win32.js +3 -0
- package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +1 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +15 -5
- package/Libraries/Components/TextInput/TextInput.flow.js +1 -1
- package/Libraries/Components/TextInput/TextInput.js +130 -103
- package/Libraries/Components/TextInput/TextInput.win32.js +202 -890
- package/Libraries/Components/Touchable/Touchable.d.ts +1 -1
- package/Libraries/Components/Touchable/Touchable.flow.js +30 -4
- package/Libraries/Components/Touchable/Touchable.js +6 -3
- package/Libraries/Components/Touchable/Touchable.win32.js +6 -3
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +2 -2
- package/Libraries/Components/Touchable/TouchableOpacity.js +3 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
- package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +189 -0
- package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlayNativeComponent.js +43 -0
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +26 -0
- package/Libraries/Components/View/View.js +71 -45
- package/Libraries/Components/View/View.win32.js +38 -16
- package/Libraries/Components/View/ViewAccessibility.d.ts +6 -6
- package/Libraries/Components/View/ViewAccessibility.js +10 -1
- package/Libraries/Components/View/ViewAccessibility.win32.d.ts +5 -5
- package/Libraries/Components/View/ViewNativeComponent.js +32 -8
- package/Libraries/Components/View/ViewPropTypes.d.ts +1 -1
- package/Libraries/Components/View/ViewPropTypes.js +1 -1
- package/Libraries/Components/View/ViewPropTypes.win32.d.ts +1 -1
- package/Libraries/Components/View/ViewPropTypes.win32.js +1 -1
- package/Libraries/Components/View/ViewWin32.js +3 -3
- package/Libraries/Core/Devtools/openFileInEditor.js +1 -0
- package/Libraries/Core/Devtools/openURLInBrowser.js +1 -0
- package/Libraries/Core/Devtools/parseErrorStack.js +2 -2
- package/Libraries/Core/Devtools/parseHermesStack.js +54 -34
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/InitializeCore.js +2 -1
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/ReactNativeVersionCheck.js +1 -9
- package/Libraries/Core/ReactNativeVersionCheck.win32.js +1 -9
- package/Libraries/Core/Timers/JSTimers.js +1 -1
- package/Libraries/Core/Timers/immediateShim.js +1 -0
- package/Libraries/Core/Timers/queueMicrotask.js +1 -1
- package/Libraries/Core/setUpAlert.js +1 -1
- package/Libraries/Core/setUpDOM.js +18 -0
- package/Libraries/Core/setUpDeveloperTools.js +1 -1
- package/Libraries/Core/setUpGlobals.js +5 -2
- package/Libraries/Core/setUpNavigator.js +6 -5
- package/Libraries/Core/setUpPerformance.js +23 -13
- package/Libraries/Core/setUpReactDevTools.js +2 -0
- package/Libraries/Core/setUpSegmentFetcher.js +0 -41
- package/Libraries/Core/setUpTimers.js +2 -2
- package/Libraries/DOM/Geometry/DOMRect.js +82 -0
- package/Libraries/DOM/Geometry/DOMRectReadOnly.js +188 -0
- package/Libraries/DOM/Nodes/ReactNativeElement.js +75 -0
- package/Libraries/DOM/Nodes/ReadOnlyElement.js +89 -0
- package/Libraries/DOM/Nodes/ReadOnlyNode.js +167 -0
- package/Libraries/DOM/OldStyleCollections/ArrayLikeUtils.js +46 -0
- package/Libraries/DOM/OldStyleCollections/DOMRectList.js +76 -0
- package/Libraries/DOM/OldStyleCollections/HTMLCollection.js +82 -0
- package/Libraries/DOM/OldStyleCollections/NodeList.js +104 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.android.js +35 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.d.ts +20 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.ios.js +49 -0
- package/Libraries/DevToolsSettings/DevToolsSettingsManager.win32.js +35 -0
- package/Libraries/{Utilities/NativeDevSplitBundleLoader.js → DevToolsSettings/NativeDevToolsSettingsManager.js} +7 -2
- package/Libraries/EventEmitter/NativeEventEmitter.d.ts +1 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.d.ts +1 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +9 -1
- package/Libraries/Events/EventPolyfill.js +1 -1
- package/Libraries/Image/AssetRegistry.js +1 -1
- package/Libraries/Image/AssetSourceResolver.js +3 -3
- package/Libraries/Image/Image.android.js +4 -1
- package/Libraries/Image/Image.d.ts +63 -2
- package/Libraries/Image/Image.ios.js +3 -0
- package/Libraries/Image/Image.win32.js +3 -0
- package/Libraries/Image/ImageBackground.js +1 -0
- package/Libraries/Image/ImageProps.js +1 -1
- package/Libraries/Image/ImageViewNativeComponent.js +4 -4
- package/Libraries/Image/RelativeImageStub.js +1 -1
- package/Libraries/Image/TextInlineImageNativeComponent.js +1 -1
- package/Libraries/Image/resolveAssetSource.js +1 -1
- package/Libraries/Inspector/DevtoolsOverlay.js +29 -19
- package/Libraries/Inspector/ElementBox.js +4 -1
- package/Libraries/Inspector/Inspector.js +5 -6
- package/Libraries/Inspector/Inspector.win32.js +7 -6
- package/Libraries/Inspector/InspectorOverlay.js +3 -3
- package/Libraries/Inspector/InspectorOverlay.win32.js +2 -1
- package/Libraries/Inspector/NetworkOverlay.js +1 -1
- package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -1
- package/Libraries/Interaction/PanResponder.js +5 -6
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -1
- package/Libraries/Linking/Linking.js +1 -4
- package/Libraries/Lists/FillRateHelper.js +4 -238
- package/Libraries/Lists/FlatList.d.ts +15 -22
- package/Libraries/Lists/FlatList.js +9 -6
- package/Libraries/Lists/SectionList.d.ts +10 -6
- package/Libraries/Lists/SectionList.js +5 -3
- package/Libraries/Lists/SectionListModern.js +3 -3
- package/Libraries/Lists/ViewabilityHelper.js +8 -344
- package/Libraries/Lists/VirtualizeUtils.js +4 -244
- package/Libraries/Lists/VirtualizedList.js +10 -1867
- package/Libraries/Lists/VirtualizedListContext.js +6 -104
- package/Libraries/Lists/VirtualizedSectionList.js +9 -602
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +1 -0
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/LogBox.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspector.js +1 -3
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +168 -0
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +3 -0
- package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +193 -0
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -0
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +7 -3
- package/Libraries/LogBox/UI/LogBoxMessage.js +87 -5
- package/Libraries/LogBox/UI/LogBoxNotification.js +5 -7
- package/Libraries/Modal/Modal.js +2 -2
- package/Libraries/NativeComponent/BaseViewConfig.android.js +32 -12
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +43 -19
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +43 -19
- package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +4 -1
- package/Libraries/NativeComponent/ViewConfig.js +1 -0
- package/Libraries/NativeComponent/ViewConfigIgnore.js +1 -4
- package/Libraries/Network/RCTNetworking.android.js +2 -2
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +1 -1
- package/Libraries/Pressability/Pressability.js +11 -5
- package/Libraries/Pressability/Pressability.win32.js +9 -3
- package/Libraries/ReactNative/AppContainer.js +7 -1
- package/Libraries/ReactNative/AppRegistry.d.ts +1 -1
- package/Libraries/ReactNative/AppRegistry.js +10 -13
- package/Libraries/ReactNative/FabricUIManager.js +24 -8
- package/Libraries/ReactNative/NativeUIManager.js +5 -5
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +10 -10
- package/Libraries/ReactNative/UIManager.js +142 -1
- package/Libraries/ReactNative/getCachedComponentWithDebugName.js +5 -5
- package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -1
- package/Libraries/ReactNative/requireNativeComponent.d.ts +1 -1
- package/Libraries/ReactNative/requireNativeComponent.js +1 -1
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +26 -3
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +13 -1
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +13 -1
- package/Libraries/Renderer/public/ReactFabricPublicInstanceUtils.js +38 -0
- package/Libraries/Renderer/shims/ReactNativeTypes.js +38 -20
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +7 -7
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -2
- package/Libraries/Share/Share.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.win32.js +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +115 -76
- package/Libraries/StyleSheet/StyleSheetTypes.js +188 -33
- package/Libraries/StyleSheet/flattenStyle.js +2 -0
- package/Libraries/StyleSheet/normalizeColor.js +1 -1
- package/Libraries/StyleSheet/processColor.js +1 -1
- package/Libraries/Text/Text.d.ts +12 -2
- package/Libraries/Text/Text.js +50 -41
- package/Libraries/Text/TextProps.js +3 -4
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
- package/Libraries/Types/CodegenTypes.js +1 -0
- package/Libraries/UTFSequence.js +3 -1
- package/Libraries/Utilities/Appearance.d.ts +10 -0
- package/Libraries/Utilities/Appearance.js +13 -0
- package/Libraries/Utilities/Dimensions.js +1 -1
- package/Libraries/Utilities/Dimensions.win32.js +1 -1
- package/Libraries/Utilities/GlobalPerformanceLogger.js +12 -1
- package/Libraries/Utilities/HMRClient.js +16 -10
- package/Libraries/Utilities/{createPerformanceLogger.d.ts → IPerformanceLogger.d.ts} +4 -4
- package/Libraries/Utilities/IPerformanceLogger.js +49 -0
- package/Libraries/Utilities/LoadingView.android.js +28 -11
- package/Libraries/Utilities/NativeAppearance.js +1 -0
- package/Libraries/Utilities/NativePlatformConstantsWin.js +1 -1
- package/Libraries/Utilities/PixelRatio.js +2 -2
- package/Libraries/Utilities/Platform.win32.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
- package/Libraries/Utilities/__mocks__/PixelRatio.js +1 -1
- package/Libraries/Utilities/codegenNativeCommands.js +2 -0
- package/Libraries/Utilities/createPerformanceLogger.js +55 -43
- package/Libraries/Utilities/stringifySafe.js +2 -7
- package/Libraries/Utilities/useColorScheme.js +1 -1
- package/Libraries/Utilities/useWindowDimensions.js +3 -3
- package/Libraries/WebPerformance/EventCounts.js +78 -0
- package/Libraries/WebPerformance/MemoryInfo.js +54 -0
- package/Libraries/WebPerformance/NativePerformance.js +38 -0
- package/Libraries/WebPerformance/NativePerformanceObserver.js +22 -7
- package/Libraries/WebPerformance/Performance.js +312 -0
- package/Libraries/WebPerformance/PerformanceEntry.js +45 -0
- package/Libraries/WebPerformance/PerformanceEventTiming.js +38 -0
- package/Libraries/WebPerformance/PerformanceObserver.js +196 -101
- package/Libraries/WebPerformance/RawPerformanceEntry.js +87 -0
- package/Libraries/WebPerformance/ReactNativeStartupTiming.js +65 -0
- package/Libraries/WebPerformance/__mocks__/NativePerformance.js +65 -0
- package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +101 -0
- package/Libraries/YellowBox/YellowBoxDeprecated.js +1 -1
- package/Libraries/vendor/core/ErrorUtils.js +1 -1
- package/Libraries/vendor/emitter/EventEmitter.d.ts +2 -2
- package/Libraries/vendor/emitter/EventEmitter.js +9 -1
- package/flow/global.js +29 -4
- package/flow/jest.js +258 -164
- package/index.js +56 -42
- package/index.win32.js +56 -42
- package/interface.js +1 -1
- package/jest/local-setup.js +33 -0
- package/jest/mockComponent.js +4 -2
- package/jest/mockNativeComponent.js +1 -1
- package/jest/mockScrollView.js +2 -1
- package/jest/react-native-env.js +1 -3
- package/jest/setup.js +11 -8
- package/overrides.json +115 -85
- package/package.json +38 -28
- package/rn-get-polyfills.js +1 -1
- package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +68 -0
- package/src/Libraries/Components/View/ViewAccessibility.win32.d.ts +5 -5
- package/src/Libraries/Components/View/ViewPropTypes.win32.d.ts +1 -1
- package/types/index.d.ts +2 -6
- package/types/modules/Codegen.d.ts +4 -4
- package/types/modules/globals.d.ts +27 -25
- package/types/public/DeprecatedPropertiesAlias.d.ts +0 -20
- package/types/public/ReactNativeRenderer.d.ts +2 -7
- package/Libraries/Animated/createAnimatedComponentInjection.js +0 -48
- package/Libraries/Animated/createAnimatedComponent_EXPERIMENTAL.js +0 -48
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.flow.js +0 -208
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.flow.js +0 -58
- package/Libraries/Components/DatePicker/DatePickerIOS.android.js +0 -47
- package/Libraries/Components/DatePicker/DatePickerIOS.d.ts +0 -92
- package/Libraries/Components/DatePicker/DatePickerIOS.flow.android.js +0 -14
- package/Libraries/Components/DatePicker/DatePickerIOS.flow.ios.js +0 -113
- package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +0 -242
- package/Libraries/Components/DatePicker/DatePickerIOS.win32.js +0 -47
- package/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js +0 -60
- package/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +0 -26
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.android.js +0 -45
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.d.ts +0 -62
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.ios.js +0 -75
- package/Libraries/Components/ProgressViewIOS/ProgressViewIOS.win32.js +0 -45
- package/Libraries/Components/ProgressViewIOS/RCTProgressViewNativeComponent.js +0 -33
- package/Libraries/Components/SafeAreaView/SafeAreaView.flow.js +0 -19
- package/Libraries/Components/Slider/Slider.d.ts +0 -132
- package/Libraries/Components/Slider/Slider.js +0 -282
- package/Libraries/Components/Slider/SliderNativeComponent.js +0 -56
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +0 -23
- package/Libraries/Interaction/Batchinator.js +0 -76
- package/Libraries/Interaction/BridgeSpyStallHandler.js +0 -63
- package/Libraries/Interaction/InteractionStallDebugger.js +0 -23
- package/Libraries/Interaction/PanResponder.flow.js +0 -257
- package/Libraries/Lists/CellRenderMask.js +0 -155
- package/Libraries/Lists/ChildListCollection.js +0 -72
- package/Libraries/Lists/StateSafePureComponent.js +0 -85
- package/Libraries/Lists/VirtualizedList.d.ts +0 -347
- package/Libraries/Lists/VirtualizedListCellRenderer.js +0 -259
- package/Libraries/Lists/VirtualizedListProps.js +0 -279
- package/Libraries/Performance/PureComponentDebug.js +0 -74
- package/Libraries/Reliability/UserFlow.js +0 -158
- package/Libraries/Renderer/implementations/ReactNativeRenderer.d.ts +0 -149
- package/Libraries/Renderer/shims/ReactNativeTypes.d.ts +0 -141
- package/Libraries/Utilities/MatrixMath.js +0 -748
- package/Libraries/Utilities/buildStyleInterpolator.js +0 -209
- package/Libraries/Utilities/clamp.js +0 -23
- package/Libraries/Utilities/deprecatedPropType.js +0 -36
- package/Libraries/Utilities/groupByEveryN.js +0 -51
- package/Libraries/Utilities/mergeIntoFast.js +0 -26
- package/Libraries/Utilities/setAndForwardRef.js +0 -71
- package/Libraries/Utilities/truncate.js +0 -51
- package/flow/JSITimerInternalType.js +0 -30
- package/flow/use-sync-external-store.js +0 -19
|
@@ -8,1873 +8,16 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
import type {ViewStyleProp} from '../StyleSheet/StyleSheet';
|
|
13
|
-
import type {LayoutEvent, ScrollEvent} from '../Types/CoreEventTypes';
|
|
14
|
-
import type {ViewToken} from './ViewabilityHelper';
|
|
15
|
-
import type {
|
|
16
|
-
FrameMetricProps,
|
|
17
|
-
Item,
|
|
18
|
-
Props,
|
|
19
|
-
RenderItemProps,
|
|
20
|
-
RenderItemType,
|
|
21
|
-
Separators,
|
|
22
|
-
} from './VirtualizedListProps';
|
|
23
|
-
|
|
24
|
-
import RefreshControl from '../Components/RefreshControl/RefreshControl';
|
|
25
|
-
import ScrollView from '../Components/ScrollView/ScrollView';
|
|
26
|
-
import View from '../Components/View/View';
|
|
27
|
-
import Batchinator from '../Interaction/Batchinator';
|
|
28
|
-
import {findNodeHandle} from '../ReactNative/RendererProxy';
|
|
29
|
-
import flattenStyle from '../StyleSheet/flattenStyle';
|
|
30
|
-
import StyleSheet from '../StyleSheet/StyleSheet';
|
|
31
|
-
import clamp from '../Utilities/clamp';
|
|
32
|
-
import infoLog from '../Utilities/infoLog';
|
|
33
|
-
import {CellRenderMask} from './CellRenderMask';
|
|
34
|
-
import ChildListCollection from './ChildListCollection';
|
|
35
|
-
import FillRateHelper from './FillRateHelper';
|
|
36
|
-
import StateSafePureComponent from './StateSafePureComponent';
|
|
37
|
-
import ViewabilityHelper from './ViewabilityHelper';
|
|
38
|
-
import CellRenderer from './VirtualizedListCellRenderer';
|
|
39
|
-
import {
|
|
40
|
-
VirtualizedListCellContextProvider,
|
|
41
|
-
VirtualizedListContext,
|
|
42
|
-
VirtualizedListContextProvider,
|
|
43
|
-
} from './VirtualizedListContext.js';
|
|
44
|
-
import {
|
|
45
|
-
computeWindowedRenderLimits,
|
|
46
|
-
keyExtractor as defaultKeyExtractor,
|
|
47
|
-
} from './VirtualizeUtils';
|
|
48
|
-
import invariant from 'invariant';
|
|
49
|
-
import * as React from 'react';
|
|
50
|
-
|
|
51
|
-
export type {RenderItemProps, RenderItemType, Separators};
|
|
52
|
-
|
|
53
|
-
const ON_END_REACHED_EPSILON = 0.001;
|
|
54
|
-
|
|
55
|
-
let _usedIndexForKey = false;
|
|
56
|
-
let _keylessItemComponentName: string = '';
|
|
57
|
-
|
|
58
|
-
type ViewabilityHelperCallbackTuple = {
|
|
59
|
-
viewabilityHelper: ViewabilityHelper,
|
|
60
|
-
onViewableItemsChanged: (info: {
|
|
61
|
-
viewableItems: Array<ViewToken>,
|
|
62
|
-
changed: Array<ViewToken>,
|
|
63
|
-
...
|
|
64
|
-
}) => void,
|
|
65
|
-
...
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
type State = {
|
|
69
|
-
renderMask: CellRenderMask,
|
|
70
|
-
cellsAroundViewport: {first: number, last: number},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Default Props Helper Functions
|
|
75
|
-
* Use the following helper functions for default values
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
// horizontalOrDefault(this.props.horizontal)
|
|
79
|
-
function horizontalOrDefault(horizontal: ?boolean) {
|
|
80
|
-
return horizontal ?? false;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// initialNumToRenderOrDefault(this.props.initialNumToRenderOrDefault)
|
|
84
|
-
function initialNumToRenderOrDefault(initialNumToRender: ?number) {
|
|
85
|
-
return initialNumToRender ?? 10;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// maxToRenderPerBatchOrDefault(this.props.maxToRenderPerBatch)
|
|
89
|
-
function maxToRenderPerBatchOrDefault(maxToRenderPerBatch: ?number) {
|
|
90
|
-
return maxToRenderPerBatch ?? 10;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// onEndReachedThresholdOrDefault(this.props.onEndReachedThreshold)
|
|
94
|
-
function onEndReachedThresholdOrDefault(onEndReachedThreshold: ?number) {
|
|
95
|
-
return onEndReachedThreshold ?? 2;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// scrollEventThrottleOrDefault(this.props.scrollEventThrottle)
|
|
99
|
-
function scrollEventThrottleOrDefault(scrollEventThrottle: ?number) {
|
|
100
|
-
return scrollEventThrottle ?? 50;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// windowSizeOrDefault(this.props.windowSize)
|
|
104
|
-
function windowSizeOrDefault(windowSize: ?number) {
|
|
105
|
-
return windowSize ?? 21;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function findLastWhere<T>(
|
|
109
|
-
arr: $ReadOnlyArray<T>,
|
|
110
|
-
predicate: (element: T) => boolean,
|
|
111
|
-
): T | null {
|
|
112
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
113
|
-
if (predicate(arr[i])) {
|
|
114
|
-
return arr[i];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist)
|
|
123
|
-
* and [`<SectionList>`](https://reactnative.dev/docs/sectionlist) components, which are also better
|
|
124
|
-
* documented. In general, this should only really be used if you need more flexibility than
|
|
125
|
-
* `FlatList` provides, e.g. for use with immutable data instead of plain arrays.
|
|
126
|
-
*
|
|
127
|
-
* Virtualization massively improves memory consumption and performance of large lists by
|
|
128
|
-
* maintaining a finite render window of active items and replacing all items outside of the render
|
|
129
|
-
* window with appropriately sized blank space. The window adapts to scrolling behavior, and items
|
|
130
|
-
* are rendered incrementally with low-pri (after any running interactions) if they are far from the
|
|
131
|
-
* visible area, or with hi-pri otherwise to minimize the potential of seeing blank space.
|
|
132
|
-
*
|
|
133
|
-
* Some caveats:
|
|
134
|
-
*
|
|
135
|
-
* - Internal state is not preserved when content scrolls out of the render window. Make sure all
|
|
136
|
-
* your data is captured in the item data or external stores like Flux, Redux, or Relay.
|
|
137
|
-
* - This is a `PureComponent` which means that it will not re-render if `props` remain shallow-
|
|
138
|
-
* equal. Make sure that everything your `renderItem` function depends on is passed as a prop
|
|
139
|
-
* (e.g. `extraData`) that is not `===` after updates, otherwise your UI may not update on
|
|
140
|
-
* changes. This includes the `data` prop and parent component state.
|
|
141
|
-
* - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously
|
|
142
|
-
* offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
|
|
143
|
-
* blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
|
|
144
|
-
* and we are working on improving it behind the scenes.
|
|
145
|
-
* - By default, the list looks for a `key` or `id` prop on each item and uses that for the React key.
|
|
146
|
-
* Alternatively, you can provide a custom `keyExtractor` prop.
|
|
147
|
-
* - As an effort to remove defaultProps, use helper functions when referencing certain props
|
|
148
|
-
*
|
|
149
|
-
*/
|
|
150
|
-
export default class VirtualizedList extends StateSafePureComponent<
|
|
151
|
-
Props,
|
|
152
|
-
State,
|
|
153
|
-
> {
|
|
154
|
-
static contextType: typeof VirtualizedListContext = VirtualizedListContext;
|
|
155
|
-
|
|
156
|
-
// scrollToEnd may be janky without getItemLayout prop
|
|
157
|
-
scrollToEnd(params?: ?{animated?: ?boolean, ...}) {
|
|
158
|
-
const animated = params ? params.animated : true;
|
|
159
|
-
const veryLast = this.props.getItemCount(this.props.data) - 1;
|
|
160
|
-
const frame = this.__getFrameMetricsApprox(veryLast, this.props);
|
|
161
|
-
const offset = Math.max(
|
|
162
|
-
0,
|
|
163
|
-
frame.offset +
|
|
164
|
-
frame.length +
|
|
165
|
-
this._footerLength -
|
|
166
|
-
this._scrollMetrics.visibleLength,
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
if (this._scrollRef == null) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (this._scrollRef.scrollTo == null) {
|
|
174
|
-
console.warn(
|
|
175
|
-
'No scrollTo method provided. This may be because you have two nested ' +
|
|
176
|
-
'VirtualizedLists with the same orientation, or because you are ' +
|
|
177
|
-
'using a custom component that does not implement scrollTo.',
|
|
178
|
-
);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this._scrollRef.scrollTo(
|
|
183
|
-
horizontalOrDefault(this.props.horizontal)
|
|
184
|
-
? {x: offset, animated}
|
|
185
|
-
: {y: offset, animated},
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// scrollToIndex may be janky without getItemLayout prop
|
|
190
|
-
scrollToIndex(params: {
|
|
191
|
-
animated?: ?boolean,
|
|
192
|
-
index: number,
|
|
193
|
-
viewOffset?: number,
|
|
194
|
-
viewPosition?: number,
|
|
195
|
-
...
|
|
196
|
-
}): $FlowFixMe {
|
|
197
|
-
const {
|
|
198
|
-
data,
|
|
199
|
-
horizontal,
|
|
200
|
-
getItemCount,
|
|
201
|
-
getItemLayout,
|
|
202
|
-
onScrollToIndexFailed,
|
|
203
|
-
} = this.props;
|
|
204
|
-
const {animated, index, viewOffset, viewPosition} = params;
|
|
205
|
-
invariant(
|
|
206
|
-
index >= 0,
|
|
207
|
-
`scrollToIndex out of range: requested index ${index} but minimum is 0`,
|
|
208
|
-
);
|
|
209
|
-
invariant(
|
|
210
|
-
getItemCount(data) >= 1,
|
|
211
|
-
`scrollToIndex out of range: item length ${getItemCount(
|
|
212
|
-
data,
|
|
213
|
-
)} but minimum is 1`,
|
|
214
|
-
);
|
|
215
|
-
invariant(
|
|
216
|
-
index < getItemCount(data),
|
|
217
|
-
`scrollToIndex out of range: requested index ${index} is out of 0 to ${
|
|
218
|
-
getItemCount(data) - 1
|
|
219
|
-
}`,
|
|
220
|
-
);
|
|
221
|
-
if (!getItemLayout && index > this._highestMeasuredFrameIndex) {
|
|
222
|
-
invariant(
|
|
223
|
-
!!onScrollToIndexFailed,
|
|
224
|
-
'scrollToIndex should be used in conjunction with getItemLayout or onScrollToIndexFailed, ' +
|
|
225
|
-
'otherwise there is no way to know the location of offscreen indices or handle failures.',
|
|
226
|
-
);
|
|
227
|
-
onScrollToIndexFailed({
|
|
228
|
-
averageItemLength: this._averageCellLength,
|
|
229
|
-
highestMeasuredFrameIndex: this._highestMeasuredFrameIndex,
|
|
230
|
-
index,
|
|
231
|
-
});
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const frame = this.__getFrameMetricsApprox(Math.floor(index), this.props);
|
|
235
|
-
const offset =
|
|
236
|
-
Math.max(
|
|
237
|
-
0,
|
|
238
|
-
this._getOffsetApprox(index, this.props) -
|
|
239
|
-
(viewPosition || 0) *
|
|
240
|
-
(this._scrollMetrics.visibleLength - frame.length),
|
|
241
|
-
) - (viewOffset || 0);
|
|
242
|
-
|
|
243
|
-
if (this._scrollRef == null) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (this._scrollRef.scrollTo == null) {
|
|
248
|
-
console.warn(
|
|
249
|
-
'No scrollTo method provided. This may be because you have two nested ' +
|
|
250
|
-
'VirtualizedLists with the same orientation, or because you are ' +
|
|
251
|
-
'using a custom component that does not implement scrollTo.',
|
|
252
|
-
);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
this._scrollRef.scrollTo(
|
|
257
|
-
horizontal ? {x: offset, animated} : {y: offset, animated},
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// scrollToItem may be janky without getItemLayout prop. Required linear scan through items -
|
|
262
|
-
// use scrollToIndex instead if possible.
|
|
263
|
-
scrollToItem(params: {
|
|
264
|
-
animated?: ?boolean,
|
|
265
|
-
item: Item,
|
|
266
|
-
viewOffset?: number,
|
|
267
|
-
viewPosition?: number,
|
|
268
|
-
...
|
|
269
|
-
}) {
|
|
270
|
-
const {item} = params;
|
|
271
|
-
const {data, getItem, getItemCount} = this.props;
|
|
272
|
-
const itemCount = getItemCount(data);
|
|
273
|
-
for (let index = 0; index < itemCount; index++) {
|
|
274
|
-
if (getItem(data, index) === item) {
|
|
275
|
-
this.scrollToIndex({...params, index});
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Scroll to a specific content pixel offset in the list.
|
|
283
|
-
*
|
|
284
|
-
* Param `offset` expects the offset to scroll to.
|
|
285
|
-
* In case of `horizontal` is true, the offset is the x-value,
|
|
286
|
-
* in any other case the offset is the y-value.
|
|
287
|
-
*
|
|
288
|
-
* Param `animated` (`true` by default) defines whether the list
|
|
289
|
-
* should do an animation while scrolling.
|
|
290
|
-
*/
|
|
291
|
-
scrollToOffset(params: {animated?: ?boolean, offset: number, ...}) {
|
|
292
|
-
const {animated, offset} = params;
|
|
293
|
-
|
|
294
|
-
if (this._scrollRef == null) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (this._scrollRef.scrollTo == null) {
|
|
299
|
-
console.warn(
|
|
300
|
-
'No scrollTo method provided. This may be because you have two nested ' +
|
|
301
|
-
'VirtualizedLists with the same orientation, or because you are ' +
|
|
302
|
-
'using a custom component that does not implement scrollTo.',
|
|
303
|
-
);
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
this._scrollRef.scrollTo(
|
|
308
|
-
horizontalOrDefault(this.props.horizontal)
|
|
309
|
-
? {x: offset, animated}
|
|
310
|
-
: {y: offset, animated},
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
recordInteraction() {
|
|
315
|
-
this._nestedChildLists.forEach(childList => {
|
|
316
|
-
childList.recordInteraction();
|
|
317
|
-
});
|
|
318
|
-
this._viewabilityTuples.forEach(t => {
|
|
319
|
-
t.viewabilityHelper.recordInteraction();
|
|
320
|
-
});
|
|
321
|
-
this._updateViewableItems(this.props, this.state.cellsAroundViewport);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
flashScrollIndicators() {
|
|
325
|
-
if (this._scrollRef == null) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
this._scrollRef.flashScrollIndicators();
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Provides a handle to the underlying scroll responder.
|
|
334
|
-
* Note that `this._scrollRef` might not be a `ScrollView`, so we
|
|
335
|
-
* need to check that it responds to `getScrollResponder` before calling it.
|
|
336
|
-
*/
|
|
337
|
-
getScrollResponder(): ?ScrollResponderType {
|
|
338
|
-
if (this._scrollRef && this._scrollRef.getScrollResponder) {
|
|
339
|
-
return this._scrollRef.getScrollResponder();
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
getScrollableNode(): ?number {
|
|
344
|
-
if (this._scrollRef && this._scrollRef.getScrollableNode) {
|
|
345
|
-
return this._scrollRef.getScrollableNode();
|
|
346
|
-
} else {
|
|
347
|
-
return findNodeHandle(this._scrollRef);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
getScrollRef():
|
|
352
|
-
| ?React.ElementRef<typeof ScrollView>
|
|
353
|
-
| ?React.ElementRef<typeof View> {
|
|
354
|
-
if (this._scrollRef && this._scrollRef.getScrollRef) {
|
|
355
|
-
return this._scrollRef.getScrollRef();
|
|
356
|
-
} else {
|
|
357
|
-
return this._scrollRef;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
setNativeProps(props: Object) {
|
|
362
|
-
if (this._scrollRef) {
|
|
363
|
-
this._scrollRef.setNativeProps(props);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
_getCellKey(): string {
|
|
368
|
-
return this.context?.cellKey || 'rootList';
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// $FlowFixMe[missing-local-annot]
|
|
372
|
-
_getScrollMetrics = () => {
|
|
373
|
-
return this._scrollMetrics;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
hasMore(): boolean {
|
|
377
|
-
return this._hasMore;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// $FlowFixMe[missing-local-annot]
|
|
381
|
-
_getOutermostParentListRef = () => {
|
|
382
|
-
if (this._isNestedWithSameOrientation()) {
|
|
383
|
-
return this.context.getOutermostParentListRef();
|
|
384
|
-
} else {
|
|
385
|
-
return this;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
_registerAsNestedChild = (childList: {
|
|
390
|
-
cellKey: string,
|
|
391
|
-
ref: React.ElementRef<typeof VirtualizedList>,
|
|
392
|
-
}): void => {
|
|
393
|
-
this._nestedChildLists.add(childList.ref, childList.cellKey);
|
|
394
|
-
if (this._hasInteracted) {
|
|
395
|
-
childList.ref.recordInteraction();
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
_unregisterAsNestedChild = (childList: {
|
|
400
|
-
ref: React.ElementRef<typeof VirtualizedList>,
|
|
401
|
-
}): void => {
|
|
402
|
-
this._nestedChildLists.remove(childList.ref);
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
state: State;
|
|
406
|
-
|
|
407
|
-
constructor(props: Props) {
|
|
408
|
-
super(props);
|
|
409
|
-
invariant(
|
|
410
|
-
// $FlowFixMe[prop-missing]
|
|
411
|
-
!props.onScroll || !props.onScroll.__isNative,
|
|
412
|
-
'Components based on VirtualizedList must be wrapped with Animated.createAnimatedComponent ' +
|
|
413
|
-
'to support native onScroll events with useNativeDriver',
|
|
414
|
-
);
|
|
415
|
-
invariant(
|
|
416
|
-
windowSizeOrDefault(props.windowSize) > 0,
|
|
417
|
-
'VirtualizedList: The windowSize prop must be present and set to a value greater than 0.',
|
|
418
|
-
);
|
|
419
|
-
|
|
420
|
-
invariant(
|
|
421
|
-
props.getItemCount,
|
|
422
|
-
'VirtualizedList: The "getItemCount" prop must be provided',
|
|
423
|
-
);
|
|
424
|
-
|
|
425
|
-
this._fillRateHelper = new FillRateHelper(this._getFrameMetrics);
|
|
426
|
-
this._updateCellsToRenderBatcher = new Batchinator(
|
|
427
|
-
this._updateCellsToRender,
|
|
428
|
-
this.props.updateCellsBatchingPeriod ?? 50,
|
|
429
|
-
);
|
|
430
|
-
|
|
431
|
-
if (this.props.viewabilityConfigCallbackPairs) {
|
|
432
|
-
this._viewabilityTuples = this.props.viewabilityConfigCallbackPairs.map(
|
|
433
|
-
pair => ({
|
|
434
|
-
viewabilityHelper: new ViewabilityHelper(pair.viewabilityConfig),
|
|
435
|
-
onViewableItemsChanged: pair.onViewableItemsChanged,
|
|
436
|
-
}),
|
|
437
|
-
);
|
|
438
|
-
} else {
|
|
439
|
-
const {onViewableItemsChanged, viewabilityConfig} = this.props;
|
|
440
|
-
if (onViewableItemsChanged) {
|
|
441
|
-
this._viewabilityTuples.push({
|
|
442
|
-
viewabilityHelper: new ViewabilityHelper(viewabilityConfig),
|
|
443
|
-
onViewableItemsChanged: onViewableItemsChanged,
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
invariant(
|
|
449
|
-
!this.context,
|
|
450
|
-
'Unexpectedly saw VirtualizedListContext available in ctor',
|
|
451
|
-
);
|
|
452
|
-
|
|
453
|
-
const initialRenderRegion = VirtualizedList._initialRenderRegion(props);
|
|
454
|
-
|
|
455
|
-
this.state = {
|
|
456
|
-
cellsAroundViewport: initialRenderRegion,
|
|
457
|
-
renderMask: VirtualizedList._createRenderMask(props, initialRenderRegion),
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
static _createRenderMask(
|
|
462
|
-
props: Props,
|
|
463
|
-
cellsAroundViewport: {first: number, last: number},
|
|
464
|
-
additionalRegions?: ?$ReadOnlyArray<{first: number, last: number}>,
|
|
465
|
-
): CellRenderMask {
|
|
466
|
-
const itemCount = props.getItemCount(props.data);
|
|
467
|
-
|
|
468
|
-
invariant(
|
|
469
|
-
cellsAroundViewport.first >= 0 &&
|
|
470
|
-
cellsAroundViewport.last >= cellsAroundViewport.first - 1 &&
|
|
471
|
-
cellsAroundViewport.last < itemCount,
|
|
472
|
-
`Invalid cells around viewport "[${cellsAroundViewport.first}, ${cellsAroundViewport.last}]" was passed to VirtualizedList._createRenderMask`,
|
|
473
|
-
);
|
|
474
|
-
|
|
475
|
-
const renderMask = new CellRenderMask(itemCount);
|
|
476
|
-
|
|
477
|
-
if (itemCount > 0) {
|
|
478
|
-
const allRegions = [cellsAroundViewport, ...(additionalRegions ?? [])];
|
|
479
|
-
for (const region of allRegions) {
|
|
480
|
-
renderMask.addCells(region);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// The initially rendered cells are retained as part of the
|
|
484
|
-
// "scroll-to-top" optimization
|
|
485
|
-
if (props.initialScrollIndex == null || props.initialScrollIndex <= 0) {
|
|
486
|
-
const initialRegion = VirtualizedList._initialRenderRegion(props);
|
|
487
|
-
renderMask.addCells(initialRegion);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// The layout coordinates of sticker headers may be off-screen while the
|
|
491
|
-
// actual header is on-screen. Keep the most recent before the viewport
|
|
492
|
-
// rendered, even if its layout coordinates are not in viewport.
|
|
493
|
-
const stickyIndicesSet = new Set(props.stickyHeaderIndices);
|
|
494
|
-
VirtualizedList._ensureClosestStickyHeader(
|
|
495
|
-
props,
|
|
496
|
-
stickyIndicesSet,
|
|
497
|
-
renderMask,
|
|
498
|
-
cellsAroundViewport.first,
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return renderMask;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
static _initialRenderRegion(props: Props): {first: number, last: number} {
|
|
506
|
-
const itemCount = props.getItemCount(props.data);
|
|
507
|
-
const scrollIndex = Math.floor(Math.max(0, props.initialScrollIndex ?? 0));
|
|
508
|
-
|
|
509
|
-
return {
|
|
510
|
-
first: scrollIndex,
|
|
511
|
-
last:
|
|
512
|
-
Math.min(
|
|
513
|
-
itemCount,
|
|
514
|
-
scrollIndex + initialNumToRenderOrDefault(props.initialNumToRender),
|
|
515
|
-
) - 1,
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
static _ensureClosestStickyHeader(
|
|
520
|
-
props: Props,
|
|
521
|
-
stickyIndicesSet: Set<number>,
|
|
522
|
-
renderMask: CellRenderMask,
|
|
523
|
-
cellIdx: number,
|
|
524
|
-
) {
|
|
525
|
-
const stickyOffset = props.ListHeaderComponent ? 1 : 0;
|
|
526
|
-
|
|
527
|
-
for (let itemIdx = cellIdx - 1; itemIdx >= 0; itemIdx--) {
|
|
528
|
-
if (stickyIndicesSet.has(itemIdx + stickyOffset)) {
|
|
529
|
-
renderMask.addCells({first: itemIdx, last: itemIdx});
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
_adjustCellsAroundViewport(
|
|
536
|
-
props: Props,
|
|
537
|
-
cellsAroundViewport: {first: number, last: number},
|
|
538
|
-
): {first: number, last: number} {
|
|
539
|
-
const {data, getItemCount} = props;
|
|
540
|
-
const onEndReachedThreshold = onEndReachedThresholdOrDefault(
|
|
541
|
-
props.onEndReachedThreshold,
|
|
542
|
-
);
|
|
543
|
-
this._updateViewableItems(props, cellsAroundViewport);
|
|
544
|
-
|
|
545
|
-
const {contentLength, offset, visibleLength} = this._scrollMetrics;
|
|
546
|
-
const distanceFromEnd = contentLength - visibleLength - offset;
|
|
547
|
-
|
|
548
|
-
// Wait until the scroll view metrics have been set up. And until then,
|
|
549
|
-
// we will trust the initialNumToRender suggestion
|
|
550
|
-
if (visibleLength <= 0 || contentLength <= 0) {
|
|
551
|
-
return cellsAroundViewport.last >= getItemCount(data)
|
|
552
|
-
? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
|
|
553
|
-
: cellsAroundViewport;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
let newCellsAroundViewport: {first: number, last: number};
|
|
557
|
-
if (props.disableVirtualization) {
|
|
558
|
-
const renderAhead =
|
|
559
|
-
distanceFromEnd < onEndReachedThreshold * visibleLength
|
|
560
|
-
? maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch)
|
|
561
|
-
: 0;
|
|
562
|
-
|
|
563
|
-
newCellsAroundViewport = {
|
|
564
|
-
first: 0,
|
|
565
|
-
last: Math.min(
|
|
566
|
-
cellsAroundViewport.last + renderAhead,
|
|
567
|
-
getItemCount(data) - 1,
|
|
568
|
-
),
|
|
569
|
-
};
|
|
570
|
-
} else {
|
|
571
|
-
// If we have a non-zero initialScrollIndex and run this before we've scrolled,
|
|
572
|
-
// we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex.
|
|
573
|
-
// So let's wait until we've scrolled the view to the right place. And until then,
|
|
574
|
-
// we will trust the initialScrollIndex suggestion.
|
|
575
|
-
|
|
576
|
-
// Thus, we want to recalculate the windowed render limits if any of the following hold:
|
|
577
|
-
// - initialScrollIndex is undefined or is 0
|
|
578
|
-
// - initialScrollIndex > 0 AND scrolling is complete
|
|
579
|
-
// - initialScrollIndex > 0 AND the end of the list is visible (this handles the case
|
|
580
|
-
// where the list is shorter than the visible area)
|
|
581
|
-
if (
|
|
582
|
-
props.initialScrollIndex &&
|
|
583
|
-
!this._scrollMetrics.offset &&
|
|
584
|
-
Math.abs(distanceFromEnd) >= Number.EPSILON
|
|
585
|
-
) {
|
|
586
|
-
return cellsAroundViewport.last >= getItemCount(data)
|
|
587
|
-
? VirtualizedList._constrainToItemCount(cellsAroundViewport, props)
|
|
588
|
-
: cellsAroundViewport;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
newCellsAroundViewport = computeWindowedRenderLimits(
|
|
592
|
-
props,
|
|
593
|
-
maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch),
|
|
594
|
-
windowSizeOrDefault(props.windowSize),
|
|
595
|
-
cellsAroundViewport,
|
|
596
|
-
this.__getFrameMetricsApprox,
|
|
597
|
-
this._scrollMetrics,
|
|
598
|
-
);
|
|
599
|
-
invariant(
|
|
600
|
-
newCellsAroundViewport.last < getItemCount(data),
|
|
601
|
-
'computeWindowedRenderLimits() should return range in-bounds',
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
if (this._nestedChildLists.size() > 0) {
|
|
606
|
-
// If some cell in the new state has a child list in it, we should only render
|
|
607
|
-
// up through that item, so that we give that list a chance to render.
|
|
608
|
-
// Otherwise there's churn from multiple child lists mounting and un-mounting
|
|
609
|
-
// their items.
|
|
610
|
-
|
|
611
|
-
// Will this prevent rendering if the nested list doesn't realize the end?
|
|
612
|
-
const childIdx = this._findFirstChildWithMore(
|
|
613
|
-
newCellsAroundViewport.first,
|
|
614
|
-
newCellsAroundViewport.last,
|
|
615
|
-
);
|
|
616
|
-
|
|
617
|
-
newCellsAroundViewport.last = childIdx ?? newCellsAroundViewport.last;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
return newCellsAroundViewport;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
_findFirstChildWithMore(first: number, last: number): number | null {
|
|
624
|
-
for (let ii = first; ii <= last; ii++) {
|
|
625
|
-
const cellKeyForIndex = this._indicesToKeys.get(ii);
|
|
626
|
-
if (
|
|
627
|
-
cellKeyForIndex != null &&
|
|
628
|
-
this._nestedChildLists.anyInCell(cellKeyForIndex, childList =>
|
|
629
|
-
childList.hasMore(),
|
|
630
|
-
)
|
|
631
|
-
) {
|
|
632
|
-
return ii;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
11
|
+
'use strict';
|
|
635
12
|
|
|
636
|
-
|
|
637
|
-
}
|
|
13
|
+
import {typeof VirtualizedList as VirtualizedListType} from '@react-native/virtualized-lists';
|
|
638
14
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
this.context.registerAsNestedChild({
|
|
642
|
-
ref: this,
|
|
643
|
-
cellKey: this.context.cellKey,
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
}
|
|
15
|
+
const VirtualizedList: VirtualizedListType =
|
|
16
|
+
require('@react-native/virtualized-lists').VirtualizedList;
|
|
647
17
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
tuple.viewabilityHelper.dispose();
|
|
655
|
-
});
|
|
656
|
-
this._fillRateHelper.deactivateAndFlush();
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
static getDerivedStateFromProps(newProps: Props, prevState: State): State {
|
|
660
|
-
// first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
|
|
661
|
-
// sure we're rendering a reasonable range here.
|
|
662
|
-
const itemCount = newProps.getItemCount(newProps.data);
|
|
663
|
-
if (itemCount === prevState.renderMask.numCells()) {
|
|
664
|
-
return prevState;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
const constrainedCells = VirtualizedList._constrainToItemCount(
|
|
668
|
-
prevState.cellsAroundViewport,
|
|
669
|
-
newProps,
|
|
670
|
-
);
|
|
671
|
-
|
|
672
|
-
return {
|
|
673
|
-
cellsAroundViewport: constrainedCells,
|
|
674
|
-
renderMask: VirtualizedList._createRenderMask(newProps, constrainedCells),
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
_pushCells(
|
|
679
|
-
cells: Array<Object>,
|
|
680
|
-
stickyHeaderIndices: Array<number>,
|
|
681
|
-
stickyIndicesFromProps: Set<number>,
|
|
682
|
-
first: number,
|
|
683
|
-
last: number,
|
|
684
|
-
inversionStyle: ViewStyleProp,
|
|
685
|
-
) {
|
|
686
|
-
const {
|
|
687
|
-
CellRendererComponent,
|
|
688
|
-
ItemSeparatorComponent,
|
|
689
|
-
ListHeaderComponent,
|
|
690
|
-
ListItemComponent,
|
|
691
|
-
data,
|
|
692
|
-
debug,
|
|
693
|
-
getItem,
|
|
694
|
-
getItemCount,
|
|
695
|
-
getItemLayout,
|
|
696
|
-
horizontal,
|
|
697
|
-
renderItem,
|
|
698
|
-
} = this.props;
|
|
699
|
-
const stickyOffset = ListHeaderComponent ? 1 : 0;
|
|
700
|
-
const end = getItemCount(data) - 1;
|
|
701
|
-
let prevCellKey;
|
|
702
|
-
last = Math.min(end, last);
|
|
703
|
-
for (let ii = first; ii <= last; ii++) {
|
|
704
|
-
const item = getItem(data, ii);
|
|
705
|
-
const key = this._keyExtractor(item, ii, this.props);
|
|
706
|
-
this._indicesToKeys.set(ii, key);
|
|
707
|
-
if (stickyIndicesFromProps.has(ii + stickyOffset)) {
|
|
708
|
-
stickyHeaderIndices.push(cells.length);
|
|
709
|
-
}
|
|
710
|
-
cells.push(
|
|
711
|
-
<CellRenderer
|
|
712
|
-
CellRendererComponent={CellRendererComponent}
|
|
713
|
-
ItemSeparatorComponent={ii < end ? ItemSeparatorComponent : undefined}
|
|
714
|
-
ListItemComponent={ListItemComponent}
|
|
715
|
-
cellKey={key}
|
|
716
|
-
debug={debug}
|
|
717
|
-
fillRateHelper={this._fillRateHelper}
|
|
718
|
-
getItemLayout={getItemLayout}
|
|
719
|
-
horizontal={horizontal}
|
|
720
|
-
index={ii}
|
|
721
|
-
inversionStyle={inversionStyle}
|
|
722
|
-
item={item}
|
|
723
|
-
key={key}
|
|
724
|
-
prevCellKey={prevCellKey}
|
|
725
|
-
onCellLayout={this._onCellLayout}
|
|
726
|
-
onUpdateSeparators={this._onUpdateSeparators}
|
|
727
|
-
onCellFocusCapture={e => this._onCellFocusCapture(key)}
|
|
728
|
-
onUnmount={this._onCellUnmount}
|
|
729
|
-
ref={ref => {
|
|
730
|
-
this._cellRefs[key] = ref;
|
|
731
|
-
}}
|
|
732
|
-
renderItem={renderItem}
|
|
733
|
-
/>,
|
|
734
|
-
);
|
|
735
|
-
prevCellKey = key;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
static _constrainToItemCount(
|
|
740
|
-
cells: {first: number, last: number},
|
|
741
|
-
props: Props,
|
|
742
|
-
): {first: number, last: number} {
|
|
743
|
-
const itemCount = props.getItemCount(props.data);
|
|
744
|
-
const last = Math.min(itemCount - 1, cells.last);
|
|
745
|
-
|
|
746
|
-
const maxToRenderPerBatch = maxToRenderPerBatchOrDefault(
|
|
747
|
-
props.maxToRenderPerBatch,
|
|
748
|
-
);
|
|
749
|
-
|
|
750
|
-
return {
|
|
751
|
-
first: clamp(0, itemCount - 1 - maxToRenderPerBatch, cells.first),
|
|
752
|
-
last,
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
_onUpdateSeparators = (keys: Array<?string>, newProps: Object) => {
|
|
757
|
-
keys.forEach(key => {
|
|
758
|
-
const ref = key != null && this._cellRefs[key];
|
|
759
|
-
ref && ref.updateSeparatorProps(newProps);
|
|
760
|
-
});
|
|
761
|
-
};
|
|
762
|
-
|
|
763
|
-
_isNestedWithSameOrientation(): boolean {
|
|
764
|
-
const nestedContext = this.context;
|
|
765
|
-
return !!(
|
|
766
|
-
nestedContext &&
|
|
767
|
-
!!nestedContext.horizontal === horizontalOrDefault(this.props.horizontal)
|
|
768
|
-
);
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
_getSpacerKey = (isVertical: boolean): string =>
|
|
772
|
-
isVertical ? 'height' : 'width';
|
|
773
|
-
|
|
774
|
-
_keyExtractor(
|
|
775
|
-
item: Item,
|
|
776
|
-
index: number,
|
|
777
|
-
props: {
|
|
778
|
-
keyExtractor?: ?(item: Item, index: number) => string,
|
|
779
|
-
...
|
|
780
|
-
},
|
|
781
|
-
// $FlowFixMe[missing-local-annot]
|
|
782
|
-
) {
|
|
783
|
-
if (props.keyExtractor != null) {
|
|
784
|
-
return props.keyExtractor(item, index);
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
const key = defaultKeyExtractor(item, index);
|
|
788
|
-
if (key === String(index)) {
|
|
789
|
-
_usedIndexForKey = true;
|
|
790
|
-
if (item.type && item.type.displayName) {
|
|
791
|
-
_keylessItemComponentName = item.type.displayName;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
return key;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
render(): React.Node {
|
|
798
|
-
if (__DEV__) {
|
|
799
|
-
const flatStyles = flattenStyle(this.props.contentContainerStyle);
|
|
800
|
-
if (flatStyles != null && flatStyles.flexWrap === 'wrap') {
|
|
801
|
-
console.warn(
|
|
802
|
-
'`flexWrap: `wrap`` is not supported with the `VirtualizedList` components.' +
|
|
803
|
-
'Consider using `numColumns` with `FlatList` instead.',
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} =
|
|
808
|
-
this.props;
|
|
809
|
-
const {data, horizontal} = this.props;
|
|
810
|
-
const inversionStyle = this.props.inverted
|
|
811
|
-
? horizontalOrDefault(this.props.horizontal)
|
|
812
|
-
? styles.horizontallyInverted
|
|
813
|
-
: styles.verticallyInverted
|
|
814
|
-
: null;
|
|
815
|
-
const cells: Array<any | React.Node> = [];
|
|
816
|
-
const stickyIndicesFromProps = new Set(this.props.stickyHeaderIndices);
|
|
817
|
-
const stickyHeaderIndices = [];
|
|
818
|
-
|
|
819
|
-
// 1. Add cell for ListHeaderComponent
|
|
820
|
-
if (ListHeaderComponent) {
|
|
821
|
-
if (stickyIndicesFromProps.has(0)) {
|
|
822
|
-
stickyHeaderIndices.push(0);
|
|
823
|
-
}
|
|
824
|
-
const element = React.isValidElement(ListHeaderComponent) ? (
|
|
825
|
-
ListHeaderComponent
|
|
826
|
-
) : (
|
|
827
|
-
// $FlowFixMe[not-a-component]
|
|
828
|
-
// $FlowFixMe[incompatible-type-arg]
|
|
829
|
-
<ListHeaderComponent />
|
|
830
|
-
);
|
|
831
|
-
cells.push(
|
|
832
|
-
<VirtualizedListCellContextProvider
|
|
833
|
-
cellKey={this._getCellKey() + '-header'}
|
|
834
|
-
key="$header">
|
|
835
|
-
<View
|
|
836
|
-
onLayout={this._onLayoutHeader}
|
|
837
|
-
style={StyleSheet.compose(
|
|
838
|
-
inversionStyle,
|
|
839
|
-
this.props.ListHeaderComponentStyle,
|
|
840
|
-
)}>
|
|
841
|
-
{
|
|
842
|
-
// $FlowFixMe[incompatible-type] - Typing ReactNativeComponent revealed errors
|
|
843
|
-
element
|
|
844
|
-
}
|
|
845
|
-
</View>
|
|
846
|
-
</VirtualizedListCellContextProvider>,
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
// 2a. Add a cell for ListEmptyComponent if applicable
|
|
851
|
-
const itemCount = this.props.getItemCount(data);
|
|
852
|
-
if (itemCount === 0 && ListEmptyComponent) {
|
|
853
|
-
const element: React.Element<any> = ((React.isValidElement(
|
|
854
|
-
ListEmptyComponent,
|
|
855
|
-
) ? (
|
|
856
|
-
ListEmptyComponent
|
|
857
|
-
) : (
|
|
858
|
-
// $FlowFixMe[not-a-component]
|
|
859
|
-
// $FlowFixMe[incompatible-type-arg]
|
|
860
|
-
<ListEmptyComponent />
|
|
861
|
-
)): any);
|
|
862
|
-
cells.push(
|
|
863
|
-
<VirtualizedListCellContextProvider
|
|
864
|
-
cellKey={this._getCellKey() + '-empty'}
|
|
865
|
-
key="$empty">
|
|
866
|
-
{React.cloneElement(element, {
|
|
867
|
-
onLayout: (event: LayoutEvent) => {
|
|
868
|
-
this._onLayoutEmpty(event);
|
|
869
|
-
if (element.props.onLayout) {
|
|
870
|
-
element.props.onLayout(event);
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
style: StyleSheet.compose(inversionStyle, element.props.style),
|
|
874
|
-
})}
|
|
875
|
-
</VirtualizedListCellContextProvider>,
|
|
876
|
-
);
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
// 2b. Add cells and spacers for each item
|
|
880
|
-
if (itemCount > 0) {
|
|
881
|
-
_usedIndexForKey = false;
|
|
882
|
-
_keylessItemComponentName = '';
|
|
883
|
-
const spacerKey = this._getSpacerKey(!horizontal);
|
|
884
|
-
|
|
885
|
-
const renderRegions = this.state.renderMask.enumerateRegions();
|
|
886
|
-
const lastSpacer = findLastWhere(renderRegions, r => r.isSpacer);
|
|
887
|
-
|
|
888
|
-
for (const section of renderRegions) {
|
|
889
|
-
if (section.isSpacer) {
|
|
890
|
-
// Legacy behavior is to avoid spacers when virtualization is
|
|
891
|
-
// disabled (including head spacers on initial render).
|
|
892
|
-
if (this.props.disableVirtualization) {
|
|
893
|
-
continue;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
// Without getItemLayout, we limit our tail spacer to the _highestMeasuredFrameIndex to
|
|
897
|
-
// prevent the user for hyperscrolling into un-measured area because otherwise content will
|
|
898
|
-
// likely jump around as it renders in above the viewport.
|
|
899
|
-
const isLastSpacer = section === lastSpacer;
|
|
900
|
-
const constrainToMeasured = isLastSpacer && !this.props.getItemLayout;
|
|
901
|
-
const last = constrainToMeasured
|
|
902
|
-
? clamp(
|
|
903
|
-
section.first - 1,
|
|
904
|
-
section.last,
|
|
905
|
-
this._highestMeasuredFrameIndex,
|
|
906
|
-
)
|
|
907
|
-
: section.last;
|
|
908
|
-
|
|
909
|
-
const firstMetrics = this.__getFrameMetricsApprox(
|
|
910
|
-
section.first,
|
|
911
|
-
this.props,
|
|
912
|
-
);
|
|
913
|
-
const lastMetrics = this.__getFrameMetricsApprox(last, this.props);
|
|
914
|
-
const spacerSize =
|
|
915
|
-
lastMetrics.offset + lastMetrics.length - firstMetrics.offset;
|
|
916
|
-
cells.push(
|
|
917
|
-
<View
|
|
918
|
-
key={`$spacer-${section.first}`}
|
|
919
|
-
style={{[spacerKey]: spacerSize}}
|
|
920
|
-
/>,
|
|
921
|
-
);
|
|
922
|
-
} else {
|
|
923
|
-
this._pushCells(
|
|
924
|
-
cells,
|
|
925
|
-
stickyHeaderIndices,
|
|
926
|
-
stickyIndicesFromProps,
|
|
927
|
-
section.first,
|
|
928
|
-
section.last,
|
|
929
|
-
inversionStyle,
|
|
930
|
-
);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
if (!this._hasWarned.keys && _usedIndexForKey) {
|
|
935
|
-
console.warn(
|
|
936
|
-
'VirtualizedList: missing keys for items, make sure to specify a key or id property on each ' +
|
|
937
|
-
'item or provide a custom keyExtractor.',
|
|
938
|
-
_keylessItemComponentName,
|
|
939
|
-
);
|
|
940
|
-
this._hasWarned.keys = true;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
// 3. Add cell for ListFooterComponent
|
|
945
|
-
if (ListFooterComponent) {
|
|
946
|
-
const element = React.isValidElement(ListFooterComponent) ? (
|
|
947
|
-
ListFooterComponent
|
|
948
|
-
) : (
|
|
949
|
-
// $FlowFixMe[not-a-component]
|
|
950
|
-
// $FlowFixMe[incompatible-type-arg]
|
|
951
|
-
<ListFooterComponent />
|
|
952
|
-
);
|
|
953
|
-
cells.push(
|
|
954
|
-
<VirtualizedListCellContextProvider
|
|
955
|
-
cellKey={this._getFooterCellKey()}
|
|
956
|
-
key="$footer">
|
|
957
|
-
<View
|
|
958
|
-
onLayout={this._onLayoutFooter}
|
|
959
|
-
style={StyleSheet.compose(
|
|
960
|
-
inversionStyle,
|
|
961
|
-
this.props.ListFooterComponentStyle,
|
|
962
|
-
)}>
|
|
963
|
-
{
|
|
964
|
-
// $FlowFixMe[incompatible-type] - Typing ReactNativeComponent revealed errors
|
|
965
|
-
element
|
|
966
|
-
}
|
|
967
|
-
</View>
|
|
968
|
-
</VirtualizedListCellContextProvider>,
|
|
969
|
-
);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
// 4. Render the ScrollView
|
|
973
|
-
const scrollProps = {
|
|
974
|
-
...this.props,
|
|
975
|
-
onContentSizeChange: this._onContentSizeChange,
|
|
976
|
-
onLayout: this._onLayout,
|
|
977
|
-
onScroll: this._onScroll,
|
|
978
|
-
onScrollBeginDrag: this._onScrollBeginDrag,
|
|
979
|
-
onScrollEndDrag: this._onScrollEndDrag,
|
|
980
|
-
onMomentumScrollBegin: this._onMomentumScrollBegin,
|
|
981
|
-
onMomentumScrollEnd: this._onMomentumScrollEnd,
|
|
982
|
-
scrollEventThrottle: scrollEventThrottleOrDefault(
|
|
983
|
-
this.props.scrollEventThrottle,
|
|
984
|
-
), // TODO: Android support
|
|
985
|
-
invertStickyHeaders:
|
|
986
|
-
this.props.invertStickyHeaders !== undefined
|
|
987
|
-
? this.props.invertStickyHeaders
|
|
988
|
-
: this.props.inverted,
|
|
989
|
-
stickyHeaderIndices,
|
|
990
|
-
style: inversionStyle
|
|
991
|
-
? [inversionStyle, this.props.style]
|
|
992
|
-
: this.props.style,
|
|
993
|
-
};
|
|
994
|
-
|
|
995
|
-
this._hasMore = this.state.cellsAroundViewport.last < itemCount - 1;
|
|
996
|
-
|
|
997
|
-
const innerRet = (
|
|
998
|
-
<VirtualizedListContextProvider
|
|
999
|
-
value={{
|
|
1000
|
-
cellKey: null,
|
|
1001
|
-
getScrollMetrics: this._getScrollMetrics,
|
|
1002
|
-
horizontal: horizontalOrDefault(this.props.horizontal),
|
|
1003
|
-
getOutermostParentListRef: this._getOutermostParentListRef,
|
|
1004
|
-
registerAsNestedChild: this._registerAsNestedChild,
|
|
1005
|
-
unregisterAsNestedChild: this._unregisterAsNestedChild,
|
|
1006
|
-
}}>
|
|
1007
|
-
{React.cloneElement(
|
|
1008
|
-
(
|
|
1009
|
-
this.props.renderScrollComponent ||
|
|
1010
|
-
this._defaultRenderScrollComponent
|
|
1011
|
-
)(scrollProps),
|
|
1012
|
-
{
|
|
1013
|
-
ref: this._captureScrollRef,
|
|
1014
|
-
},
|
|
1015
|
-
cells,
|
|
1016
|
-
)}
|
|
1017
|
-
</VirtualizedListContextProvider>
|
|
1018
|
-
);
|
|
1019
|
-
let ret: React.Node = innerRet;
|
|
1020
|
-
if (__DEV__) {
|
|
1021
|
-
ret = (
|
|
1022
|
-
<ScrollView.Context.Consumer>
|
|
1023
|
-
{scrollContext => {
|
|
1024
|
-
if (
|
|
1025
|
-
scrollContext != null &&
|
|
1026
|
-
!scrollContext.horizontal ===
|
|
1027
|
-
!horizontalOrDefault(this.props.horizontal) &&
|
|
1028
|
-
!this._hasWarned.nesting &&
|
|
1029
|
-
this.context == null &&
|
|
1030
|
-
this.props.scrollEnabled !== false
|
|
1031
|
-
) {
|
|
1032
|
-
// TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170
|
|
1033
|
-
console.error(
|
|
1034
|
-
'VirtualizedLists should never be nested inside plain ScrollViews with the same ' +
|
|
1035
|
-
'orientation because it can break windowing and other functionality - use another ' +
|
|
1036
|
-
'VirtualizedList-backed container instead.',
|
|
1037
|
-
);
|
|
1038
|
-
this._hasWarned.nesting = true;
|
|
1039
|
-
}
|
|
1040
|
-
return innerRet;
|
|
1041
|
-
}}
|
|
1042
|
-
</ScrollView.Context.Consumer>
|
|
1043
|
-
);
|
|
1044
|
-
}
|
|
1045
|
-
if (this.props.debug) {
|
|
1046
|
-
return (
|
|
1047
|
-
<View style={styles.debug}>
|
|
1048
|
-
{ret}
|
|
1049
|
-
{this._renderDebugOverlay()}
|
|
1050
|
-
</View>
|
|
1051
|
-
);
|
|
1052
|
-
} else {
|
|
1053
|
-
return ret;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
componentDidUpdate(prevProps: Props) {
|
|
1058
|
-
const {data, extraData} = this.props;
|
|
1059
|
-
if (data !== prevProps.data || extraData !== prevProps.extraData) {
|
|
1060
|
-
// clear the viewableIndices cache to also trigger
|
|
1061
|
-
// the onViewableItemsChanged callback with the new data
|
|
1062
|
-
this._viewabilityTuples.forEach(tuple => {
|
|
1063
|
-
tuple.viewabilityHelper.resetViewableIndices();
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
// The `this._hiPriInProgress` is guaranteeing a hiPri cell update will only happen
|
|
1067
|
-
// once per fiber update. The `_scheduleCellsToRenderUpdate` will set it to true
|
|
1068
|
-
// if a hiPri update needs to perform. If `componentDidUpdate` is triggered with
|
|
1069
|
-
// `this._hiPriInProgress=true`, means it's triggered by the hiPri update. The
|
|
1070
|
-
// `_scheduleCellsToRenderUpdate` will check this condition and not perform
|
|
1071
|
-
// another hiPri update.
|
|
1072
|
-
const hiPriInProgress = this._hiPriInProgress;
|
|
1073
|
-
this._scheduleCellsToRenderUpdate();
|
|
1074
|
-
// Make sure setting `this._hiPriInProgress` back to false after `componentDidUpdate`
|
|
1075
|
-
// is triggered with `this._hiPriInProgress = true`
|
|
1076
|
-
if (hiPriInProgress) {
|
|
1077
|
-
this._hiPriInProgress = false;
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
_averageCellLength = 0;
|
|
1082
|
-
_cellRefs: {[string]: null | CellRenderer<any>} = {};
|
|
1083
|
-
_fillRateHelper: FillRateHelper;
|
|
1084
|
-
_frames: {
|
|
1085
|
-
[string]: {
|
|
1086
|
-
inLayout?: boolean,
|
|
1087
|
-
index: number,
|
|
1088
|
-
length: number,
|
|
1089
|
-
offset: number,
|
|
1090
|
-
},
|
|
1091
|
-
} = {};
|
|
1092
|
-
_footerLength = 0;
|
|
1093
|
-
// Used for preventing scrollToIndex from being called multiple times for initialScrollIndex
|
|
1094
|
-
_hasTriggeredInitialScrollToIndex = false;
|
|
1095
|
-
_hasInteracted = false;
|
|
1096
|
-
_hasMore = false;
|
|
1097
|
-
_hasWarned: {[string]: boolean} = {};
|
|
1098
|
-
_headerLength = 0;
|
|
1099
|
-
_hiPriInProgress: boolean = false; // flag to prevent infinite hiPri cell limit update
|
|
1100
|
-
_highestMeasuredFrameIndex = 0;
|
|
1101
|
-
_indicesToKeys: Map<number, string> = new Map();
|
|
1102
|
-
_lastFocusedCellKey: ?string = null;
|
|
1103
|
-
_nestedChildLists: ChildListCollection<VirtualizedList> =
|
|
1104
|
-
new ChildListCollection();
|
|
1105
|
-
_offsetFromParentVirtualizedList: number = 0;
|
|
1106
|
-
_prevParentOffset: number = 0;
|
|
1107
|
-
// $FlowFixMe[missing-local-annot]
|
|
1108
|
-
_scrollMetrics = {
|
|
1109
|
-
contentLength: 0,
|
|
1110
|
-
dOffset: 0,
|
|
1111
|
-
dt: 10,
|
|
1112
|
-
offset: 0,
|
|
1113
|
-
timestamp: 0,
|
|
1114
|
-
velocity: 0,
|
|
1115
|
-
visibleLength: 0,
|
|
1116
|
-
zoomScale: 1,
|
|
1117
|
-
};
|
|
1118
|
-
_scrollRef: ?React.ElementRef<any> = null;
|
|
1119
|
-
_sentEndForContentLength = 0;
|
|
1120
|
-
_totalCellLength = 0;
|
|
1121
|
-
_totalCellsMeasured = 0;
|
|
1122
|
-
_updateCellsToRenderBatcher: Batchinator;
|
|
1123
|
-
_viewabilityTuples: Array<ViewabilityHelperCallbackTuple> = [];
|
|
1124
|
-
|
|
1125
|
-
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
1126
|
-
* LTI update could not be added via codemod */
|
|
1127
|
-
_captureScrollRef = ref => {
|
|
1128
|
-
this._scrollRef = ref;
|
|
1129
|
-
};
|
|
1130
|
-
|
|
1131
|
-
_computeBlankness() {
|
|
1132
|
-
this._fillRateHelper.computeBlankness(
|
|
1133
|
-
this.props,
|
|
1134
|
-
this.state.cellsAroundViewport,
|
|
1135
|
-
this._scrollMetrics,
|
|
1136
|
-
);
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
|
|
1140
|
-
* LTI update could not be added via codemod */
|
|
1141
|
-
_defaultRenderScrollComponent = props => {
|
|
1142
|
-
const onRefresh = props.onRefresh;
|
|
1143
|
-
if (this._isNestedWithSameOrientation()) {
|
|
1144
|
-
// $FlowFixMe[prop-missing] - Typing ReactNativeComponent revealed errors
|
|
1145
|
-
return <View {...props} />;
|
|
1146
|
-
} else if (onRefresh) {
|
|
1147
|
-
invariant(
|
|
1148
|
-
typeof props.refreshing === 'boolean',
|
|
1149
|
-
'`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `' +
|
|
1150
|
-
JSON.stringify(props.refreshing ?? 'undefined') +
|
|
1151
|
-
'`',
|
|
1152
|
-
);
|
|
1153
|
-
return (
|
|
1154
|
-
// $FlowFixMe[prop-missing] Invalid prop usage
|
|
1155
|
-
// $FlowFixMe[incompatible-use]
|
|
1156
|
-
<ScrollView
|
|
1157
|
-
{...props}
|
|
1158
|
-
refreshControl={
|
|
1159
|
-
props.refreshControl == null ? (
|
|
1160
|
-
<RefreshControl
|
|
1161
|
-
// $FlowFixMe[incompatible-type]
|
|
1162
|
-
refreshing={props.refreshing}
|
|
1163
|
-
onRefresh={onRefresh}
|
|
1164
|
-
progressViewOffset={props.progressViewOffset}
|
|
1165
|
-
/>
|
|
1166
|
-
) : (
|
|
1167
|
-
props.refreshControl
|
|
1168
|
-
)
|
|
1169
|
-
}
|
|
1170
|
-
/>
|
|
1171
|
-
);
|
|
1172
|
-
} else {
|
|
1173
|
-
// $FlowFixMe[prop-missing] Invalid prop usage
|
|
1174
|
-
// $FlowFixMe[incompatible-use]
|
|
1175
|
-
return <ScrollView {...props} />;
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
|
|
1179
|
-
_onCellLayout = (e: LayoutEvent, cellKey: string, index: number): void => {
|
|
1180
|
-
const layout = e.nativeEvent.layout;
|
|
1181
|
-
const next = {
|
|
1182
|
-
offset: this._selectOffset(layout),
|
|
1183
|
-
length: this._selectLength(layout),
|
|
1184
|
-
index,
|
|
1185
|
-
inLayout: true,
|
|
1186
|
-
};
|
|
1187
|
-
const curr = this._frames[cellKey];
|
|
1188
|
-
if (
|
|
1189
|
-
!curr ||
|
|
1190
|
-
next.offset !== curr.offset ||
|
|
1191
|
-
next.length !== curr.length ||
|
|
1192
|
-
index !== curr.index
|
|
1193
|
-
) {
|
|
1194
|
-
this._totalCellLength += next.length - (curr ? curr.length : 0);
|
|
1195
|
-
this._totalCellsMeasured += curr ? 0 : 1;
|
|
1196
|
-
this._averageCellLength =
|
|
1197
|
-
this._totalCellLength / this._totalCellsMeasured;
|
|
1198
|
-
this._frames[cellKey] = next;
|
|
1199
|
-
this._highestMeasuredFrameIndex = Math.max(
|
|
1200
|
-
this._highestMeasuredFrameIndex,
|
|
1201
|
-
index,
|
|
1202
|
-
);
|
|
1203
|
-
this._scheduleCellsToRenderUpdate();
|
|
1204
|
-
} else {
|
|
1205
|
-
this._frames[cellKey].inLayout = true;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
this._triggerRemeasureForChildListsInCell(cellKey);
|
|
1209
|
-
|
|
1210
|
-
this._computeBlankness();
|
|
1211
|
-
this._updateViewableItems(this.props, this.state.cellsAroundViewport);
|
|
1212
|
-
};
|
|
1213
|
-
|
|
1214
|
-
_onCellFocusCapture(cellKey: string) {
|
|
1215
|
-
this._lastFocusedCellKey = cellKey;
|
|
1216
|
-
const renderMask = VirtualizedList._createRenderMask(
|
|
1217
|
-
this.props,
|
|
1218
|
-
this.state.cellsAroundViewport,
|
|
1219
|
-
this._getNonViewportRenderRegions(this.props),
|
|
1220
|
-
);
|
|
1221
|
-
|
|
1222
|
-
this.setState(state => {
|
|
1223
|
-
if (!renderMask.equals(state.renderMask)) {
|
|
1224
|
-
return {renderMask};
|
|
1225
|
-
}
|
|
1226
|
-
return null;
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
_onCellUnmount = (cellKey: string) => {
|
|
1231
|
-
const curr = this._frames[cellKey];
|
|
1232
|
-
if (curr) {
|
|
1233
|
-
this._frames[cellKey] = {...curr, inLayout: false};
|
|
1234
|
-
}
|
|
1235
|
-
};
|
|
1236
|
-
|
|
1237
|
-
_triggerRemeasureForChildListsInCell(cellKey: string): void {
|
|
1238
|
-
this._nestedChildLists.forEachInCell(cellKey, childList => {
|
|
1239
|
-
childList.measureLayoutRelativeToContainingList();
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
measureLayoutRelativeToContainingList(): void {
|
|
1244
|
-
// TODO (T35574538): findNodeHandle sometimes crashes with "Unable to find
|
|
1245
|
-
// node on an unmounted component" during scrolling
|
|
1246
|
-
try {
|
|
1247
|
-
if (!this._scrollRef) {
|
|
1248
|
-
return;
|
|
1249
|
-
}
|
|
1250
|
-
// We are assuming that getOutermostParentListRef().getScrollRef()
|
|
1251
|
-
// is a non-null reference to a ScrollView
|
|
1252
|
-
this._scrollRef.measureLayout(
|
|
1253
|
-
this.context.getOutermostParentListRef().getScrollRef(),
|
|
1254
|
-
(x, y, width, height) => {
|
|
1255
|
-
this._offsetFromParentVirtualizedList = this._selectOffset({x, y});
|
|
1256
|
-
this._scrollMetrics.contentLength = this._selectLength({
|
|
1257
|
-
width,
|
|
1258
|
-
height,
|
|
1259
|
-
});
|
|
1260
|
-
const scrollMetrics = this._convertParentScrollMetrics(
|
|
1261
|
-
this.context.getScrollMetrics(),
|
|
1262
|
-
);
|
|
1263
|
-
|
|
1264
|
-
const metricsChanged =
|
|
1265
|
-
this._scrollMetrics.visibleLength !== scrollMetrics.visibleLength ||
|
|
1266
|
-
this._scrollMetrics.offset !== scrollMetrics.offset;
|
|
1267
|
-
|
|
1268
|
-
if (metricsChanged) {
|
|
1269
|
-
this._scrollMetrics.visibleLength = scrollMetrics.visibleLength;
|
|
1270
|
-
this._scrollMetrics.offset = scrollMetrics.offset;
|
|
1271
|
-
|
|
1272
|
-
// If metrics of the scrollView changed, then we triggered remeasure for child list
|
|
1273
|
-
// to ensure VirtualizedList has the right information.
|
|
1274
|
-
this._nestedChildLists.forEach(childList => {
|
|
1275
|
-
childList.measureLayoutRelativeToContainingList();
|
|
1276
|
-
});
|
|
1277
|
-
}
|
|
1278
|
-
},
|
|
1279
|
-
error => {
|
|
1280
|
-
console.warn(
|
|
1281
|
-
"VirtualizedList: Encountered an error while measuring a list's" +
|
|
1282
|
-
' offset from its containing VirtualizedList.',
|
|
1283
|
-
);
|
|
1284
|
-
},
|
|
1285
|
-
);
|
|
1286
|
-
} catch (error) {
|
|
1287
|
-
console.warn(
|
|
1288
|
-
'measureLayoutRelativeToContainingList threw an error',
|
|
1289
|
-
error.stack,
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
_onLayout = (e: LayoutEvent) => {
|
|
1295
|
-
if (this._isNestedWithSameOrientation()) {
|
|
1296
|
-
// Need to adjust our scroll metrics to be relative to our containing
|
|
1297
|
-
// VirtualizedList before we can make claims about list item viewability
|
|
1298
|
-
this.measureLayoutRelativeToContainingList();
|
|
1299
|
-
} else {
|
|
1300
|
-
this._scrollMetrics.visibleLength = this._selectLength(
|
|
1301
|
-
e.nativeEvent.layout,
|
|
1302
|
-
);
|
|
1303
|
-
}
|
|
1304
|
-
this.props.onLayout && this.props.onLayout(e);
|
|
1305
|
-
this._scheduleCellsToRenderUpdate();
|
|
1306
|
-
this._maybeCallOnEndReached();
|
|
1307
|
-
};
|
|
1308
|
-
|
|
1309
|
-
_onLayoutEmpty = (e: LayoutEvent) => {
|
|
1310
|
-
this.props.onLayout && this.props.onLayout(e);
|
|
1311
|
-
};
|
|
1312
|
-
|
|
1313
|
-
_getFooterCellKey(): string {
|
|
1314
|
-
return this._getCellKey() + '-footer';
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
_onLayoutFooter = (e: LayoutEvent) => {
|
|
1318
|
-
this._triggerRemeasureForChildListsInCell(this._getFooterCellKey());
|
|
1319
|
-
this._footerLength = this._selectLength(e.nativeEvent.layout);
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
|
-
_onLayoutHeader = (e: LayoutEvent) => {
|
|
1323
|
-
this._headerLength = this._selectLength(e.nativeEvent.layout);
|
|
1324
|
-
};
|
|
1325
|
-
|
|
1326
|
-
// $FlowFixMe[missing-local-annot]
|
|
1327
|
-
_renderDebugOverlay() {
|
|
1328
|
-
const normalize =
|
|
1329
|
-
this._scrollMetrics.visibleLength /
|
|
1330
|
-
(this._scrollMetrics.contentLength || 1);
|
|
1331
|
-
const framesInLayout = [];
|
|
1332
|
-
const itemCount = this.props.getItemCount(this.props.data);
|
|
1333
|
-
for (let ii = 0; ii < itemCount; ii++) {
|
|
1334
|
-
const frame = this.__getFrameMetricsApprox(ii, this.props);
|
|
1335
|
-
/* $FlowFixMe[prop-missing] (>=0.68.0 site=react_native_fb) This comment
|
|
1336
|
-
* suppresses an error found when Flow v0.68 was deployed. To see the
|
|
1337
|
-
* error delete this comment and run Flow. */
|
|
1338
|
-
if (frame.inLayout) {
|
|
1339
|
-
framesInLayout.push(frame);
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
const windowTop = this.__getFrameMetricsApprox(
|
|
1343
|
-
this.state.cellsAroundViewport.first,
|
|
1344
|
-
this.props,
|
|
1345
|
-
).offset;
|
|
1346
|
-
const frameLast = this.__getFrameMetricsApprox(
|
|
1347
|
-
this.state.cellsAroundViewport.last,
|
|
1348
|
-
this.props,
|
|
1349
|
-
);
|
|
1350
|
-
const windowLen = frameLast.offset + frameLast.length - windowTop;
|
|
1351
|
-
const visTop = this._scrollMetrics.offset;
|
|
1352
|
-
const visLen = this._scrollMetrics.visibleLength;
|
|
1353
|
-
|
|
1354
|
-
return (
|
|
1355
|
-
<View style={[styles.debugOverlayBase, styles.debugOverlay]}>
|
|
1356
|
-
{framesInLayout.map((f, ii) => (
|
|
1357
|
-
<View
|
|
1358
|
-
key={'f' + ii}
|
|
1359
|
-
style={[
|
|
1360
|
-
styles.debugOverlayBase,
|
|
1361
|
-
styles.debugOverlayFrame,
|
|
1362
|
-
{
|
|
1363
|
-
top: f.offset * normalize,
|
|
1364
|
-
height: f.length * normalize,
|
|
1365
|
-
},
|
|
1366
|
-
]}
|
|
1367
|
-
/>
|
|
1368
|
-
))}
|
|
1369
|
-
<View
|
|
1370
|
-
style={[
|
|
1371
|
-
styles.debugOverlayBase,
|
|
1372
|
-
styles.debugOverlayFrameLast,
|
|
1373
|
-
{
|
|
1374
|
-
top: windowTop * normalize,
|
|
1375
|
-
height: windowLen * normalize,
|
|
1376
|
-
},
|
|
1377
|
-
]}
|
|
1378
|
-
/>
|
|
1379
|
-
<View
|
|
1380
|
-
style={[
|
|
1381
|
-
styles.debugOverlayBase,
|
|
1382
|
-
styles.debugOverlayFrameVis,
|
|
1383
|
-
{
|
|
1384
|
-
top: visTop * normalize,
|
|
1385
|
-
height: visLen * normalize,
|
|
1386
|
-
},
|
|
1387
|
-
]}
|
|
1388
|
-
/>
|
|
1389
|
-
</View>
|
|
1390
|
-
);
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
_selectLength(
|
|
1394
|
-
metrics: $ReadOnly<{
|
|
1395
|
-
height: number,
|
|
1396
|
-
width: number,
|
|
1397
|
-
...
|
|
1398
|
-
}>,
|
|
1399
|
-
): number {
|
|
1400
|
-
return !horizontalOrDefault(this.props.horizontal)
|
|
1401
|
-
? metrics.height
|
|
1402
|
-
: metrics.width;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
_selectOffset(
|
|
1406
|
-
metrics: $ReadOnly<{
|
|
1407
|
-
x: number,
|
|
1408
|
-
y: number,
|
|
1409
|
-
...
|
|
1410
|
-
}>,
|
|
1411
|
-
): number {
|
|
1412
|
-
return !horizontalOrDefault(this.props.horizontal) ? metrics.y : metrics.x;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
_maybeCallOnEndReached() {
|
|
1416
|
-
const {data, getItemCount, onEndReached, onEndReachedThreshold} =
|
|
1417
|
-
this.props;
|
|
1418
|
-
const {contentLength, visibleLength, offset} = this._scrollMetrics;
|
|
1419
|
-
let distanceFromEnd = contentLength - visibleLength - offset;
|
|
1420
|
-
|
|
1421
|
-
// Especially when oERT is zero it's necessary to 'floor' very small distanceFromEnd values to be 0
|
|
1422
|
-
// since debouncing causes us to not fire this event for every single "pixel" we scroll and can thus
|
|
1423
|
-
// be at the "end" of the list with a distanceFromEnd approximating 0 but not quite there.
|
|
1424
|
-
if (distanceFromEnd < ON_END_REACHED_EPSILON) {
|
|
1425
|
-
distanceFromEnd = 0;
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
// TODO: T121172172 Look into why we're "defaulting" to a threshold of 2 when oERT is not present
|
|
1429
|
-
const threshold =
|
|
1430
|
-
onEndReachedThreshold != null ? onEndReachedThreshold * visibleLength : 2;
|
|
1431
|
-
if (
|
|
1432
|
-
onEndReached &&
|
|
1433
|
-
this.state.cellsAroundViewport.last === getItemCount(data) - 1 &&
|
|
1434
|
-
distanceFromEnd <= threshold &&
|
|
1435
|
-
this._scrollMetrics.contentLength !== this._sentEndForContentLength
|
|
1436
|
-
) {
|
|
1437
|
-
// Only call onEndReached once for a given content length
|
|
1438
|
-
this._sentEndForContentLength = this._scrollMetrics.contentLength;
|
|
1439
|
-
onEndReached({distanceFromEnd});
|
|
1440
|
-
} else if (distanceFromEnd > threshold) {
|
|
1441
|
-
// If the user scrolls away from the end and back again cause
|
|
1442
|
-
// an onEndReached to be triggered again
|
|
1443
|
-
this._sentEndForContentLength = 0;
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
_onContentSizeChange = (width: number, height: number) => {
|
|
1448
|
-
if (
|
|
1449
|
-
width > 0 &&
|
|
1450
|
-
height > 0 &&
|
|
1451
|
-
this.props.initialScrollIndex != null &&
|
|
1452
|
-
this.props.initialScrollIndex > 0 &&
|
|
1453
|
-
!this._hasTriggeredInitialScrollToIndex
|
|
1454
|
-
) {
|
|
1455
|
-
if (this.props.contentOffset == null) {
|
|
1456
|
-
this.scrollToIndex({
|
|
1457
|
-
animated: false,
|
|
1458
|
-
index: this.props.initialScrollIndex,
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
this._hasTriggeredInitialScrollToIndex = true;
|
|
1462
|
-
}
|
|
1463
|
-
if (this.props.onContentSizeChange) {
|
|
1464
|
-
this.props.onContentSizeChange(width, height);
|
|
1465
|
-
}
|
|
1466
|
-
this._scrollMetrics.contentLength = this._selectLength({height, width});
|
|
1467
|
-
this._scheduleCellsToRenderUpdate();
|
|
1468
|
-
this._maybeCallOnEndReached();
|
|
1469
|
-
};
|
|
1470
|
-
|
|
1471
|
-
/* Translates metrics from a scroll event in a parent VirtualizedList into
|
|
1472
|
-
* coordinates relative to the child list.
|
|
1473
|
-
*/
|
|
1474
|
-
_convertParentScrollMetrics = (metrics: {
|
|
1475
|
-
visibleLength: number,
|
|
1476
|
-
offset: number,
|
|
1477
|
-
...
|
|
1478
|
-
}): $FlowFixMe => {
|
|
1479
|
-
// Offset of the top of the nested list relative to the top of its parent's viewport
|
|
1480
|
-
const offset = metrics.offset - this._offsetFromParentVirtualizedList;
|
|
1481
|
-
// Child's visible length is the same as its parent's
|
|
1482
|
-
const visibleLength = metrics.visibleLength;
|
|
1483
|
-
const dOffset = offset - this._scrollMetrics.offset;
|
|
1484
|
-
const contentLength = this._scrollMetrics.contentLength;
|
|
1485
|
-
|
|
1486
|
-
return {
|
|
1487
|
-
visibleLength,
|
|
1488
|
-
contentLength,
|
|
1489
|
-
offset,
|
|
1490
|
-
dOffset,
|
|
1491
|
-
};
|
|
1492
|
-
};
|
|
1493
|
-
|
|
1494
|
-
_onScroll = (e: Object) => {
|
|
1495
|
-
this._nestedChildLists.forEach(childList => {
|
|
1496
|
-
childList._onScroll(e);
|
|
1497
|
-
});
|
|
1498
|
-
if (this.props.onScroll) {
|
|
1499
|
-
this.props.onScroll(e);
|
|
1500
|
-
}
|
|
1501
|
-
const timestamp = e.timeStamp;
|
|
1502
|
-
let visibleLength = this._selectLength(e.nativeEvent.layoutMeasurement);
|
|
1503
|
-
let contentLength = this._selectLength(e.nativeEvent.contentSize);
|
|
1504
|
-
let offset = this._selectOffset(e.nativeEvent.contentOffset);
|
|
1505
|
-
let dOffset = offset - this._scrollMetrics.offset;
|
|
1506
|
-
|
|
1507
|
-
if (this._isNestedWithSameOrientation()) {
|
|
1508
|
-
if (this._scrollMetrics.contentLength === 0) {
|
|
1509
|
-
// Ignore scroll events until onLayout has been called and we
|
|
1510
|
-
// know our offset from our offset from our parent
|
|
1511
|
-
return;
|
|
1512
|
-
}
|
|
1513
|
-
({visibleLength, contentLength, offset, dOffset} =
|
|
1514
|
-
this._convertParentScrollMetrics({
|
|
1515
|
-
visibleLength,
|
|
1516
|
-
offset,
|
|
1517
|
-
}));
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
const dt = this._scrollMetrics.timestamp
|
|
1521
|
-
? Math.max(1, timestamp - this._scrollMetrics.timestamp)
|
|
1522
|
-
: 1;
|
|
1523
|
-
const velocity = dOffset / dt;
|
|
1524
|
-
|
|
1525
|
-
if (
|
|
1526
|
-
dt > 500 &&
|
|
1527
|
-
this._scrollMetrics.dt > 500 &&
|
|
1528
|
-
contentLength > 5 * visibleLength &&
|
|
1529
|
-
!this._hasWarned.perf
|
|
1530
|
-
) {
|
|
1531
|
-
infoLog(
|
|
1532
|
-
'VirtualizedList: You have a large list that is slow to update - make sure your ' +
|
|
1533
|
-
'renderItem function renders components that follow React performance best practices ' +
|
|
1534
|
-
'like PureComponent, shouldComponentUpdate, etc.',
|
|
1535
|
-
{dt, prevDt: this._scrollMetrics.dt, contentLength},
|
|
1536
|
-
);
|
|
1537
|
-
this._hasWarned.perf = true;
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
// For invalid negative values (w/ RTL), set this to 1.
|
|
1541
|
-
const zoomScale = e.nativeEvent.zoomScale < 0 ? 1 : e.nativeEvent.zoomScale;
|
|
1542
|
-
this._scrollMetrics = {
|
|
1543
|
-
contentLength,
|
|
1544
|
-
dt,
|
|
1545
|
-
dOffset,
|
|
1546
|
-
offset,
|
|
1547
|
-
timestamp,
|
|
1548
|
-
velocity,
|
|
1549
|
-
visibleLength,
|
|
1550
|
-
zoomScale,
|
|
1551
|
-
};
|
|
1552
|
-
this._updateViewableItems(this.props, this.state.cellsAroundViewport);
|
|
1553
|
-
if (!this.props) {
|
|
1554
|
-
return;
|
|
1555
|
-
}
|
|
1556
|
-
this._maybeCallOnEndReached();
|
|
1557
|
-
if (velocity !== 0) {
|
|
1558
|
-
this._fillRateHelper.activate();
|
|
1559
|
-
}
|
|
1560
|
-
this._computeBlankness();
|
|
1561
|
-
this._scheduleCellsToRenderUpdate();
|
|
1562
|
-
};
|
|
1563
|
-
|
|
1564
|
-
_scheduleCellsToRenderUpdate() {
|
|
1565
|
-
const {first, last} = this.state.cellsAroundViewport;
|
|
1566
|
-
const {offset, visibleLength, velocity} = this._scrollMetrics;
|
|
1567
|
-
const itemCount = this.props.getItemCount(this.props.data);
|
|
1568
|
-
let hiPri = false;
|
|
1569
|
-
const onEndReachedThreshold = onEndReachedThresholdOrDefault(
|
|
1570
|
-
this.props.onEndReachedThreshold,
|
|
1571
|
-
);
|
|
1572
|
-
const scrollingThreshold = (onEndReachedThreshold * visibleLength) / 2;
|
|
1573
|
-
// Mark as high priority if we're close to the start of the first item
|
|
1574
|
-
// But only if there are items before the first rendered item
|
|
1575
|
-
if (first > 0) {
|
|
1576
|
-
const distTop =
|
|
1577
|
-
offset - this.__getFrameMetricsApprox(first, this.props).offset;
|
|
1578
|
-
hiPri =
|
|
1579
|
-
hiPri || distTop < 0 || (velocity < -2 && distTop < scrollingThreshold);
|
|
1580
|
-
}
|
|
1581
|
-
// Mark as high priority if we're close to the end of the last item
|
|
1582
|
-
// But only if there are items after the last rendered item
|
|
1583
|
-
if (last >= 0 && last < itemCount - 1) {
|
|
1584
|
-
const distBottom =
|
|
1585
|
-
this.__getFrameMetricsApprox(last, this.props).offset -
|
|
1586
|
-
(offset + visibleLength);
|
|
1587
|
-
hiPri =
|
|
1588
|
-
hiPri ||
|
|
1589
|
-
distBottom < 0 ||
|
|
1590
|
-
(velocity > 2 && distBottom < scrollingThreshold);
|
|
1591
|
-
}
|
|
1592
|
-
// Only trigger high-priority updates if we've actually rendered cells,
|
|
1593
|
-
// and with that size estimate, accurately compute how many cells we should render.
|
|
1594
|
-
// Otherwise, it would just render as many cells as it can (of zero dimension),
|
|
1595
|
-
// each time through attempting to render more (limited by maxToRenderPerBatch),
|
|
1596
|
-
// starving the renderer from actually laying out the objects and computing _averageCellLength.
|
|
1597
|
-
// If this is triggered in an `componentDidUpdate` followed by a hiPri cellToRenderUpdate
|
|
1598
|
-
// We shouldn't do another hipri cellToRenderUpdate
|
|
1599
|
-
if (
|
|
1600
|
-
hiPri &&
|
|
1601
|
-
(this._averageCellLength || this.props.getItemLayout) &&
|
|
1602
|
-
!this._hiPriInProgress
|
|
1603
|
-
) {
|
|
1604
|
-
this._hiPriInProgress = true;
|
|
1605
|
-
// Don't worry about interactions when scrolling quickly; focus on filling content as fast
|
|
1606
|
-
// as possible.
|
|
1607
|
-
this._updateCellsToRenderBatcher.dispose({abort: true});
|
|
1608
|
-
this._updateCellsToRender();
|
|
1609
|
-
return;
|
|
1610
|
-
} else {
|
|
1611
|
-
this._updateCellsToRenderBatcher.schedule();
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
_onScrollBeginDrag = (e: ScrollEvent): void => {
|
|
1616
|
-
this._nestedChildLists.forEach(childList => {
|
|
1617
|
-
childList._onScrollBeginDrag(e);
|
|
1618
|
-
});
|
|
1619
|
-
this._viewabilityTuples.forEach(tuple => {
|
|
1620
|
-
tuple.viewabilityHelper.recordInteraction();
|
|
1621
|
-
});
|
|
1622
|
-
this._hasInteracted = true;
|
|
1623
|
-
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
|
|
1624
|
-
};
|
|
1625
|
-
|
|
1626
|
-
_onScrollEndDrag = (e: ScrollEvent): void => {
|
|
1627
|
-
this._nestedChildLists.forEach(childList => {
|
|
1628
|
-
childList._onScrollEndDrag(e);
|
|
1629
|
-
});
|
|
1630
|
-
const {velocity} = e.nativeEvent;
|
|
1631
|
-
if (velocity) {
|
|
1632
|
-
this._scrollMetrics.velocity = this._selectOffset(velocity);
|
|
1633
|
-
}
|
|
1634
|
-
this._computeBlankness();
|
|
1635
|
-
this.props.onScrollEndDrag && this.props.onScrollEndDrag(e);
|
|
1636
|
-
};
|
|
1637
|
-
|
|
1638
|
-
_onMomentumScrollBegin = (e: ScrollEvent): void => {
|
|
1639
|
-
this._nestedChildLists.forEach(childList => {
|
|
1640
|
-
childList._onMomentumScrollBegin(e);
|
|
1641
|
-
});
|
|
1642
|
-
this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
|
|
1643
|
-
};
|
|
1644
|
-
|
|
1645
|
-
_onMomentumScrollEnd = (e: ScrollEvent): void => {
|
|
1646
|
-
this._nestedChildLists.forEach(childList => {
|
|
1647
|
-
childList._onMomentumScrollEnd(e);
|
|
1648
|
-
});
|
|
1649
|
-
this._scrollMetrics.velocity = 0;
|
|
1650
|
-
this._computeBlankness();
|
|
1651
|
-
this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e);
|
|
1652
|
-
};
|
|
1653
|
-
|
|
1654
|
-
_updateCellsToRender = () => {
|
|
1655
|
-
this.setState((state, props) => {
|
|
1656
|
-
const cellsAroundViewport = this._adjustCellsAroundViewport(
|
|
1657
|
-
props,
|
|
1658
|
-
state.cellsAroundViewport,
|
|
1659
|
-
);
|
|
1660
|
-
const renderMask = VirtualizedList._createRenderMask(
|
|
1661
|
-
props,
|
|
1662
|
-
cellsAroundViewport,
|
|
1663
|
-
this._getNonViewportRenderRegions(props),
|
|
1664
|
-
);
|
|
1665
|
-
|
|
1666
|
-
if (
|
|
1667
|
-
cellsAroundViewport.first === state.cellsAroundViewport.first &&
|
|
1668
|
-
cellsAroundViewport.last === state.cellsAroundViewport.last &&
|
|
1669
|
-
renderMask.equals(state.renderMask)
|
|
1670
|
-
) {
|
|
1671
|
-
return null;
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
return {cellsAroundViewport, renderMask};
|
|
1675
|
-
});
|
|
1676
|
-
};
|
|
1677
|
-
|
|
1678
|
-
_createViewToken = (
|
|
1679
|
-
index: number,
|
|
1680
|
-
isViewable: boolean,
|
|
1681
|
-
props: FrameMetricProps,
|
|
1682
|
-
// $FlowFixMe[missing-local-annot]
|
|
1683
|
-
) => {
|
|
1684
|
-
const {data, getItem} = props;
|
|
1685
|
-
const item = getItem(data, index);
|
|
1686
|
-
return {
|
|
1687
|
-
index,
|
|
1688
|
-
item,
|
|
1689
|
-
key: this._keyExtractor(item, index, props),
|
|
1690
|
-
isViewable,
|
|
1691
|
-
};
|
|
1692
|
-
};
|
|
1693
|
-
|
|
1694
|
-
/**
|
|
1695
|
-
* Gets an approximate offset to an item at a given index. Supports
|
|
1696
|
-
* fractional indices.
|
|
1697
|
-
*/
|
|
1698
|
-
_getOffsetApprox = (index: number, props: FrameMetricProps): number => {
|
|
1699
|
-
if (Number.isInteger(index)) {
|
|
1700
|
-
return this.__getFrameMetricsApprox(index, props).offset;
|
|
1701
|
-
} else {
|
|
1702
|
-
const frameMetrics = this.__getFrameMetricsApprox(
|
|
1703
|
-
Math.floor(index),
|
|
1704
|
-
props,
|
|
1705
|
-
);
|
|
1706
|
-
const remainder = index - Math.floor(index);
|
|
1707
|
-
return frameMetrics.offset + remainder * frameMetrics.length;
|
|
1708
|
-
}
|
|
1709
|
-
};
|
|
1710
|
-
|
|
1711
|
-
__getFrameMetricsApprox: (
|
|
1712
|
-
index: number,
|
|
1713
|
-
props: FrameMetricProps,
|
|
1714
|
-
) => {
|
|
1715
|
-
length: number,
|
|
1716
|
-
offset: number,
|
|
1717
|
-
...
|
|
1718
|
-
} = (index, props) => {
|
|
1719
|
-
const frame = this._getFrameMetrics(index, props);
|
|
1720
|
-
if (frame && frame.index === index) {
|
|
1721
|
-
// check for invalid frames due to row re-ordering
|
|
1722
|
-
return frame;
|
|
1723
|
-
} else {
|
|
1724
|
-
const {data, getItemCount, getItemLayout} = props;
|
|
1725
|
-
invariant(
|
|
1726
|
-
index >= 0 && index < getItemCount(data),
|
|
1727
|
-
'Tried to get frame for out of range index ' + index,
|
|
1728
|
-
);
|
|
1729
|
-
invariant(
|
|
1730
|
-
!getItemLayout,
|
|
1731
|
-
'Should not have to estimate frames when a measurement metrics function is provided',
|
|
1732
|
-
);
|
|
1733
|
-
return {
|
|
1734
|
-
length: this._averageCellLength,
|
|
1735
|
-
offset: this._averageCellLength * index,
|
|
1736
|
-
};
|
|
1737
|
-
}
|
|
1738
|
-
};
|
|
1739
|
-
|
|
1740
|
-
_getFrameMetrics = (
|
|
1741
|
-
index: number,
|
|
1742
|
-
props: FrameMetricProps,
|
|
1743
|
-
): ?{
|
|
1744
|
-
length: number,
|
|
1745
|
-
offset: number,
|
|
1746
|
-
index: number,
|
|
1747
|
-
inLayout?: boolean,
|
|
1748
|
-
...
|
|
1749
|
-
} => {
|
|
1750
|
-
const {data, getItem, getItemCount, getItemLayout} = props;
|
|
1751
|
-
invariant(
|
|
1752
|
-
index >= 0 && index < getItemCount(data),
|
|
1753
|
-
'Tried to get frame for out of range index ' + index,
|
|
1754
|
-
);
|
|
1755
|
-
const item = getItem(data, index);
|
|
1756
|
-
const frame = item && this._frames[this._keyExtractor(item, index, props)];
|
|
1757
|
-
if (!frame || frame.index !== index) {
|
|
1758
|
-
if (getItemLayout) {
|
|
1759
|
-
/* $FlowFixMe[prop-missing] (>=0.63.0 site=react_native_fb) This comment
|
|
1760
|
-
* suppresses an error found when Flow v0.63 was deployed. To see the error
|
|
1761
|
-
* delete this comment and run Flow. */
|
|
1762
|
-
return getItemLayout(data, index);
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
return frame;
|
|
1766
|
-
};
|
|
1767
|
-
|
|
1768
|
-
_getNonViewportRenderRegions = (
|
|
1769
|
-
props: FrameMetricProps,
|
|
1770
|
-
): $ReadOnlyArray<{
|
|
1771
|
-
first: number,
|
|
1772
|
-
last: number,
|
|
1773
|
-
}> => {
|
|
1774
|
-
// Keep a viewport's worth of content around the last focused cell to allow
|
|
1775
|
-
// random navigation around it without any blanking. E.g. tabbing from one
|
|
1776
|
-
// focused item out of viewport to another.
|
|
1777
|
-
if (
|
|
1778
|
-
!(this._lastFocusedCellKey && this._cellRefs[this._lastFocusedCellKey])
|
|
1779
|
-
) {
|
|
1780
|
-
return [];
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
const lastFocusedCellRenderer = this._cellRefs[this._lastFocusedCellKey];
|
|
1784
|
-
const focusedCellIndex = lastFocusedCellRenderer.props.index;
|
|
1785
|
-
const itemCount = props.getItemCount(props.data);
|
|
1786
|
-
|
|
1787
|
-
// The cell may have been unmounted and have a stale index
|
|
1788
|
-
if (
|
|
1789
|
-
focusedCellIndex >= itemCount ||
|
|
1790
|
-
this._indicesToKeys.get(focusedCellIndex) !== this._lastFocusedCellKey
|
|
1791
|
-
) {
|
|
1792
|
-
return [];
|
|
1793
|
-
}
|
|
1794
|
-
|
|
1795
|
-
let first = focusedCellIndex;
|
|
1796
|
-
let heightOfCellsBeforeFocused = 0;
|
|
1797
|
-
for (
|
|
1798
|
-
let i = first - 1;
|
|
1799
|
-
i >= 0 && heightOfCellsBeforeFocused < this._scrollMetrics.visibleLength;
|
|
1800
|
-
i--
|
|
1801
|
-
) {
|
|
1802
|
-
first--;
|
|
1803
|
-
heightOfCellsBeforeFocused += this.__getFrameMetricsApprox(
|
|
1804
|
-
i,
|
|
1805
|
-
props,
|
|
1806
|
-
).length;
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
let last = focusedCellIndex;
|
|
1810
|
-
let heightOfCellsAfterFocused = 0;
|
|
1811
|
-
for (
|
|
1812
|
-
let i = last + 1;
|
|
1813
|
-
i < itemCount &&
|
|
1814
|
-
heightOfCellsAfterFocused < this._scrollMetrics.visibleLength;
|
|
1815
|
-
i++
|
|
1816
|
-
) {
|
|
1817
|
-
last++;
|
|
1818
|
-
heightOfCellsAfterFocused += this.__getFrameMetricsApprox(
|
|
1819
|
-
i,
|
|
1820
|
-
props,
|
|
1821
|
-
).length;
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
return [{first, last}];
|
|
1825
|
-
};
|
|
1826
|
-
|
|
1827
|
-
_updateViewableItems(
|
|
1828
|
-
props: FrameMetricProps,
|
|
1829
|
-
cellsAroundViewport: {first: number, last: number},
|
|
1830
|
-
) {
|
|
1831
|
-
this._viewabilityTuples.forEach(tuple => {
|
|
1832
|
-
tuple.viewabilityHelper.onUpdate(
|
|
1833
|
-
props,
|
|
1834
|
-
this._scrollMetrics.offset,
|
|
1835
|
-
this._scrollMetrics.visibleLength,
|
|
1836
|
-
this._getFrameMetrics,
|
|
1837
|
-
this._createViewToken,
|
|
1838
|
-
tuple.onViewableItemsChanged,
|
|
1839
|
-
cellsAroundViewport,
|
|
1840
|
-
);
|
|
1841
|
-
});
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
const styles = StyleSheet.create({
|
|
1846
|
-
verticallyInverted: {
|
|
1847
|
-
transform: [{scaleY: -1}],
|
|
1848
|
-
},
|
|
1849
|
-
horizontallyInverted: {
|
|
1850
|
-
transform: [{scaleX: -1}],
|
|
1851
|
-
},
|
|
1852
|
-
debug: {
|
|
1853
|
-
flex: 1,
|
|
1854
|
-
},
|
|
1855
|
-
debugOverlayBase: {
|
|
1856
|
-
position: 'absolute',
|
|
1857
|
-
top: 0,
|
|
1858
|
-
right: 0,
|
|
1859
|
-
},
|
|
1860
|
-
debugOverlay: {
|
|
1861
|
-
bottom: 0,
|
|
1862
|
-
width: 20,
|
|
1863
|
-
borderColor: 'blue',
|
|
1864
|
-
borderWidth: 1,
|
|
1865
|
-
},
|
|
1866
|
-
debugOverlayFrame: {
|
|
1867
|
-
left: 0,
|
|
1868
|
-
backgroundColor: 'orange',
|
|
1869
|
-
},
|
|
1870
|
-
debugOverlayFrameLast: {
|
|
1871
|
-
left: 0,
|
|
1872
|
-
borderColor: 'green',
|
|
1873
|
-
borderWidth: 2,
|
|
1874
|
-
},
|
|
1875
|
-
debugOverlayFrameVis: {
|
|
1876
|
-
left: 0,
|
|
1877
|
-
borderColor: 'red',
|
|
1878
|
-
borderWidth: 2,
|
|
1879
|
-
},
|
|
1880
|
-
});
|
|
18
|
+
export type {
|
|
19
|
+
RenderItemProps,
|
|
20
|
+
RenderItemType,
|
|
21
|
+
Separators,
|
|
22
|
+
} from '@react-native/virtualized-lists';
|
|
23
|
+
module.exports = VirtualizedList;
|