react-native-nitro-list 0.1.1 → 0.1.2
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/ios/HybridNitroList.swift +10 -14
- package/lib/commonjs/cell/CellKeyGenerator.js +21 -0
- package/lib/commonjs/cell/CellKeyGenerator.js.map +1 -0
- package/lib/commonjs/cell/CellRecycler.js +48 -40
- package/lib/commonjs/cell/CellRecycler.js.map +1 -1
- package/lib/commonjs/cell/createCell.js +21 -0
- package/lib/commonjs/cell/createCell.js.map +1 -0
- package/lib/commonjs/cell/index.js +20 -0
- package/lib/commonjs/cell/index.js.map +1 -0
- package/lib/commonjs/getVisibleIndices.js.map +1 -1
- package/lib/commonjs/hooks/usePersistentCallback.js +36 -0
- package/lib/commonjs/hooks/usePersistentCallback.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/layout/MutableLinearLayout.js +78 -39
- package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -1
- package/lib/commonjs/layout/constants/layoutDefaults.js +19 -0
- package/lib/commonjs/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/commonjs/layout/index.js +0 -18
- package/lib/commonjs/layout/index.js.map +1 -1
- package/lib/commonjs/recycler/CellPool.js +46 -0
- package/lib/commonjs/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/recycler/RecyclerList.js +224 -0
- package/lib/commonjs/recycler/RecyclerList.js.map +1 -0
- package/lib/commonjs/types/Axis.js +2 -0
- package/lib/commonjs/{layout/LayoutProvider.js.map → types/Axis.js.map} +1 -1
- package/lib/commonjs/types/CellKey.js +2 -0
- package/lib/{module/layout/LayoutProvider.js.map → commonjs/types/CellKey.js.map} +1 -1
- package/lib/commonjs/types/CellType.js +2 -0
- package/lib/commonjs/{layout/LayoutRectangle.js.map → types/CellType.js.map} +1 -1
- package/lib/commonjs/types/VisibleRange.js +2 -0
- package/lib/{module/layout/LayoutRectangle.js.map → commonjs/types/VisibleRange.js.map} +1 -1
- package/lib/commonjs/{RecyclerList.types.js → types/VisibleRangeInput.js} +1 -1
- package/lib/commonjs/types/VisibleRangeInput.js.map +1 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/layout/LayoutRect.js +2 -0
- package/lib/commonjs/types/layout/LayoutRect.js.map +1 -0
- package/lib/commonjs/types/layout/LinearLayoutInput.js +6 -0
- package/lib/commonjs/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js +26 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/commonjs/types/layout/index.js +2 -0
- package/lib/commonjs/types/layout/index.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerCellInstance.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerCellInstance.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerListProps.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerListProps.js.map +1 -0
- package/lib/commonjs/types/recycler/index.js +2 -0
- package/lib/commonjs/types/recycler/index.js.map +1 -0
- package/lib/commonjs/{layout/LayoutProvider.js → types/scroll/ScrollMetrics.js} +1 -1
- package/lib/commonjs/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/commonjs/types/scroll/index.js +2 -0
- package/lib/commonjs/types/scroll/index.js.map +1 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js +71 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/commonjs/windowing/index.js +3 -3
- package/lib/commonjs/windowing/index.js.map +1 -1
- package/lib/module/cell/CellKeyGenerator.js +16 -0
- package/lib/module/cell/CellKeyGenerator.js.map +1 -0
- package/lib/module/cell/CellRecycler.js +48 -39
- package/lib/module/cell/CellRecycler.js.map +1 -1
- package/lib/module/cell/createCell.js +17 -0
- package/lib/module/cell/createCell.js.map +1 -0
- package/lib/module/cell/index.js +7 -0
- package/lib/module/cell/index.js.map +1 -0
- package/lib/module/getVisibleIndices.js.map +1 -1
- package/lib/module/hooks/usePersistentCallback.js +33 -0
- package/lib/module/hooks/usePersistentCallback.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/MutableLinearLayout.js +78 -38
- package/lib/module/layout/MutableLinearLayout.js.map +1 -1
- package/lib/module/layout/constants/layoutDefaults.js +15 -0
- package/lib/module/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/module/layout/index.js +0 -3
- package/lib/module/layout/index.js.map +1 -1
- package/lib/module/recycler/CellPool.js +41 -0
- package/lib/module/recycler/CellPool.js.map +1 -0
- package/lib/module/recycler/RecyclerList.js +221 -0
- package/lib/module/recycler/RecyclerList.js.map +1 -0
- package/lib/module/types/Axis.js +2 -0
- package/lib/module/types/Axis.js.map +1 -0
- package/lib/module/types/CellKey.js +2 -0
- package/lib/module/types/CellKey.js.map +1 -0
- package/lib/module/types/CellType.js +2 -0
- package/lib/module/types/CellType.js.map +1 -0
- package/lib/module/types/VisibleRange.js +2 -0
- package/lib/module/types/VisibleRange.js.map +1 -0
- package/lib/module/types/VisibleRangeInput.js +4 -0
- package/lib/module/types/VisibleRangeInput.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/layout/LayoutRect.js +2 -0
- package/lib/module/types/layout/LayoutRect.js.map +1 -0
- package/lib/module/types/layout/LinearLayoutInput.js +4 -0
- package/lib/module/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/module/types/layout/MainAxisPadding.js +22 -0
- package/lib/module/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/module/types/layout/index.js +2 -0
- package/lib/module/types/layout/index.js.map +1 -0
- package/lib/module/types/recycler/RecyclerCellInstance.js +4 -0
- package/lib/module/types/recycler/RecyclerCellInstance.js.map +1 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js +4 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/module/types/recycler/RecyclerListProps.js +4 -0
- package/lib/module/types/recycler/RecyclerListProps.js.map +1 -0
- package/lib/module/types/recycler/index.js +2 -0
- package/lib/module/types/recycler/index.js.map +1 -0
- package/lib/module/types/scroll/ScrollMetrics.js +4 -0
- package/lib/module/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/module/types/scroll/index.js +2 -0
- package/lib/module/types/scroll/index.js.map +1 -0
- package/lib/module/windowing/computeVisibleItemRange.js +67 -0
- package/lib/module/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/module/windowing/index.js +1 -1
- package/lib/module/windowing/index.js.map +1 -1
- package/lib/typescript/src/cell/Cell.d.ts +13 -4
- package/lib/typescript/src/cell/Cell.d.ts.map +1 -1
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts +11 -0
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts.map +1 -0
- package/lib/typescript/src/cell/CellRecycler.d.ts +19 -11
- package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -1
- package/lib/typescript/src/cell/createCell.d.ts +7 -0
- package/lib/typescript/src/cell/createCell.d.ts.map +1 -0
- package/lib/typescript/src/cell/index.d.ts +4 -0
- package/lib/typescript/src/cell/index.d.ts.map +1 -0
- package/lib/typescript/src/getVisibleIndices.d.ts +2 -2
- package/lib/typescript/src/getVisibleIndices.d.ts.map +1 -1
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts +16 -0
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts +45 -13
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -1
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts +13 -0
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts.map +1 -0
- package/lib/typescript/src/layout/index.d.ts +1 -4
- package/lib/typescript/src/layout/index.d.ts.map +1 -1
- package/lib/typescript/src/native/NitroList.types.d.ts +2 -2
- package/lib/typescript/src/native/NitroList.types.d.ts.map +1 -1
- package/lib/typescript/src/recycler/CellPool.d.ts +14 -0
- package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts +4 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +2 -2
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/Axis.d.ts +11 -0
- package/lib/typescript/src/types/Axis.d.ts.map +1 -0
- package/lib/typescript/src/types/CellKey.d.ts +10 -0
- package/lib/typescript/src/types/CellKey.d.ts.map +1 -0
- package/lib/typescript/src/types/CellType.d.ts +11 -0
- package/lib/typescript/src/types/CellType.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRange.d.ts +10 -0
- package/lib/typescript/src/types/VisibleRange.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts +35 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +8 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts +15 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts +10 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts +20 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/index.d.ts +4 -0
- package/lib/typescript/src/types/layout/index.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts +37 -0
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +8 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts +66 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/index.d.ts +4 -0
- package/lib/typescript/src/types/recycler/index.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts +15 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/index.d.ts +2 -0
- package/lib/typescript/src/types/scroll/index.d.ts.map +1 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts +15 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts.map +1 -0
- package/lib/typescript/src/windowing/index.d.ts +1 -1
- package/lib/typescript/src/windowing/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.cpp +7 -7
- package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/{JLayoutRectangle.hpp → JLayoutRect.hpp} +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/HybridNitroLayoutEngineSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{LayoutRectangle.kt → LayoutRect.kt} +5 -5
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +14 -14
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +3 -3
- package/nitrogen/generated/ios/c++/HybridNitroLayoutEngineSpecSwift.hpp +4 -4
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec_cxx.swift +5 -5
- package/nitrogen/generated/ios/swift/{LayoutRectangle.swift → LayoutRect.swift} +5 -5
- package/nitrogen/generated/shared/c++/HybridNitroLayoutEngineSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/{LayoutRectangle.hpp → LayoutRect.hpp} +11 -11
- package/package.json +1 -1
- package/src/cell/Cell.ts +13 -4
- package/src/cell/CellKeyGenerator.ts +17 -0
- package/src/cell/CellRecycler.ts +53 -43
- package/src/cell/createCell.ts +15 -0
- package/src/cell/index.ts +5 -0
- package/src/getVisibleIndices.ts +4 -2
- package/src/hooks/usePersistentCallback.ts +37 -0
- package/src/index.ts +1 -2
- package/src/layout/MutableLinearLayout.ts +91 -58
- package/src/layout/constants/layoutDefaults.ts +12 -0
- package/src/layout/index.ts +1 -4
- package/src/native/NitroList.types.ts +3 -2
- package/src/recycler/CellPool.ts +47 -0
- package/src/recycler/RecyclerList.tsx +304 -0
- package/src/specs/nitro-layout-engine.nitro.ts +2 -2
- package/src/types/Axis.ts +10 -0
- package/src/types/CellKey.ts +9 -0
- package/src/types/CellType.ts +10 -0
- package/src/types/VisibleRange.ts +9 -0
- package/src/types/VisibleRangeInput.ts +39 -0
- package/src/types/index.ts +15 -0
- package/src/types/layout/LayoutRect.ts +14 -0
- package/src/types/layout/LinearLayoutInput.ts +12 -0
- package/src/types/layout/MainAxisPadding.ts +23 -0
- package/src/types/layout/index.ts +3 -0
- package/src/types/recycler/RecyclerCellInstance.ts +40 -0
- package/src/types/recycler/RecyclerItemRenderer.ts +8 -0
- package/src/types/recycler/RecyclerListProps.ts +74 -0
- package/src/types/recycler/index.ts +3 -0
- package/src/types/scroll/ScrollMetrics.ts +18 -0
- package/src/types/scroll/index.ts +1 -0
- package/src/windowing/computeVisibleItemRange.ts +78 -0
- package/src/windowing/index.ts +1 -1
- package/lib/commonjs/RecyclerList.internal.js +0 -25
- package/lib/commonjs/RecyclerList.internal.js.map +0 -1
- package/lib/commonjs/RecyclerList.js +0 -171
- package/lib/commonjs/RecyclerList.js.map +0 -1
- package/lib/commonjs/RecyclerList.types.js.map +0 -1
- package/lib/commonjs/cell/StableKey.js +0 -10
- package/lib/commonjs/cell/StableKey.js.map +0 -1
- package/lib/commonjs/hooks/useCellRenderer.js +0 -62
- package/lib/commonjs/hooks/useCellRenderer.js.map +0 -1
- package/lib/commonjs/hooks/useStableCallback.js +0 -13
- package/lib/commonjs/hooks/useStableCallback.js.map +0 -1
- package/lib/commonjs/layout/EstimatedLayoutProvider.js +0 -30
- package/lib/commonjs/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/commonjs/layout/LayoutEngine.js +0 -21
- package/lib/commonjs/layout/LayoutEngine.js.map +0 -1
- package/lib/commonjs/layout/LayoutRectangle.js +0 -2
- package/lib/commonjs/viewability/ViewabilityHelper.js +0 -121
- package/lib/commonjs/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/commonjs/windowing/findVisibleIndexRange.js +0 -48
- package/lib/commonjs/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/module/RecyclerList.internal.js +0 -22
- package/lib/module/RecyclerList.internal.js.map +0 -1
- package/lib/module/RecyclerList.js +0 -166
- package/lib/module/RecyclerList.js.map +0 -1
- package/lib/module/RecyclerList.types.js +0 -4
- package/lib/module/RecyclerList.types.js.map +0 -1
- package/lib/module/cell/StableKey.js +0 -6
- package/lib/module/cell/StableKey.js.map +0 -1
- package/lib/module/hooks/useCellRenderer.js +0 -58
- package/lib/module/hooks/useCellRenderer.js.map +0 -1
- package/lib/module/hooks/useStableCallback.js +0 -9
- package/lib/module/hooks/useStableCallback.js.map +0 -1
- package/lib/module/layout/EstimatedLayoutProvider.js +0 -25
- package/lib/module/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/module/layout/LayoutEngine.js +0 -17
- package/lib/module/layout/LayoutEngine.js.map +0 -1
- package/lib/module/layout/LayoutProvider.js +0 -4
- package/lib/module/layout/LayoutRectangle.js +0 -2
- package/lib/module/viewability/ViewabilityHelper.js +0 -116
- package/lib/module/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/module/windowing/findVisibleIndexRange.js +0 -44
- package/lib/module/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/typescript/src/RecyclerList.d.ts +0 -26
- package/lib/typescript/src/RecyclerList.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.internal.d.ts +0 -9
- package/lib/typescript/src/RecyclerList.internal.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.types.d.ts +0 -18
- package/lib/typescript/src/RecyclerList.types.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts +0 -2
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts.map +0 -1
- package/lib/typescript/src/cell/StableKey.d.ts +0 -2
- package/lib/typescript/src/cell/StableKey.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCellRenderer.d.ts +0 -19
- package/lib/typescript/src/hooks/useCellRenderer.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useStableCallback.d.ts +0 -2
- package/lib/typescript/src/hooks/useStableCallback.d.ts.map +0 -1
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts +0 -15
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutEngine.d.ts +0 -10
- package/lib/typescript/src/layout/LayoutEngine.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutProvider.d.ts +0 -16
- package/lib/typescript/src/layout/LayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutRectangle.d.ts +0 -11
- package/lib/typescript/src/layout/LayoutRectangle.d.ts.map +0 -1
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts +0 -50
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts +0 -11
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts.map +0 -1
- package/src/RecyclerList.internal.ts +0 -38
- package/src/RecyclerList.tsx +0 -252
- package/src/RecyclerList.types.ts +0 -24
- package/src/__tests__/windowing/findVisibleIndexRange.test.ts +0 -55
- package/src/cell/StableKey.ts +0 -6
- package/src/hooks/useCellRenderer.ts +0 -86
- package/src/hooks/useStableCallback.ts +0 -13
- package/src/layout/EstimatedLayoutProvider.ts +0 -35
- package/src/layout/LayoutEngine.ts +0 -21
- package/src/layout/LayoutProvider.ts +0 -17
- package/src/layout/LayoutRectangle.ts +0 -10
- package/src/viewability/ViewabilityHelper.ts +0 -130
- package/src/windowing/findVisibleIndexRange.ts +0 -60
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RecyclerList = RecyclerList;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _MutableLinearLayout = require("../layout/MutableLinearLayout");
|
|
10
|
+
var _windowing = require("../windowing");
|
|
11
|
+
var _CellPool = require("./CellPool");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
/* =========================================================
|
|
15
|
+
* Constants
|
|
16
|
+
* =======================================================*/const DEFAULT_VIEWPORT_SIZE = 800;
|
|
17
|
+
const DEFAULT_ITEM_SIZE = 60;
|
|
18
|
+
const SCROLL_EVENT_THROTTLE = 16;
|
|
19
|
+
|
|
20
|
+
/* =========================================================
|
|
21
|
+
* RecyclerList
|
|
22
|
+
* =======================================================*/
|
|
23
|
+
|
|
24
|
+
function RecyclerList(props) {
|
|
25
|
+
const {
|
|
26
|
+
scrollDirection = 'vertical',
|
|
27
|
+
containerCrossAxisSize,
|
|
28
|
+
data,
|
|
29
|
+
itemMainAxisSizes,
|
|
30
|
+
padding = {
|
|
31
|
+
start: 0,
|
|
32
|
+
end: 0
|
|
33
|
+
},
|
|
34
|
+
itemSpacing,
|
|
35
|
+
bufferRatio = 1.3,
|
|
36
|
+
getCellType,
|
|
37
|
+
renderItem
|
|
38
|
+
} = props;
|
|
39
|
+
const isVertical = scrollDirection === 'vertical';
|
|
40
|
+
const itemCount = data.length;
|
|
41
|
+
|
|
42
|
+
/* -------------------------------------------------------
|
|
43
|
+
* Controlled render
|
|
44
|
+
* -----------------------------------------------------*/
|
|
45
|
+
|
|
46
|
+
const [, forceRender] = (0, _react.useState)(0);
|
|
47
|
+
|
|
48
|
+
/* -------------------------------------------------------
|
|
49
|
+
* Layout engine
|
|
50
|
+
* -----------------------------------------------------*/
|
|
51
|
+
|
|
52
|
+
const layoutEngineRef = (0, _react.useRef)(null);
|
|
53
|
+
const layoutSignatureRef = (0, _react.useRef)('');
|
|
54
|
+
const layoutSignature = [scrollDirection, containerCrossAxisSize, itemCount, itemMainAxisSizes, padding.start, padding.end, itemSpacing ?? 'default'].join('|');
|
|
55
|
+
if (!layoutEngineRef.current || layoutSignatureRef.current !== layoutSignature) {
|
|
56
|
+
const engine = new _MutableLinearLayout.MutableLinearLayout(scrollDirection);
|
|
57
|
+
engine.compute({
|
|
58
|
+
crossAxisSize: containerCrossAxisSize,
|
|
59
|
+
itemMainAxisSizes,
|
|
60
|
+
padding,
|
|
61
|
+
itemSpacing
|
|
62
|
+
});
|
|
63
|
+
layoutEngineRef.current = engine;
|
|
64
|
+
layoutSignatureRef.current = layoutSignature;
|
|
65
|
+
}
|
|
66
|
+
const layouts = layoutEngineRef.current.getLayouts();
|
|
67
|
+
const contentSize = layoutEngineRef.current.getContentSize();
|
|
68
|
+
|
|
69
|
+
/* -------------------------------------------------------
|
|
70
|
+
* Scroll metrics
|
|
71
|
+
* -----------------------------------------------------*/
|
|
72
|
+
|
|
73
|
+
const scrollOffsetRef = (0, _react.useRef)(0);
|
|
74
|
+
const viewportSizeRef = (0, _react.useRef)(DEFAULT_VIEWPORT_SIZE);
|
|
75
|
+
|
|
76
|
+
/* -------------------------------------------------------
|
|
77
|
+
* Cell pool + physical cells
|
|
78
|
+
* -----------------------------------------------------*/
|
|
79
|
+
|
|
80
|
+
const cellPoolRef = (0, _react.useRef)(new _CellPool.CellPool());
|
|
81
|
+
const activeCellsRef = (0, _react.useRef)([]);
|
|
82
|
+
const nextCellKeyRef = (0, _react.useRef)(0);
|
|
83
|
+
const createCell = type => ({
|
|
84
|
+
key: nextCellKeyRef.current++,
|
|
85
|
+
index: -1,
|
|
86
|
+
type
|
|
87
|
+
});
|
|
88
|
+
const MAX_CELLS = Math.ceil(viewportSizeRef.current / DEFAULT_ITEM_SIZE * bufferRatio) + 2;
|
|
89
|
+
|
|
90
|
+
/* -------------------------------------------------------
|
|
91
|
+
* Visible cell coordinator
|
|
92
|
+
* -----------------------------------------------------*/
|
|
93
|
+
|
|
94
|
+
const updateVisibleCells = () => {
|
|
95
|
+
const offset = scrollOffsetRef.current;
|
|
96
|
+
const viewportSize = viewportSizeRef.current;
|
|
97
|
+
const buffer = viewportSize * bufferRatio;
|
|
98
|
+
const range = (0, _windowing.computeVisibleItemRange)({
|
|
99
|
+
layouts,
|
|
100
|
+
offset,
|
|
101
|
+
viewportSize,
|
|
102
|
+
buffer,
|
|
103
|
+
isVertical
|
|
104
|
+
});
|
|
105
|
+
if (!range) return;
|
|
106
|
+
const nextCells = [];
|
|
107
|
+
const used = new Set();
|
|
108
|
+
for (let index = range.startIndex; index <= range.endIndex; index++) {
|
|
109
|
+
const item = data[index];
|
|
110
|
+
if (item === undefined) continue;
|
|
111
|
+
const type = getCellType(item, index);
|
|
112
|
+
|
|
113
|
+
// Register type once, with hard cap
|
|
114
|
+
if (!cellPoolRef.current.hasType(type)) {
|
|
115
|
+
cellPoolRef.current.registerType(type, MAX_CELLS);
|
|
116
|
+
for (let i = 0; i < MAX_CELLS; i++) {
|
|
117
|
+
cellPoolRef.current.release(createCell(type));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
let cell = cellPoolRef.current.acquire(type);
|
|
121
|
+
if (!cell) {
|
|
122
|
+
const reuseIndex = activeCellsRef.current.findIndex(c => c.type === type);
|
|
123
|
+
if (reuseIndex === -1) continue;
|
|
124
|
+
cell = activeCellsRef.current.splice(reuseIndex, 1)[0];
|
|
125
|
+
}
|
|
126
|
+
cell.index = index;
|
|
127
|
+
nextCells.push(cell);
|
|
128
|
+
used.add(cell);
|
|
129
|
+
}
|
|
130
|
+
for (const cell of activeCellsRef.current) {
|
|
131
|
+
if (!used.has(cell)) {
|
|
132
|
+
cellPoolRef.current.release(cell);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
let changed = nextCells.length !== activeCellsRef.current.length;
|
|
136
|
+
if (!changed) {
|
|
137
|
+
for (let i = 0; i < nextCells.length; i++) {
|
|
138
|
+
if (nextCells[i] !== activeCellsRef.current[i]) {
|
|
139
|
+
changed = true;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (changed) {
|
|
145
|
+
activeCellsRef.current = nextCells;
|
|
146
|
+
forceRender(v => v + 1);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/* -------------------------------------------------------
|
|
151
|
+
* Scroll handlers
|
|
152
|
+
* -----------------------------------------------------*/
|
|
153
|
+
|
|
154
|
+
const frameScheduledRef = (0, _react.useRef)(false);
|
|
155
|
+
const onScroll = e => {
|
|
156
|
+
scrollOffsetRef.current = isVertical ? e.nativeEvent.contentOffset.y : e.nativeEvent.contentOffset.x;
|
|
157
|
+
if (frameScheduledRef.current) return;
|
|
158
|
+
frameScheduledRef.current = true;
|
|
159
|
+
requestAnimationFrame(() => {
|
|
160
|
+
frameScheduledRef.current = false;
|
|
161
|
+
updateVisibleCells();
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const onLayout = e => {
|
|
165
|
+
viewportSizeRef.current = isVertical ? e.nativeEvent.layout.height : e.nativeEvent.layout.width;
|
|
166
|
+
updateVisibleCells();
|
|
167
|
+
};
|
|
168
|
+
(0, _react.useEffect)(() => {
|
|
169
|
+
updateVisibleCells();
|
|
170
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
171
|
+
}, []);
|
|
172
|
+
|
|
173
|
+
/* -------------------------------------------------------
|
|
174
|
+
* Render
|
|
175
|
+
* -----------------------------------------------------*/
|
|
176
|
+
|
|
177
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
178
|
+
onScroll: onScroll,
|
|
179
|
+
onLayout: onLayout,
|
|
180
|
+
horizontal: !isVertical,
|
|
181
|
+
scrollEventThrottle: SCROLL_EVENT_THROTTLE,
|
|
182
|
+
removeClippedSubviews: true,
|
|
183
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
184
|
+
style: isVertical ? {
|
|
185
|
+
height: contentSize
|
|
186
|
+
} : {
|
|
187
|
+
width: contentSize
|
|
188
|
+
},
|
|
189
|
+
children: activeCellsRef.current.map(cell => {
|
|
190
|
+
const index = cell.index;
|
|
191
|
+
const layout = layouts[index];
|
|
192
|
+
const item = data[index];
|
|
193
|
+
if (!layout || item === undefined) return null;
|
|
194
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
195
|
+
style: [styles.cell, isVertical ? {
|
|
196
|
+
top: layout.y,
|
|
197
|
+
height: layout.height,
|
|
198
|
+
width: layout.width
|
|
199
|
+
} : {
|
|
200
|
+
left: layout.x,
|
|
201
|
+
width: layout.width,
|
|
202
|
+
height: layout.height
|
|
203
|
+
}],
|
|
204
|
+
children: renderItem({
|
|
205
|
+
item,
|
|
206
|
+
index,
|
|
207
|
+
cell
|
|
208
|
+
})
|
|
209
|
+
}, cell.key);
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* =========================================================
|
|
216
|
+
* Styles
|
|
217
|
+
* =======================================================*/
|
|
218
|
+
|
|
219
|
+
const styles = _reactNative.StyleSheet.create({
|
|
220
|
+
cell: {
|
|
221
|
+
position: 'absolute'
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
//# sourceMappingURL=RecyclerList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_MutableLinearLayout","_windowing","_CellPool","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULT_VIEWPORT_SIZE","DEFAULT_ITEM_SIZE","SCROLL_EVENT_THROTTLE","RecyclerList","props","scrollDirection","containerCrossAxisSize","data","itemMainAxisSizes","padding","start","end","itemSpacing","bufferRatio","getCellType","renderItem","isVertical","itemCount","length","forceRender","useState","layoutEngineRef","useRef","layoutSignatureRef","layoutSignature","join","current","engine","MutableLinearLayout","compute","crossAxisSize","layouts","getLayouts","contentSize","getContentSize","scrollOffsetRef","viewportSizeRef","cellPoolRef","CellPool","activeCellsRef","nextCellKeyRef","createCell","type","key","index","MAX_CELLS","Math","ceil","updateVisibleCells","offset","viewportSize","buffer","range","computeVisibleItemRange","nextCells","used","Set","startIndex","endIndex","item","undefined","hasType","registerType","release","cell","acquire","reuseIndex","findIndex","c","splice","push","add","changed","v","frameScheduledRef","onScroll","nativeEvent","contentOffset","y","x","requestAnimationFrame","onLayout","layout","height","width","useEffect","jsx","ScrollView","horizontal","scrollEventThrottle","removeClippedSubviews","children","View","style","map","styles","top","left","StyleSheet","create","position"],"sourceRoot":"../../../src","sources":["recycler/RecyclerList.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAeA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAAqC,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAA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,MAAM,CAACE,KAAK;YACnBD,MAAM,EAAED,MAAM,CAACC;UACjB,CAAC,CACL;UAAAQ,QAAA,EAED5E,UAAU,CAAC;YAAE4C,IAAI;YAAEf,KAAK;YAAEoB;UAAK,CAAC;QAAC,GAhB7BA,IAAI,CAACrB,GAiBN,CAAC;MAEX,CAAC;IAAC,CACE;EAAC,CACG,CAAC;AAEjB;;AAEA;AACA;AACA;;AAEA,MAAMoD,MAAM,GAAGG,uBAAU,CAACC,MAAM,CAAC;EAC/BnC,IAAI,EAAE;IACJoC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/Axis.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/CellKey.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/CellType.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/VisibleRange.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/VisibleRangeInput.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ZERO_MAIN_AXIS_PADDING", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _MainAxisPadding.ZERO_MAIN_AXIS_PADDING;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _MainAxisPadding = require("./layout/MainAxisPadding");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_MainAxisPadding","require"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;;;;;;;AAKA,IAAAA,gBAAA,GAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/layout/LayoutRect.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/layout/LinearLayoutInput.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ZERO_MAIN_AXIS_PADDING = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Padding applied along the main scroll axis.
|
|
9
|
+
*
|
|
10
|
+
* This is a layout-level concept (not visual styling).
|
|
11
|
+
*
|
|
12
|
+
* - vertical → top / bottom
|
|
13
|
+
* - horizontal → left / right
|
|
14
|
+
*
|
|
15
|
+
* Uses start/end to remain RTL-safe and platform-neutral.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Shared zero-padding constant.
|
|
20
|
+
* Safe to reuse across layouts.
|
|
21
|
+
*/
|
|
22
|
+
const ZERO_MAIN_AXIS_PADDING = exports.ZERO_MAIN_AXIS_PADDING = {
|
|
23
|
+
start: 0,
|
|
24
|
+
end: 0
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=MainAxisPadding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ZERO_MAIN_AXIS_PADDING","exports","start","end"],"sourceRoot":"../../../../src","sources":["types/layout/MainAxisPadding.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACO,MAAMA,sBAAuC,GAAAC,OAAA,CAAAD,sBAAA,GAAG;EACrDE,KAAK,EAAE,CAAC;EACRC,GAAG,EAAE;AACP,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/layout/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/RecyclerCellInstance.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/RecyclerItemRenderer.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/RecyclerListProps.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/recycler/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/scroll/ScrollMetrics.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["types/scroll/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.computeVisibleItemRange = computeVisibleItemRange;
|
|
7
|
+
/**
|
|
8
|
+
* Computes the visible item index range using binary search.
|
|
9
|
+
*
|
|
10
|
+
* Responsibilities:
|
|
11
|
+
* - Determine which items intersect the visible window
|
|
12
|
+
* - Stay independent of rendering and recycling
|
|
13
|
+
*
|
|
14
|
+
* Performance:
|
|
15
|
+
* - O(log n) to locate the first visible item
|
|
16
|
+
* - O(k) to expand to the last visible item (k = visible count)
|
|
17
|
+
*/
|
|
18
|
+
function computeVisibleItemRange(input) {
|
|
19
|
+
const {
|
|
20
|
+
layouts,
|
|
21
|
+
offset,
|
|
22
|
+
viewportSize,
|
|
23
|
+
buffer,
|
|
24
|
+
isVertical
|
|
25
|
+
} = input;
|
|
26
|
+
const itemCount = layouts.length;
|
|
27
|
+
if (itemCount === 0) return null;
|
|
28
|
+
const windowStart = Math.max(0, offset - buffer);
|
|
29
|
+
const windowEnd = offset + viewportSize + buffer;
|
|
30
|
+
|
|
31
|
+
// --------------------------------------------------
|
|
32
|
+
// Binary search:
|
|
33
|
+
// First item whose END >= windowStart
|
|
34
|
+
// --------------------------------------------------
|
|
35
|
+
let low = 0;
|
|
36
|
+
let high = itemCount - 1;
|
|
37
|
+
let firstVisibleIndex = itemCount;
|
|
38
|
+
while (low <= high) {
|
|
39
|
+
const mid = low + high >>> 1;
|
|
40
|
+
const rect = layouts[mid];
|
|
41
|
+
const start = isVertical ? rect.y : rect.x;
|
|
42
|
+
const size = isVertical ? rect.height : rect.width;
|
|
43
|
+
const end = start + size;
|
|
44
|
+
if (end >= windowStart) {
|
|
45
|
+
firstVisibleIndex = mid;
|
|
46
|
+
high = mid - 1;
|
|
47
|
+
} else {
|
|
48
|
+
low = mid + 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (firstVisibleIndex === itemCount) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// --------------------------------------------------
|
|
56
|
+
// Linear scan forward:
|
|
57
|
+
// Last item whose START <= windowEnd
|
|
58
|
+
// --------------------------------------------------
|
|
59
|
+
let lastVisibleIndex = firstVisibleIndex;
|
|
60
|
+
for (let i = firstVisibleIndex + 1; i < itemCount; i++) {
|
|
61
|
+
const rect = layouts[i];
|
|
62
|
+
const start = isVertical ? rect.y : rect.x;
|
|
63
|
+
if (start > windowEnd) break;
|
|
64
|
+
lastVisibleIndex = i;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
startIndex: firstVisibleIndex,
|
|
68
|
+
endIndex: lastVisibleIndex
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=computeVisibleItemRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["computeVisibleItemRange","input","layouts","offset","viewportSize","buffer","isVertical","itemCount","length","windowStart","Math","max","windowEnd","low","high","firstVisibleIndex","mid","rect","start","y","x","size","height","width","end","lastVisibleIndex","i","startIndex","endIndex"],"sourceRoot":"../../../src","sources":["windowing/computeVisibleItemRange.ts"],"mappings":";;;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAuBA,CACrCC,KAAwB,EACH;EACrB,MAAM;IACJC,OAAO;IACPC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC;EACF,CAAC,GAAGL,KAAK;EAET,MAAMM,SAAS,GAAGL,OAAO,CAACM,MAAM;EAChC,IAAID,SAAS,KAAK,CAAC,EAAE,OAAO,IAAI;EAEhC,MAAME,WAAW,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAER,MAAM,GAAGE,MAAM,CAAC;EAChD,MAAMO,SAAS,GAAGT,MAAM,GAAGC,YAAY,GAAGC,MAAM;;EAEhD;EACA;EACA;EACA;EACA,IAAIQ,GAAG,GAAG,CAAC;EACX,IAAIC,I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
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "computeVisibleItemRange", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _computeVisibleItemRange.computeVisibleItemRange;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "useScrollMetrics", {
|
|
@@ -15,6 +15,6 @@ Object.defineProperty(exports, "useScrollMetrics", {
|
|
|
15
15
|
return _useScrollMetrics.useScrollMetrics;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
var _findVisibleIndexRange = require("./findVisibleIndexRange");
|
|
19
18
|
var _useScrollMetrics = require("./useScrollMetrics");
|
|
19
|
+
var _computeVisibleItemRange = require("./computeVisibleItemRange");
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_useScrollMetrics","require","_computeVisibleItemRange"],"sourceRoot":"../../../src","sources":["windowing/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Monotonic key generator for physical cell instances.
|
|
5
|
+
* Guarantees stable keys across the lifetime of the list.
|
|
6
|
+
*/
|
|
7
|
+
export class CellKeyGenerator {
|
|
8
|
+
nextId = 0;
|
|
9
|
+
next() {
|
|
10
|
+
return this.nextId++;
|
|
11
|
+
}
|
|
12
|
+
reset() {
|
|
13
|
+
this.nextId = 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=CellKeyGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CellKeyGenerator","nextId","next","reset"],"sourceRoot":"../../../src","sources":["cell/CellKeyGenerator.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,CAAC;EACpBC,MAAM,GAAG,CAAC;EAElBC,IAAIA,CAAA,EAAY;IACd,OAAO,IAAI,CAACD,MAAM,EAAE;EACtB;EAEAE,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACF,MAAM,GAAG,CAAC;EACjB;AACF","ignoreList":[]}
|