@shopify/flash-list 2.0.0-alpha.21 → 2.0.0-alpha.22
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/dist/AnimatedFlashList.js +2 -2
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +1 -167
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +3 -595
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +2 -63
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js.map +1 -1
- package/dist/__tests__/ViewabilityHelper.test.js +3 -4
- package/dist/__tests__/ViewabilityHelper.test.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js +2 -1
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +2 -4
- package/dist/benchmark/useBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useBenchmark.js +12 -24
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +2 -1
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/errors/ErrorMessages.d.ts +16 -0
- package/dist/errors/ErrorMessages.d.ts.map +1 -0
- package/dist/errors/ErrorMessages.js +19 -0
- package/dist/errors/ErrorMessages.js.map +1 -0
- package/dist/errors/WarningMessages.d.ts +4 -0
- package/dist/errors/WarningMessages.d.ts.map +1 -0
- package/dist/errors/WarningMessages.js +7 -0
- package/dist/errors/WarningMessages.js.map +1 -0
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -29
- package/dist/index.js.map +1 -1
- package/dist/isNewArch.d.ts +2 -0
- package/dist/isNewArch.d.ts.map +1 -0
- package/dist/isNewArch.js +25 -0
- package/dist/isNewArch.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +1 -22
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +1 -16
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +1 -22
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +1 -22
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +1 -15
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +1 -16
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +1 -23
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +1 -18
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerView.js +5 -0
- package/dist/recyclerview/RecyclerView.js.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.js +9 -8
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
- package/dist/recyclerview/RecyclerViewProps.d.ts +1 -8
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.js +4 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.js +2 -1
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -1
- package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.d.ts +2 -2
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js +2 -4
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js.map +1 -1
- package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.d.ts +3 -3
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.js +16 -16
- package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -14
- package/src/AnimatedFlashList.ts +2 -2
- package/src/FlashList.ts +1 -0
- package/src/FlashListProps.ts +3 -79
- package/src/__tests__/ViewabilityHelper.test.ts +13 -14
- package/src/benchmark/JSFPSMonitor.ts +3 -3
- package/src/benchmark/useBenchmark.ts +12 -40
- package/src/benchmark/useFlatListBenchmark.ts +3 -1
- package/src/errors/ErrorMessages.ts +26 -0
- package/src/errors/WarningMessages.ts +4 -0
- package/src/index.ts +7 -43
- package/src/isNewArch.ts +25 -0
- package/src/native/config/PlatformHelper.android.ts +1 -25
- package/src/native/config/PlatformHelper.ios.ts +1 -24
- package/src/native/config/PlatformHelper.ts +1 -25
- package/src/native/config/PlatformHelper.web.ts +1 -30
- package/src/recyclerview/RecyclerView.tsx +5 -0
- package/src/recyclerview/RecyclerViewManager.ts +9 -18
- package/src/recyclerview/RecyclerViewProps.ts +1 -11
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +4 -0
- package/src/recyclerview/layout-managers/LayoutManager.ts +2 -1
- package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -9
- package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +18 -20
- package/RNFlashList.podspec +0 -37
- package/android/build.gradle +0 -89
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutShadow.kt +0 -105
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt +0 -158
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutViewManager.kt +0 -70
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/BlankAreaEvent.kt +0 -29
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainer.java +0 -16
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerImpl.kt +0 -16
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerManager.kt +0 -34
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/FlashListPackage.kt +0 -19
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerDelegate.java +0 -47
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerInterface.java +0 -21
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerDelegate.java +0 -32
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerInterface.java +0 -16
- package/android/src/test/java/com/shopify/reactnative/flash_list/AutoLayoutShadowTest.kt +0 -147
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/Rect.kt +0 -61
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestCollection.kt +0 -6
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestDataModel.kt +0 -8
- package/android/src/test/resources/LayoutTestData.json +0 -788
- package/dist/GridLayoutProviderWithProps.d.ts +0 -42
- package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
- package/dist/GridLayoutProviderWithProps.js +0 -114
- package/dist/GridLayoutProviderWithProps.js.map +0 -1
- package/dist/MasonryFlashList.d.ts +0 -51
- package/dist/MasonryFlashList.d.ts.map +0 -1
- package/dist/MasonryFlashList.js +0 -252
- package/dist/MasonryFlashList.js.map +0 -1
- package/dist/PureComponentWrapper.d.ts +0 -22
- package/dist/PureComponentWrapper.d.ts.map +0 -1
- package/dist/PureComponentWrapper.js +0 -37
- package/dist/PureComponentWrapper.js.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.d.ts +0 -2
- package/dist/__tests__/ContentContainerUtils.test.d.ts.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.js +0 -85
- package/dist/__tests__/ContentContainerUtils.test.js.map +0 -1
- package/dist/__tests__/FlashList.test.d.ts +0 -2
- package/dist/__tests__/FlashList.test.d.ts.map +0 -1
- package/dist/__tests__/FlashList.test.js +0 -902
- package/dist/__tests__/FlashList.test.js.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +0 -2
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.js +0 -143
- package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.d.ts +0 -2
- package/dist/__tests__/MasonryFlashList.test.d.ts.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.js +0 -254
- package/dist/__tests__/MasonryFlashList.test.js.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.d.ts +0 -2
- package/dist/__tests__/PlatformHelper.web.test.d.ts.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.js +0 -33
- package/dist/__tests__/PlatformHelper.web.test.js.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.d.ts +0 -19
- package/dist/__tests__/helpers/mountFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.js +0 -44
- package/dist/__tests__/helpers/mountFlashList.js.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +0 -18
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.js +0 -49
- package/dist/__tests__/helpers/mountMasonryFlashList.js.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.d.ts +0 -2
- package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.js +0 -179
- package/dist/__tests__/useBlankAreaTracker.test.js.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +0 -34
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.js +0 -66
- package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
- package/dist/enableNewCore.d.ts +0 -3
- package/dist/enableNewCore.d.ts.map +0 -1
- package/dist/enableNewCore.js +0 -25
- package/dist/enableNewCore.js.map +0 -1
- package/dist/errors/CustomError.d.ts +0 -8
- package/dist/errors/CustomError.d.ts.map +0 -1
- package/dist/errors/CustomError.js +0 -14
- package/dist/errors/CustomError.js.map +0 -1
- package/dist/errors/ExceptionList.d.ts +0 -24
- package/dist/errors/ExceptionList.d.ts.map +0 -1
- package/dist/errors/ExceptionList.js +0 -26
- package/dist/errors/ExceptionList.js.map +0 -1
- package/dist/errors/Warnings.d.ts +0 -9
- package/dist/errors/Warnings.d.ts.map +0 -1
- package/dist/errors/Warnings.js +0 -13
- package/dist/errors/Warnings.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -22
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.js +0 -48
- package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -4
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -5
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -4
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -16
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -3
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
- package/dist/native/cell-container/CellContainer.android.d.ts +0 -6
- package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.android.js +0 -9
- package/dist/native/cell-container/CellContainer.android.js.map +0 -1
- package/dist/native/cell-container/CellContainer.d.ts +0 -8
- package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.d.ts +0 -6
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.js +0 -9
- package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
- package/dist/native/cell-container/CellContainer.js +0 -11
- package/dist/native/cell-container/CellContainer.js.map +0 -1
- package/dist/native/cell-container/CellContainer.web.d.ts +0 -7
- package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.web.js +0 -13
- package/dist/native/cell-container/CellContainer.web.js.map +0 -1
- package/dist/specs/AutoLayoutNativeComponent.d.ts +0 -18
- package/dist/specs/AutoLayoutNativeComponent.d.ts.map +0 -1
- package/dist/specs/AutoLayoutNativeComponent.js +0 -6
- package/dist/specs/AutoLayoutNativeComponent.js.map +0 -1
- package/dist/specs/CellContainerNativeComponent.d.ts +0 -8
- package/dist/specs/CellContainerNativeComponent.d.ts.map +0 -1
- package/dist/specs/CellContainerNativeComponent.js +0 -6
- package/dist/specs/CellContainerNativeComponent.js.map +0 -1
- package/dist/utils/ContentContainerUtils.d.ts +0 -27
- package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
- package/dist/utils/ContentContainerUtils.js +0 -48
- package/dist/utils/ContentContainerUtils.js.map +0 -1
- package/dist/viewability/ViewToken.d.ts.map +0 -1
- package/dist/viewability/ViewToken.js.map +0 -1
- package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.js.map +0 -1
- package/ios/RNFlashList.xcodeproj/project.pbxproj +0 -3
- package/ios/RNFlashList.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/Sources/AutoLayoutView.swift +0 -294
- package/ios/Sources/AutoLayoutViewComponentView.h +0 -16
- package/ios/Sources/AutoLayoutViewComponentView.mm +0 -90
- package/ios/Sources/AutoLayoutViewManager.mm +0 -14
- package/ios/Sources/AutoLayoutViewManager.swift +0 -12
- package/ios/Sources/CellContainerComponentView.h +0 -18
- package/ios/Sources/CellContainerComponentView.mm +0 -62
- package/ios/Sources/CellContainerManager.mm +0 -8
- package/ios/Sources/CellContainerManager.swift +0 -12
- package/ios/Sources/FlatListPro-Bridging-Header.h +0 -11
- package/ios/Tests/AutoLayoutViewTests.swift +0 -113
- package/src/FlashList.tsx +0 -953
- package/src/GridLayoutProviderWithProps.ts +0 -180
- package/src/MasonryFlashList.tsx +0 -476
- package/src/PureComponentWrapper.tsx +0 -42
- package/src/__tests__/ContentContainerUtils.test.ts +0 -130
- package/src/__tests__/FlashList.test.tsx +0 -1001
- package/src/__tests__/GridLayoutProviderWithProps.test.ts +0 -179
- package/src/__tests__/MasonryFlashList.test.ts +0 -292
- package/src/__tests__/PlatformHelper.web.test.ts +0 -45
- package/src/__tests__/helpers/mountFlashList.tsx +0 -62
- package/src/__tests__/helpers/mountMasonryFlashList.tsx +0 -70
- package/src/__tests__/useBlankAreaTracker.test.tsx +0 -206
- package/src/benchmark/useBlankAreaTracker.ts +0 -117
- package/src/enableNewCore.ts +0 -24
- package/src/errors/CustomError.ts +0 -10
- package/src/errors/ExceptionList.ts +0 -28
- package/src/errors/Warnings.ts +0 -15
- package/src/native/auto-layout/AutoLayoutView.tsx +0 -73
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -17
- package/src/native/cell-container/CellContainer.android.ts +0 -7
- package/src/native/cell-container/CellContainer.ios.ts +0 -7
- package/src/native/cell-container/CellContainer.tsx +0 -14
- package/src/native/cell-container/CellContainer.web.tsx +0 -9
- package/src/specs/AutoLayoutNativeComponent.ts +0 -24
- package/src/specs/CellContainerNativeComponent.ts +0 -9
- package/src/utils/ContentContainerUtils.ts +0 -92
- /package/dist/{viewability → recyclerview/viewability}/ViewToken.d.ts +0 -0
- /package/dist/{viewability → recyclerview/viewability}/ViewToken.js +0 -0
- /package/src/{viewability → recyclerview/viewability}/ViewToken.ts +0 -0
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from "react-native";
|
|
21
21
|
|
|
22
22
|
import { FlashListRef } from "../FlashListRef";
|
|
23
|
+
import { ErrorMessages } from "../errors/ErrorMessages";
|
|
23
24
|
|
|
24
25
|
import { RVDimension } from "./layout-managers/LayoutManager";
|
|
25
26
|
import {
|
|
@@ -384,6 +385,9 @@ const RecyclerViewComponent = <T,>(
|
|
|
384
385
|
stickyHeaderIndices &&
|
|
385
386
|
stickyHeaderIndices.length > 0
|
|
386
387
|
) {
|
|
388
|
+
if (horizontal) {
|
|
389
|
+
throw new Error(ErrorMessages.stickyHeadersNotSupportedForHorizontal);
|
|
390
|
+
}
|
|
387
391
|
return (
|
|
388
392
|
<StickyHeaders
|
|
389
393
|
stickyHeaderIndices={stickyHeaderIndices}
|
|
@@ -402,6 +406,7 @@ const RecyclerViewComponent = <T,>(
|
|
|
402
406
|
stickyHeaderIndices,
|
|
403
407
|
renderItem,
|
|
404
408
|
scrollY,
|
|
409
|
+
horizontal,
|
|
405
410
|
recyclerViewManager,
|
|
406
411
|
extraData,
|
|
407
412
|
]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ErrorMessages } from "../errors/ErrorMessages";
|
|
2
2
|
|
|
3
|
+
import ViewabilityManager from "./viewability/ViewabilityManager";
|
|
3
4
|
import { ConsecutiveNumbers } from "./helpers/ConsecutiveNumbers";
|
|
4
5
|
import { RVGridLayoutManagerImpl } from "./layout-managers/GridLayoutManager";
|
|
5
6
|
import {
|
|
@@ -131,9 +132,7 @@ export class RecyclerViewManager<T> {
|
|
|
131
132
|
|
|
132
133
|
getLayout(index: number) {
|
|
133
134
|
if (!this.layoutManager) {
|
|
134
|
-
throw new Error(
|
|
135
|
-
"LayoutManager is not initialized, layout info is unavailable"
|
|
136
|
-
);
|
|
135
|
+
throw new Error(ErrorMessages.layoutManagerNotInitializedLayoutInfo);
|
|
137
136
|
}
|
|
138
137
|
return this.layoutManager.getLayout(index);
|
|
139
138
|
}
|
|
@@ -152,9 +151,7 @@ export class RecyclerViewManager<T> {
|
|
|
152
151
|
// Doesn't include header / foot etc
|
|
153
152
|
getChildContainerDimensions() {
|
|
154
153
|
if (!this.layoutManager) {
|
|
155
|
-
throw new Error(
|
|
156
|
-
"LayoutManager is not initialized, child container layout is unavailable"
|
|
157
|
-
);
|
|
154
|
+
throw new Error(ErrorMessages.layoutManagerNotInitializedChildContainer);
|
|
158
155
|
}
|
|
159
156
|
return this.layoutManager.getLayoutSize();
|
|
160
157
|
}
|
|
@@ -165,9 +162,7 @@ export class RecyclerViewManager<T> {
|
|
|
165
162
|
|
|
166
163
|
getWindowSize() {
|
|
167
164
|
if (!this.layoutManager) {
|
|
168
|
-
throw new Error(
|
|
169
|
-
"LayoutManager is not initialized, window size is unavailable"
|
|
170
|
-
);
|
|
165
|
+
throw new Error(ErrorMessages.layoutManagerNotInitializedWindowSize);
|
|
171
166
|
}
|
|
172
167
|
return this.layoutManager.getWindowsSize();
|
|
173
168
|
}
|
|
@@ -211,9 +206,7 @@ export class RecyclerViewManager<T> {
|
|
|
211
206
|
Boolean(this.layoutManager?.isHorizontal()) !==
|
|
212
207
|
Boolean(this.propsRef.horizontal)
|
|
213
208
|
) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
"Horizontal prop cannot be toggled, you can use a key on FlashList to recreate it."
|
|
216
|
-
);
|
|
209
|
+
throw new Error(ErrorMessages.horizontalPropCannotBeToggled);
|
|
217
210
|
}
|
|
218
211
|
if (this._isLayoutManagerDirty) {
|
|
219
212
|
this.layoutManager = undefined;
|
|
@@ -245,9 +238,7 @@ export class RecyclerViewManager<T> {
|
|
|
245
238
|
|
|
246
239
|
computeVisibleIndices() {
|
|
247
240
|
if (!this.layoutManager) {
|
|
248
|
-
throw new Error(
|
|
249
|
-
"LayoutManager is not initialized, visible indices are not unavailable"
|
|
250
|
-
);
|
|
241
|
+
throw new Error(ErrorMessages.layoutManagerNotInitializedVisibleIndices);
|
|
251
242
|
}
|
|
252
243
|
return this.engagedIndicesTracker.computeVisibleIndices(this.layoutManager);
|
|
253
244
|
}
|
|
@@ -360,10 +351,10 @@ export class RecyclerViewManager<T> {
|
|
|
360
351
|
private getLayoutManagerClass() {
|
|
361
352
|
// throw errors for incompatible props
|
|
362
353
|
if (this.propsRef.masonry && this.propsRef.horizontal) {
|
|
363
|
-
throw new Error(
|
|
354
|
+
throw new Error(ErrorMessages.masonryAndHorizontalIncompatible);
|
|
364
355
|
}
|
|
365
356
|
if (this.numColumns > 1 && this.propsRef.horizontal) {
|
|
366
|
-
throw new Error(
|
|
357
|
+
throw new Error(ErrorMessages.numColumnsAndHorizontalIncompatible);
|
|
367
358
|
}
|
|
368
359
|
return this.propsRef.masonry
|
|
369
360
|
? RVMasonryLayoutManagerImpl
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { FlashListProps } from "../FlashListProps";
|
|
4
|
-
|
|
5
|
-
export interface RecyclerViewProps<TItem>
|
|
6
|
-
extends Omit<FlashListProps<TItem>, "contentContainerStyle"> {
|
|
7
|
-
/**
|
|
8
|
-
* Style for the RecyclerView's parent container.
|
|
9
|
-
*/
|
|
10
|
-
contentContainerStyle?: ScrollViewProps["contentContainerStyle"];
|
|
11
|
-
}
|
|
1
|
+
export { FlashListProps as RecyclerViewProps } from "../FlashListProps";
|
|
@@ -21,6 +21,7 @@ import { adjustOffsetForRTL } from "../utils/adjustOffsetForRTL";
|
|
|
21
21
|
import { RVLayout } from "../layout-managers/LayoutManager";
|
|
22
22
|
import { ScrollAnchorRef } from "../components/ScrollAnchor";
|
|
23
23
|
import { PlatformConfig } from "../../native/config/PlatformHelper";
|
|
24
|
+
import { WarningMessages } from "../../errors/WarningMessages";
|
|
24
25
|
|
|
25
26
|
import { useUnmountFlag } from "./useUnmountFlag";
|
|
26
27
|
import { useUnmountAwareTimeout } from "./useUnmountAwareCallbacks";
|
|
@@ -548,6 +549,9 @@ export function useRecyclerViewController<T>(
|
|
|
548
549
|
* Disables item recycling in preparation for layout animations.
|
|
549
550
|
*/
|
|
550
551
|
prepareForLayoutAnimationRender: () => {
|
|
552
|
+
if (!recyclerViewManager.props.keyExtractor) {
|
|
553
|
+
console.warn(WarningMessages.keyExtractorNotDefinedForAnimation);
|
|
554
|
+
}
|
|
551
555
|
recyclerViewManager.animationOptimizationsEnabled = true;
|
|
552
556
|
},
|
|
553
557
|
};
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
findLastVisibleIndex,
|
|
8
8
|
} from "../utils/findVisibleIndex";
|
|
9
9
|
import { areDimensionsNotEqual } from "../utils/measureLayout";
|
|
10
|
+
import { ErrorMessages } from "../../errors/ErrorMessages";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Base abstract class for layout managers in the recycler view system.
|
|
@@ -224,7 +225,7 @@ export abstract class RVLayoutManager {
|
|
|
224
225
|
*/
|
|
225
226
|
getLayout(index: number): RVLayout {
|
|
226
227
|
if (index >= this.layouts.length) {
|
|
227
|
-
throw new Error(
|
|
228
|
+
throw new Error(ErrorMessages.indexOutOfBounds);
|
|
228
229
|
}
|
|
229
230
|
let layout = this.layouts[index];
|
|
230
231
|
if (!layout) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ViewabilityConfig } from "react-native";
|
|
2
|
-
import { Dimension, Layout } from "recyclerlistview";
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { RVDimension, RVLayout } from "../layout-managers/LayoutManager";
|
|
4
|
+
import { ErrorMessages } from "../../errors/ErrorMessages";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Helper class for computing viewable items based on the passed `viewabilityConfig`.
|
|
@@ -48,8 +47,8 @@ class ViewabilityHelper {
|
|
|
48
47
|
public updateViewableItems(
|
|
49
48
|
horizontal: boolean,
|
|
50
49
|
scrollOffset: number,
|
|
51
|
-
listSize:
|
|
52
|
-
getLayout: (index: number) =>
|
|
50
|
+
listSize: RVDimension,
|
|
51
|
+
getLayout: (index: number) => RVLayout | undefined,
|
|
53
52
|
viewableIndices?: number[]
|
|
54
53
|
) {
|
|
55
54
|
if (viewableIndices !== undefined) {
|
|
@@ -61,8 +60,8 @@ class ViewabilityHelper {
|
|
|
61
60
|
this.viewabilityConfig?.viewAreaCoveragePercentThreshold !== null &&
|
|
62
61
|
this.viewabilityConfig?.viewAreaCoveragePercentThreshold !== undefined
|
|
63
62
|
) {
|
|
64
|
-
throw new
|
|
65
|
-
|
|
63
|
+
throw new Error(
|
|
64
|
+
ErrorMessages.multipleViewabilityThresholdTypesNotSupported
|
|
66
65
|
);
|
|
67
66
|
}
|
|
68
67
|
if (
|
|
@@ -126,10 +125,10 @@ class ViewabilityHelper {
|
|
|
126
125
|
index: number,
|
|
127
126
|
horizontal: boolean,
|
|
128
127
|
scrollOffset: number,
|
|
129
|
-
listSize:
|
|
128
|
+
listSize: RVDimension,
|
|
130
129
|
viewAreaCoveragePercentThreshold: number | null | undefined,
|
|
131
130
|
itemVisiblePercentThreshold: number | null | undefined,
|
|
132
|
-
getLayout: (index: number) =>
|
|
131
|
+
getLayout: (index: number) => RVLayout | undefined
|
|
133
132
|
) {
|
|
134
133
|
const itemLayout = getLayout(index);
|
|
135
134
|
if (itemLayout === undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ViewabilityConfig } from "react-native";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { RecyclerViewManager } from "../RecyclerViewManager";
|
|
4
4
|
|
|
5
5
|
import ViewabilityHelper from "./ViewabilityHelper";
|
|
6
6
|
import ViewToken from "./ViewToken";
|
|
@@ -9,31 +9,31 @@ import ViewToken from "./ViewToken";
|
|
|
9
9
|
* Manager for viewability tracking. It holds multiple viewability callback pairs and keeps them updated.
|
|
10
10
|
*/
|
|
11
11
|
export default class ViewabilityManager<T> {
|
|
12
|
-
private
|
|
12
|
+
private rvManager: RecyclerViewManager<T>;
|
|
13
13
|
private viewabilityHelpers: ViewabilityHelper[] = [];
|
|
14
14
|
private hasInteracted = false;
|
|
15
15
|
|
|
16
|
-
constructor(
|
|
17
|
-
this.
|
|
16
|
+
constructor(rvManager: RecyclerViewManager<T>) {
|
|
17
|
+
this.rvManager = rvManager;
|
|
18
18
|
if (
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
rvManager.props.onViewableItemsChanged !== null &&
|
|
20
|
+
rvManager.props.onViewableItemsChanged !== undefined
|
|
21
21
|
) {
|
|
22
22
|
this.viewabilityHelpers.push(
|
|
23
23
|
this.createViewabilityHelper(
|
|
24
|
-
|
|
24
|
+
rvManager.props.viewabilityConfig,
|
|
25
25
|
(info) => {
|
|
26
|
-
|
|
26
|
+
rvManager.props.onViewableItemsChanged?.(info);
|
|
27
27
|
}
|
|
28
28
|
)
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
|
-
(
|
|
31
|
+
(rvManager.props.viewabilityConfigCallbackPairs ?? []).forEach(
|
|
32
32
|
(pair, index) => {
|
|
33
33
|
this.viewabilityHelpers.push(
|
|
34
34
|
this.createViewabilityHelper(pair.viewabilityConfig, (info) => {
|
|
35
35
|
const callback =
|
|
36
|
-
|
|
36
|
+
rvManager.props.viewabilityConfigCallbackPairs?.[index]
|
|
37
37
|
?.onViewableItemsChanged;
|
|
38
38
|
callback?.(info);
|
|
39
39
|
})
|
|
@@ -71,21 +71,19 @@ export default class ViewabilityManager<T> {
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
public updateViewableItems = (newViewableIndices?: number[]) => {
|
|
74
|
-
const listSize =
|
|
75
|
-
this.flashListRef.getWindowSize() ??
|
|
76
|
-
this.flashListRef.props.estimatedListSize;
|
|
74
|
+
const listSize = this.rvManager.getWindowSize();
|
|
77
75
|
if (listSize === undefined || !this.shouldListenToVisibleIndices) {
|
|
78
76
|
return;
|
|
79
77
|
}
|
|
80
78
|
const scrollOffset =
|
|
81
|
-
(this.
|
|
82
|
-
this.
|
|
79
|
+
(this.rvManager.getAbsoluteLastScrollOffset() ?? 0) -
|
|
80
|
+
this.rvManager.firstItemOffset;
|
|
83
81
|
this.viewabilityHelpers.forEach((viewabilityHelper) => {
|
|
84
82
|
viewabilityHelper.updateViewableItems(
|
|
85
|
-
this.
|
|
83
|
+
this.rvManager.props.horizontal ?? false,
|
|
86
84
|
scrollOffset,
|
|
87
85
|
listSize,
|
|
88
|
-
(index: number) => this.
|
|
86
|
+
(index: number) => this.rvManager.getLayout(index),
|
|
89
87
|
newViewableIndices
|
|
90
88
|
);
|
|
91
89
|
});
|
|
@@ -117,11 +115,11 @@ export default class ViewabilityManager<T> {
|
|
|
117
115
|
index: number,
|
|
118
116
|
isViewable: boolean
|
|
119
117
|
) => {
|
|
120
|
-
const item = this.
|
|
118
|
+
const item = this.rvManager.props.data![index];
|
|
121
119
|
const key =
|
|
122
|
-
item === undefined || this.
|
|
120
|
+
item === undefined || this.rvManager.props.keyExtractor === undefined
|
|
123
121
|
? index.toString()
|
|
124
|
-
: this.
|
|
122
|
+
: this.rvManager.props.keyExtractor(item, index);
|
|
125
123
|
return {
|
|
126
124
|
index,
|
|
127
125
|
isViewable,
|
package/RNFlashList.podspec
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'json'
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
-
new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED']
|
|
5
|
-
|
|
6
|
-
Pod::Spec.new do |s|
|
|
7
|
-
s.name = 'RNFlashList'
|
|
8
|
-
s.version = package['version']
|
|
9
|
-
s.summary = package['description']
|
|
10
|
-
s.homepage = package['homepage']
|
|
11
|
-
s.license = package['license']
|
|
12
|
-
s.author = package['author']
|
|
13
|
-
s.platforms = { :ios => '11.0', :tvos => '12.0' }
|
|
14
|
-
s.source = { git: 'https://github.com/shopify/flash-list.git', tag: "v#{s.version}" }
|
|
15
|
-
s.source_files = 'ios/Sources/**/*'
|
|
16
|
-
s.requires_arc = true
|
|
17
|
-
s.swift_version = '5.0'
|
|
18
|
-
|
|
19
|
-
if new_arch_enabled
|
|
20
|
-
s.pod_target_xcconfig = {
|
|
21
|
-
'OTHER_SWIFT_FLAGS' => '-D RCT_NEW_ARCH_ENABLED',
|
|
22
|
-
}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# install_modules_dependencies is available since RN 0.71
|
|
26
|
-
if respond_to?(:install_modules_dependencies, true)
|
|
27
|
-
install_modules_dependencies(s)
|
|
28
|
-
else
|
|
29
|
-
s.dependency "React-Core"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Tests spec
|
|
33
|
-
s.test_spec 'Tests' do |test_spec|
|
|
34
|
-
test_spec.source_files = 'ios/Tests/**/*'
|
|
35
|
-
test_spec.framework = 'XCTest'
|
|
36
|
-
end
|
|
37
|
-
end
|
package/android/build.gradle
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
def isNewArchitectureEnabled() {
|
|
2
|
-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
apply plugin: 'com.android.library'
|
|
6
|
-
|
|
7
|
-
apply plugin: 'kotlin-android'
|
|
8
|
-
|
|
9
|
-
if (isNewArchitectureEnabled()) {
|
|
10
|
-
apply plugin: 'com.facebook.react'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
def _ext = rootProject.ext
|
|
14
|
-
|
|
15
|
-
def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
|
|
16
|
-
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 30
|
|
17
|
-
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '30.0.2'
|
|
18
|
-
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 21
|
|
19
|
-
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 30
|
|
20
|
-
def _junitVersion = _ext.has('junitVersion') ? _ext.junitVersion : '4.13.2'
|
|
21
|
-
def _mockitoVersion = _ext.has('mockitoVersion') ? _ext.mockitoVersion : '3.2.0'
|
|
22
|
-
def _androidTestRunnerVersion = _ext.has('androidTestRunnerVersion') ? _ext.androidTestRunnerVersion : '1.1.0'
|
|
23
|
-
|
|
24
|
-
buildscript {
|
|
25
|
-
// buildscript is evaluated before any other task is executed, so this must be defined here
|
|
26
|
-
ext._kotlinVersion = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get('kotlinVersion') : '1.8.10'
|
|
27
|
-
|
|
28
|
-
repositories {
|
|
29
|
-
mavenCentral()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
dependencies {
|
|
33
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${_kotlinVersion}")
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
android {
|
|
38
|
-
compileSdkVersion _compileSdkVersion
|
|
39
|
-
buildToolsVersion _buildToolsVersion
|
|
40
|
-
|
|
41
|
-
// Conditional for compatibility with AGP <4.2.
|
|
42
|
-
if (project.android.hasProperty("namespace")) {
|
|
43
|
-
namespace = "com.shopify.reactnative.flash_list"
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
compileOptions {
|
|
47
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
48
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
sourceSets {
|
|
52
|
-
main.java.srcDirs += 'src/main/kotlin'
|
|
53
|
-
debug.java.srcDirs += 'src/debug/kotlin'
|
|
54
|
-
test.java.srcDirs += 'src/test/kotlin'
|
|
55
|
-
androidTest.java.srcDirs += 'src/androidTest/kotlin'
|
|
56
|
-
|
|
57
|
-
if (!isNewArchitectureEnabled()) {
|
|
58
|
-
main.java.srcDirs += ['src/paper/java']
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
defaultConfig {
|
|
63
|
-
minSdkVersion _minSdkVersion
|
|
64
|
-
targetSdkVersion _targetSdkVersion
|
|
65
|
-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
66
|
-
versionCode 1
|
|
67
|
-
versionName "1.0"
|
|
68
|
-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
lintOptions {
|
|
72
|
-
abortOnError false
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
testOptions {
|
|
76
|
-
unitTests.returnDefaultValues = true
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
dependencies {
|
|
81
|
-
compileOnly "com.facebook.react:react-native:${_reactNativeVersion}"
|
|
82
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${_kotlinVersion}"
|
|
83
|
-
testImplementation "junit:junit:${_junitVersion}"
|
|
84
|
-
testImplementation "org.mockito.kotlin:mockito-kotlin:${_mockitoVersion}"
|
|
85
|
-
testImplementation "org.mockito:mockito-inline:${_mockitoVersion}"
|
|
86
|
-
testImplementation 'com.google.code.gson:gson:2.8.9'
|
|
87
|
-
androidTestImplementation("androidx.test:runner:${_androidTestRunnerVersion}")
|
|
88
|
-
androidTestImplementation("androidx.test:rules:${_androidTestRunnerVersion}")
|
|
89
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
package com.shopify.reactnative.flash_list
|
|
2
|
-
|
|
3
|
-
class AutoLayoutShadow {
|
|
4
|
-
var horizontal: Boolean = false
|
|
5
|
-
var scrollOffset: Int = 0
|
|
6
|
-
var offsetFromStart: Int = 0
|
|
7
|
-
var windowSize: Int = 0
|
|
8
|
-
var renderOffset = 0
|
|
9
|
-
|
|
10
|
-
var blankOffsetAtStart = 0 // Tracks blank area from the top
|
|
11
|
-
var blankOffsetAtEnd = 0 // Tracks blank area from the bottom
|
|
12
|
-
|
|
13
|
-
var lastMaxBoundOverall = 0 // Tracks where the last pixel is drawn in the overall
|
|
14
|
-
|
|
15
|
-
private var lastMaxBound = 0 // Tracks where the last pixel is drawn in the visible window
|
|
16
|
-
private var lastMinBound = 0 // Tracks where first pixel is drawn in the visible window
|
|
17
|
-
|
|
18
|
-
/** Checks for overlaps or gaps between adjacent items and then applies a correction (Only Grid layouts with varying spans)
|
|
19
|
-
* Performance: RecyclerListView renders very small number of views and this is not going to trigger multiple layouts on Android side. Not expecting any major perf issue. */
|
|
20
|
-
fun clearGapsAndOverlaps(sortedItems: Array<CellContainer>) {
|
|
21
|
-
var maxBound = 0
|
|
22
|
-
var minBound = Int.MAX_VALUE
|
|
23
|
-
var maxBoundNeighbour = 0
|
|
24
|
-
lastMaxBoundOverall = 0
|
|
25
|
-
for (i in 0 until sortedItems.size - 1) {
|
|
26
|
-
val cell = sortedItems[i]
|
|
27
|
-
val neighbour = sortedItems[i + 1]
|
|
28
|
-
// Only apply correction if the next cell is consecutive.
|
|
29
|
-
val isNeighbourConsecutive = neighbour.index == cell.index + 1
|
|
30
|
-
if (isWithinBounds(cell) || isWithinBounds(neighbour)) {
|
|
31
|
-
if (!horizontal) {
|
|
32
|
-
maxBound = kotlin.math.max(maxBound, cell.bottom);
|
|
33
|
-
minBound = kotlin.math.min(minBound, cell.top);
|
|
34
|
-
maxBoundNeighbour = maxBound
|
|
35
|
-
if (isNeighbourConsecutive) {
|
|
36
|
-
if (cell.left < neighbour.left) {
|
|
37
|
-
if (cell.right != neighbour.left) {
|
|
38
|
-
neighbour.right = cell.right + neighbour.width
|
|
39
|
-
neighbour.left = cell.right
|
|
40
|
-
}
|
|
41
|
-
if (cell.top != neighbour.top) {
|
|
42
|
-
neighbour.bottom = cell.top + neighbour.height
|
|
43
|
-
neighbour.top = cell.top
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
neighbour.bottom = maxBound + neighbour.height
|
|
47
|
-
neighbour.top = maxBound
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (isWithinBounds(neighbour)) {
|
|
51
|
-
maxBoundNeighbour = kotlin.math.max(maxBound, neighbour.bottom)
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
maxBound = kotlin.math.max(maxBound, cell.right);
|
|
55
|
-
minBound = kotlin.math.min(minBound, cell.left);
|
|
56
|
-
maxBoundNeighbour = maxBound
|
|
57
|
-
if (isNeighbourConsecutive) {
|
|
58
|
-
if (cell.top < neighbour.top) {
|
|
59
|
-
if (cell.bottom != neighbour.top) {
|
|
60
|
-
neighbour.bottom = cell.bottom + neighbour.height
|
|
61
|
-
neighbour.top = cell.bottom
|
|
62
|
-
}
|
|
63
|
-
if (cell.left != neighbour.left) {
|
|
64
|
-
neighbour.right = cell.left + neighbour.width
|
|
65
|
-
neighbour.left = cell.left
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
neighbour.right = maxBound + neighbour.width
|
|
69
|
-
neighbour.left = maxBound
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (isWithinBounds(neighbour)) {
|
|
73
|
-
maxBoundNeighbour = kotlin.math.max(maxBound, neighbour.right)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
lastMaxBoundOverall = kotlin.math.max(lastMaxBoundOverall, if (horizontal) cell.right else cell.bottom)
|
|
78
|
-
lastMaxBoundOverall = kotlin.math.max(lastMaxBoundOverall, if (horizontal) neighbour.right else neighbour.bottom)
|
|
79
|
-
}
|
|
80
|
-
lastMaxBound = maxBoundNeighbour
|
|
81
|
-
lastMinBound = minBound
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Offset provided by react can be one frame behind the real one, it's important that this method is called with offset taken directly from
|
|
85
|
-
* scrollview object */
|
|
86
|
-
fun computeBlankFromGivenOffset(actualScrollOffset: Int, distanceFromWindowStart: Int, distanceFromWindowEnd: Int): Int {
|
|
87
|
-
val actualScrollOffset = actualScrollOffset - offsetFromStart;
|
|
88
|
-
blankOffsetAtStart = lastMinBound - actualScrollOffset - distanceFromWindowStart
|
|
89
|
-
blankOffsetAtEnd = actualScrollOffset + windowSize - renderOffset - lastMaxBound - distanceFromWindowEnd
|
|
90
|
-
return kotlin.math.max(blankOffsetAtStart, blankOffsetAtEnd)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** It's important to avoid correcting views outside the render window. An item that isn't being recycled might still remain in the view tree. If views outside get considered then gaps between
|
|
94
|
-
* unused items will cause algorithm to fail.*/
|
|
95
|
-
private fun isWithinBounds(cell: CellContainer): Boolean {
|
|
96
|
-
val scrollOffset = scrollOffset - offsetFromStart;
|
|
97
|
-
return if (!horizontal) {
|
|
98
|
-
(cell.top >= (scrollOffset - renderOffset) || cell.bottom >= (scrollOffset - renderOffset)) &&
|
|
99
|
-
(cell.top <= scrollOffset + windowSize || cell.bottom <= scrollOffset + windowSize)
|
|
100
|
-
} else {
|
|
101
|
-
(cell.left >= (scrollOffset - renderOffset) || cell.right >= (scrollOffset - renderOffset)) &&
|
|
102
|
-
(cell.left <= scrollOffset + windowSize || cell.right <= scrollOffset + windowSize)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|