@shopify/flash-list 1.8.0 → 2.0.0-alpha.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/README.md +147 -26
- package/dist/FlashListProps.d.ts +65 -2
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/__tests__/AverageWindow.test.js +35 -0
- package/dist/__tests__/AverageWindow.test.js.map +1 -1
- package/dist/enableNewCore.d.ts +3 -0
- package/dist/enableNewCore.d.ts.map +1 -0
- package/dist/enableNewCore.js +25 -0
- package/dist/enableNewCore.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/recyclerview/RecycleKeyManager.d.ts +82 -0
- package/dist/recyclerview/RecycleKeyManager.d.ts.map +1 -0
- package/dist/recyclerview/RecycleKeyManager.js +135 -0
- package/dist/recyclerview/RecycleKeyManager.js.map +1 -0
- package/dist/recyclerview/RecyclerView.d.ts +12 -0
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerView.js +283 -0
- package/dist/recyclerview/RecyclerView.js.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts +12 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js +11 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts +52 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.js +323 -0
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts +9 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.js +3 -0
- package/dist/recyclerview/RecyclerViewProps.js.map +1 -0
- package/dist/recyclerview/ViewHolder.d.ts +45 -0
- package/dist/recyclerview/ViewHolder.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolder.js +96 -0
- package/dist/recyclerview/ViewHolder.js.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts +57 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.js +75 -0
- package/dist/recyclerview/ViewHolderCollection.js.map +1 -0
- package/dist/recyclerview/components/CompatScroller.d.ts +7 -0
- package/dist/recyclerview/components/CompatScroller.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatScroller.js +8 -0
- package/dist/recyclerview/components/CompatScroller.js.map +1 -0
- package/dist/recyclerview/components/CompatView.d.ts +7 -0
- package/dist/recyclerview/components/CompatView.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatView.js +8 -0
- package/dist/recyclerview/components/CompatView.js.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts +28 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.js +35 -0
- package/dist/recyclerview/components/ScrollAnchor.js.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts +38 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.js +119 -0
- package/dist/recyclerview/components/StickyHeaders.js.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts +51 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js +122 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts +59 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js +138 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts +19 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.js +103 -0
- package/dist/recyclerview/hooks/useBoundDetection.js.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts +12 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.js +43 -0
- package/dist/recyclerview/hooks/useLayoutState.js.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts +25 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.js +73 -0
- package/dist/recyclerview/hooks/useOnLoad.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts +72 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js +370 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts +6 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js +27 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts +16 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.js +54 -0
- package/dist/recyclerview/hooks/useRecyclingState.js.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts +27 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js +93 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts +11 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js +28 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts +65 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js +204 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts +281 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js +250 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts +52 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js +191 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts +73 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js +274 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts +12 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js +18 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js.map +1 -0
- package/dist/recyclerview/utils/componentUtils.d.ts +19 -0
- package/dist/recyclerview/utils/componentUtils.d.ts.map +1 -0
- package/dist/recyclerview/utils/componentUtils.js +32 -0
- package/dist/recyclerview/utils/componentUtils.js.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts +24 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.js +82 -0
- package/dist/recyclerview/utils/findVisibleIndex.js.map +1 -0
- package/dist/recyclerview/utils/measureLayout.d.ts +56 -0
- package/dist/recyclerview/utils/measureLayout.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.js +77 -0
- package/dist/recyclerview/utils/measureLayout.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/AverageWindow.d.ts +13 -0
- package/dist/utils/AverageWindow.d.ts.map +1 -1
- package/dist/utils/AverageWindow.js +30 -1
- package/dist/utils/AverageWindow.js.map +1 -1
- package/package.json +1 -1
- package/src/FlashListProps.ts +73 -2
- package/src/__tests__/AverageWindow.test.ts +49 -1
- package/src/enableNewCore.ts +22 -0
- package/src/index.ts +21 -0
- package/src/recyclerview/RecycleKeyManager.ts +185 -0
- package/src/recyclerview/RecyclerView.tsx +500 -0
- package/src/recyclerview/RecyclerViewContextProvider.ts +19 -0
- package/src/recyclerview/RecyclerViewManager.ts +379 -0
- package/src/recyclerview/RecyclerViewProps.ts +10 -0
- package/src/recyclerview/ViewHolder.tsx +173 -0
- package/src/recyclerview/ViewHolderCollection.tsx +164 -0
- package/src/recyclerview/components/CompatScroller.ts +9 -0
- package/src/recyclerview/components/CompatView.ts +9 -0
- package/src/recyclerview/components/ScrollAnchor.tsx +53 -0
- package/src/recyclerview/components/StickyHeaders.tsx +210 -0
- package/src/recyclerview/helpers/ConsecutiveNumbers.ts +120 -0
- package/src/recyclerview/helpers/EngagedIndicesTracker.ts +191 -0
- package/src/recyclerview/hooks/useBoundDetection.ts +127 -0
- package/src/recyclerview/hooks/useLayoutState.ts +46 -0
- package/src/recyclerview/hooks/useOnLoad.ts +78 -0
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +487 -0
- package/src/recyclerview/hooks/useRecyclerViewManager.ts +30 -0
- package/src/recyclerview/hooks/useRecyclingState.ts +63 -0
- package/src/recyclerview/hooks/useSecondaryProps.tsx +119 -0
- package/src/recyclerview/hooks/useUnmountFlag.ts +26 -0
- package/src/recyclerview/layout-managers/GridLayoutManager.ts +215 -0
- package/src/recyclerview/layout-managers/LayoutManager.ts +493 -0
- package/src/recyclerview/layout-managers/LinearLayoutManager.ts +167 -0
- package/src/recyclerview/layout-managers/MasonryLayoutManager.ts +302 -0
- package/src/recyclerview/utils/adjustOffsetForRTL.ts +17 -0
- package/src/recyclerview/utils/componentUtils.ts +28 -0
- package/src/recyclerview/utils/findVisibleIndex.ts +94 -0
- package/src/recyclerview/utils/measureLayout.ts +89 -0
- package/src/utils/AverageWindow.ts +33 -0
- package/src/viewability/ViewToken.ts +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RVMasonryLayoutManagerImpl = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var LayoutManager_1 = require("./LayoutManager");
|
|
6
|
+
/**
|
|
7
|
+
* MasonryLayoutManager implementation that arranges items in a masonry/pinterest-style layout.
|
|
8
|
+
* Items are placed in columns, with support for items spanning multiple columns.
|
|
9
|
+
* Can optimize item placement to minimize column height differences.
|
|
10
|
+
*/
|
|
11
|
+
var RVMasonryLayoutManagerImpl = /** @class */ (function (_super) {
|
|
12
|
+
tslib_1.__extends(RVMasonryLayoutManagerImpl, _super);
|
|
13
|
+
function RVMasonryLayoutManagerImpl(params, previousLayoutManager) {
|
|
14
|
+
var _this = this;
|
|
15
|
+
var _a;
|
|
16
|
+
_this = _super.call(this, params, previousLayoutManager) || this;
|
|
17
|
+
/** Current column index for sequential placement */
|
|
18
|
+
_this.currentColumn = 0;
|
|
19
|
+
_this.boundedSize = params.windowSize.width;
|
|
20
|
+
_this.optimizeItemArrangement = (_a = params.optimizeItemArrangement) !== null && _a !== void 0 ? _a : false;
|
|
21
|
+
_this.columnHeights = Array(_this.maxColumns).fill(0);
|
|
22
|
+
return _this;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Updates layout parameters and triggers recomputation if necessary.
|
|
26
|
+
* @param params New layout parameters
|
|
27
|
+
*/
|
|
28
|
+
RVMasonryLayoutManagerImpl.prototype.updateLayoutParams = function (params) {
|
|
29
|
+
var prevMaxColumns = this.maxColumns;
|
|
30
|
+
var prevOptimizeItemArrangement = this.optimizeItemArrangement;
|
|
31
|
+
_super.prototype.updateLayoutParams.call(this, params);
|
|
32
|
+
if (this.boundedSize !== params.windowSize.width ||
|
|
33
|
+
prevMaxColumns !== params.maxColumns ||
|
|
34
|
+
prevOptimizeItemArrangement !== params.optimizeItemArrangement) {
|
|
35
|
+
this.boundedSize = params.windowSize.width;
|
|
36
|
+
if (this.layouts.length > 0) {
|
|
37
|
+
//console.log("-----> recomputeLayouts");
|
|
38
|
+
//update all widths
|
|
39
|
+
for (var i = 0; i < this.layouts.length; i++) {
|
|
40
|
+
this.layouts[i].width = this.getWidth(i);
|
|
41
|
+
this.layouts[i].minHeight = undefined;
|
|
42
|
+
}
|
|
43
|
+
//TODO: Optimize masonry in general
|
|
44
|
+
this.recomputeLayouts(0, this.layouts.length - 1);
|
|
45
|
+
this.requiresRepaint = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Processes layout information for items, updating their dimensions.
|
|
51
|
+
* @param layoutInfo Array of layout information for items (real measurements)
|
|
52
|
+
* @param itemCount Total number of items in the list
|
|
53
|
+
*/
|
|
54
|
+
RVMasonryLayoutManagerImpl.prototype.processLayoutInfo = function (layoutInfo, itemCount) {
|
|
55
|
+
var e_1, _a;
|
|
56
|
+
try {
|
|
57
|
+
// Update layout information
|
|
58
|
+
for (var layoutInfo_1 = tslib_1.__values(layoutInfo), layoutInfo_1_1 = layoutInfo_1.next(); !layoutInfo_1_1.done; layoutInfo_1_1 = layoutInfo_1.next()) {
|
|
59
|
+
var info = layoutInfo_1_1.value;
|
|
60
|
+
var index = info.index, dimensions = info.dimensions;
|
|
61
|
+
var layout = this.layouts[index];
|
|
62
|
+
layout.height = dimensions.height;
|
|
63
|
+
layout.isHeightMeasured = true;
|
|
64
|
+
layout.isWidthMeasured = true;
|
|
65
|
+
this.layouts[index] = layout;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
if (layoutInfo_1_1 && !layoutInfo_1_1.done && (_a = layoutInfo_1.return)) _a.call(layoutInfo_1);
|
|
72
|
+
}
|
|
73
|
+
finally { if (e_1) throw e_1.error; }
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Estimates layout dimensions for an item at the given index.
|
|
78
|
+
* Can be called by base class if estimate is required.
|
|
79
|
+
* @param index Index of the item to estimate layout for
|
|
80
|
+
*/
|
|
81
|
+
RVMasonryLayoutManagerImpl.prototype.estimateLayout = function (index) {
|
|
82
|
+
var layout = this.layouts[index];
|
|
83
|
+
// Set width based on columns and span
|
|
84
|
+
layout.width = this.getWidth(index);
|
|
85
|
+
layout.height = this.getEstimatedHeight(index);
|
|
86
|
+
layout.isWidthMeasured = true;
|
|
87
|
+
layout.enforcedWidth = true;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Returns the total size of the layout area.
|
|
91
|
+
* @returns RVDimension containing width and height of the layout
|
|
92
|
+
*/
|
|
93
|
+
RVMasonryLayoutManagerImpl.prototype.getLayoutSize = function () {
|
|
94
|
+
if (this.layouts.length === 0)
|
|
95
|
+
return { width: 0, height: 0 };
|
|
96
|
+
// Find the tallest column
|
|
97
|
+
var maxHeight = Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(this.columnHeights), false));
|
|
98
|
+
return {
|
|
99
|
+
width: this.boundedSize,
|
|
100
|
+
height: maxHeight,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Recomputes layouts for items in the given range.
|
|
105
|
+
* Uses different placement strategies based on optimization settings.
|
|
106
|
+
* @param startIndex Starting index of items to recompute
|
|
107
|
+
* @param endIndex Ending index of items to recompute
|
|
108
|
+
*/
|
|
109
|
+
RVMasonryLayoutManagerImpl.prototype.recomputeLayouts = function (startIndex, endIndex) {
|
|
110
|
+
var _a;
|
|
111
|
+
// Reset column heights if starting from the beginning
|
|
112
|
+
if (startIndex === 0) {
|
|
113
|
+
this.columnHeights = Array(this.maxColumns).fill(0);
|
|
114
|
+
this.currentColumn = 0;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Find the y-position of the first item to recompute
|
|
118
|
+
// and adjust column heights accordingly
|
|
119
|
+
this.updateColumnHeightsToIndex(startIndex);
|
|
120
|
+
}
|
|
121
|
+
var itemCount = this.layouts.length;
|
|
122
|
+
for (var i = startIndex; i < itemCount; i++) {
|
|
123
|
+
var layout = this.getLayout(i);
|
|
124
|
+
var span = (_a = this.getSpanSizeInfo(i).span) !== null && _a !== void 0 ? _a : 1;
|
|
125
|
+
if (this.optimizeItemArrangement) {
|
|
126
|
+
if (span === 1) {
|
|
127
|
+
// For single column items, place in the shortest column
|
|
128
|
+
this.placeSingleColumnItem(layout);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// For multi-column items, find the best position
|
|
132
|
+
this.placeOptimizedMultiColumnItem(layout, span);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// No optimization - place items sequentially
|
|
137
|
+
this.placeItemSequentially(layout, span);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Calculates the width of an item based on its span.
|
|
143
|
+
* @param index Index of the item
|
|
144
|
+
* @returns Width of the item
|
|
145
|
+
*/
|
|
146
|
+
RVMasonryLayoutManagerImpl.prototype.getWidth = function (index) {
|
|
147
|
+
var _a;
|
|
148
|
+
var span = (_a = this.getSpanSizeInfo(index).span) !== null && _a !== void 0 ? _a : 1;
|
|
149
|
+
return (this.boundedSize / this.maxColumns) * span;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Places an item sequentially in the next available position.
|
|
153
|
+
* @param layout Layout information for the item
|
|
154
|
+
* @param span Number of columns the item spans
|
|
155
|
+
*/
|
|
156
|
+
RVMasonryLayoutManagerImpl.prototype.placeItemSequentially = function (layout, span) {
|
|
157
|
+
// Check if the item can fit in the current row
|
|
158
|
+
if (this.currentColumn + span > this.maxColumns) {
|
|
159
|
+
// Move to the next row
|
|
160
|
+
this.currentColumn = 0;
|
|
161
|
+
}
|
|
162
|
+
// Find the maximum height of the columns this item will span
|
|
163
|
+
var maxHeight = this.columnHeights[this.currentColumn];
|
|
164
|
+
for (var col = this.currentColumn + 1; col < this.currentColumn + span; col++) {
|
|
165
|
+
if (col < this.maxColumns) {
|
|
166
|
+
maxHeight = Math.max(maxHeight, this.columnHeights[col]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Place the item
|
|
170
|
+
layout.x = (this.boundedSize / this.maxColumns) * this.currentColumn;
|
|
171
|
+
layout.y = maxHeight;
|
|
172
|
+
// Update column heights
|
|
173
|
+
for (var col = this.currentColumn; col < this.currentColumn + span; col++) {
|
|
174
|
+
if (col < this.maxColumns) {
|
|
175
|
+
this.columnHeights[col] = maxHeight + layout.height;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Move to the next column
|
|
179
|
+
this.currentColumn += span;
|
|
180
|
+
if (this.currentColumn >= this.maxColumns) {
|
|
181
|
+
this.currentColumn = 0;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Places a single-column item in the shortest available column.
|
|
186
|
+
* @param layout Layout information for the item
|
|
187
|
+
*/
|
|
188
|
+
RVMasonryLayoutManagerImpl.prototype.placeSingleColumnItem = function (layout) {
|
|
189
|
+
// Find the shortest column
|
|
190
|
+
var shortestColumnIndex = 0;
|
|
191
|
+
var minHeight = this.columnHeights[0];
|
|
192
|
+
for (var i = 1; i < this.maxColumns; i++) {
|
|
193
|
+
if (this.columnHeights[i] < minHeight) {
|
|
194
|
+
minHeight = this.columnHeights[i];
|
|
195
|
+
shortestColumnIndex = i;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Place the item in the shortest column
|
|
199
|
+
layout.x = (this.boundedSize / this.maxColumns) * shortestColumnIndex;
|
|
200
|
+
layout.y = this.columnHeights[shortestColumnIndex];
|
|
201
|
+
// Update the column height
|
|
202
|
+
this.columnHeights[shortestColumnIndex] += layout.height;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Places a multi-column item in the position that minimizes total column heights.
|
|
206
|
+
* @param layout Layout information for the item
|
|
207
|
+
* @param span Number of columns the item spans
|
|
208
|
+
*/
|
|
209
|
+
RVMasonryLayoutManagerImpl.prototype.placeOptimizedMultiColumnItem = function (layout, span) {
|
|
210
|
+
var bestStartColumn = 0;
|
|
211
|
+
var minTotalHeight = Number.MAX_VALUE;
|
|
212
|
+
// Try all possible positions
|
|
213
|
+
for (var startCol = 0; startCol <= this.maxColumns - span; startCol++) {
|
|
214
|
+
// Find the maximum height among the columns this item would span
|
|
215
|
+
var maxHeight_1 = this.columnHeights[startCol];
|
|
216
|
+
for (var col = startCol + 1; col < startCol + span; col++) {
|
|
217
|
+
maxHeight_1 = Math.max(maxHeight_1, this.columnHeights[col]);
|
|
218
|
+
}
|
|
219
|
+
// Calculate the total height after placing the item
|
|
220
|
+
var totalHeight = 0;
|
|
221
|
+
for (var col = 0; col < this.maxColumns; col++) {
|
|
222
|
+
if (col >= startCol && col < startCol + span) {
|
|
223
|
+
totalHeight += maxHeight_1 + layout.height;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
totalHeight += this.columnHeights[col];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Update best position if this is better
|
|
230
|
+
if (totalHeight < minTotalHeight) {
|
|
231
|
+
minTotalHeight = totalHeight;
|
|
232
|
+
bestStartColumn = startCol;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// Place the item at the best position
|
|
236
|
+
var maxHeight = Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(this.columnHeights.slice(bestStartColumn, bestStartColumn + span)), false));
|
|
237
|
+
layout.x = (this.boundedSize / this.maxColumns) * bestStartColumn;
|
|
238
|
+
layout.y = maxHeight;
|
|
239
|
+
// Update column heights
|
|
240
|
+
for (var col = bestStartColumn; col < bestStartColumn + span; col++) {
|
|
241
|
+
this.columnHeights[col] = maxHeight + layout.height;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Updates column heights up to a given index by recalculating item positions.
|
|
246
|
+
* @param index Index to update column heights up to
|
|
247
|
+
*/
|
|
248
|
+
RVMasonryLayoutManagerImpl.prototype.updateColumnHeightsToIndex = function (index) {
|
|
249
|
+
// Reset column heights
|
|
250
|
+
this.columnHeights = Array(this.maxColumns).fill(0);
|
|
251
|
+
this.currentColumn = 0;
|
|
252
|
+
// Recalculate column heights up to the given index
|
|
253
|
+
for (var i = 0; i < index; i++) {
|
|
254
|
+
var layout = this.layouts[i];
|
|
255
|
+
var itemWidth = layout.width;
|
|
256
|
+
var columnWidth = this.boundedSize / this.maxColumns;
|
|
257
|
+
var span = Math.round(itemWidth / columnWidth);
|
|
258
|
+
// Find which columns this item spans
|
|
259
|
+
var startColumn = Math.round(layout.x / columnWidth);
|
|
260
|
+
var endColumn = Math.min(startColumn + span, this.maxColumns);
|
|
261
|
+
// Update column heights
|
|
262
|
+
for (var col = startColumn; col < endColumn; col++) {
|
|
263
|
+
this.columnHeights[col] = Math.max(this.columnHeights[col], layout.y + layout.height);
|
|
264
|
+
}
|
|
265
|
+
// Update current column for non-optimized layout
|
|
266
|
+
if (!this.optimizeItemArrangement) {
|
|
267
|
+
this.currentColumn = (startColumn + span) % this.maxColumns;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
return RVMasonryLayoutManagerImpl;
|
|
272
|
+
}(LayoutManager_1.RVLayoutManager));
|
|
273
|
+
exports.RVMasonryLayoutManagerImpl = RVMasonryLayoutManagerImpl;
|
|
274
|
+
//# sourceMappingURL=MasonryLayoutManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MasonryLayoutManager.js","sourceRoot":"","sources":["../../../src/recyclerview/layout-managers/MasonryLayoutManager.ts"],"names":[],"mappings":";;;;AAAA,iDAMyB;AAEzB;;;;GAIG;AACH;IAAgD,sDAAe;IAQ7D,oCAAY,MAAoB,EAAE,qBAAuC;QAAzE,iBAKC;;gBAJC,kBAAM,MAAM,EAAE,qBAAqB,CAAC;QAJtC,oDAAoD;QAC5C,mBAAa,GAAW,CAAC,CAAC;QAIhC,KAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;QAC3C,KAAI,CAAC,uBAAuB,GAAG,MAAA,MAAM,CAAC,uBAAuB,mCAAI,KAAK,CAAC;QACvE,KAAI,CAAC,aAAa,GAAG,KAAK,CAAC,KAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;IACtD,CAAC;IAED;;;OAGG;IACH,uDAAkB,GAAlB,UAAmB,MAAoB;QACrC,IAAM,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC;QACvC,IAAM,2BAA2B,GAAG,IAAI,CAAC,uBAAuB,CAAC;QACjE,iBAAM,kBAAkB,YAAC,MAAM,CAAC,CAAC;QACjC,IACE,IAAI,CAAC,WAAW,KAAK,MAAM,CAAC,UAAU,CAAC,KAAK;YAC5C,cAAc,KAAK,MAAM,CAAC,UAAU;YACpC,2BAA2B,KAAK,MAAM,CAAC,uBAAuB,EAC9D;YACA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;YAC3C,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,yCAAyC;gBAEzC,mBAAmB;gBACnB,KAAK,IAAI,C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E,GAAG,GAAG,SAAS,EAAE,GAAG,EAAE,EAAE;gBAClD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAChC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EACvB,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CACzB,CAAC;aACH;YAED,iDAAiD;YACjD,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE;gBACjC,IAAI,CAAC,aAAa,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;aAC7D;SACF;IACH,CAAC;IACH,iCAAC;AAAD,CAAC,AAhSD,CAAgD,+BAAe,GAgS9D;AAhSY,gEAA0B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adjusts the scroll offset for Right-to-Left (RTL) layouts.
|
|
3
|
+
* offset it flipped when RTL is enabled.
|
|
4
|
+
* This function converts a left-to-right offset to its RTL equivalent.
|
|
5
|
+
*
|
|
6
|
+
* @param offset - The original scroll offset in LTR layout
|
|
7
|
+
* @param contentSize - The total size of the scrollable content
|
|
8
|
+
* @param windowSize - The size of the visible window/viewport
|
|
9
|
+
* @returns The adjusted offset for RTL layout
|
|
10
|
+
*/
|
|
11
|
+
export declare function adjustOffsetForRTL(offset: number, contentSize: number, windowSize: number): number;
|
|
12
|
+
//# sourceMappingURL=adjustOffsetForRTL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adjustOffsetForRTL.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/utils/adjustOffsetForRTL.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,UAGnB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.adjustOffsetForRTL = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Adjusts the scroll offset for Right-to-Left (RTL) layouts.
|
|
6
|
+
* offset it flipped when RTL is enabled.
|
|
7
|
+
* This function converts a left-to-right offset to its RTL equivalent.
|
|
8
|
+
*
|
|
9
|
+
* @param offset - The original scroll offset in LTR layout
|
|
10
|
+
* @param contentSize - The total size of the scrollable content
|
|
11
|
+
* @param windowSize - The size of the visible window/viewport
|
|
12
|
+
* @returns The adjusted offset for RTL layout
|
|
13
|
+
*/
|
|
14
|
+
function adjustOffsetForRTL(offset, contentSize, windowSize) {
|
|
15
|
+
return contentSize - offset - windowSize;
|
|
16
|
+
}
|
|
17
|
+
exports.adjustOffsetForRTL = adjustOffsetForRTL;
|
|
18
|
+
//# sourceMappingURL=adjustOffsetForRTL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adjustOffsetForRTL.js","sourceRoot":"","sources":["../../../src/recyclerview/utils/adjustOffsetForRTL.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAChC,MAAc,EACd,WAAmB,EACnB,UAAkB;IAElB,OAAO,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC;AAC3C,CAAC;AAND,gDAMC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to handle both React components and React elements.
|
|
4
|
+
* This utility ensures proper rendering of components whether they are passed as
|
|
5
|
+
* component types or pre-rendered elements.
|
|
6
|
+
*
|
|
7
|
+
* @param component - Can be a React component type, React element, null, or undefined
|
|
8
|
+
* @returns A valid React element if the input is valid, null otherwise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // With a component type
|
|
12
|
+
* getValidComponent(MyComponent)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // With a pre-rendered element
|
|
16
|
+
* getValidComponent(<MyComponent />)
|
|
17
|
+
*/
|
|
18
|
+
export declare const getValidComponent: (component: React.ComponentType<any> | React.ReactElement | null | undefined) => React.ReactElement | null;
|
|
19
|
+
//# sourceMappingURL=componentUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentUtils.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/utils/componentUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,cACjB,MAAM,aAAa,CAAC,GAAG,CAAC,GAAG,MAAM,YAAY,GAAG,IAAI,GAAG,SAAS,KAC1E,MAAM,YAAY,GAAG,IAOvB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValidComponent = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to handle both React components and React elements.
|
|
8
|
+
* This utility ensures proper rendering of components whether they are passed as
|
|
9
|
+
* component types or pre-rendered elements.
|
|
10
|
+
*
|
|
11
|
+
* @param component - Can be a React component type, React element, null, or undefined
|
|
12
|
+
* @returns A valid React element if the input is valid, null otherwise
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // With a component type
|
|
16
|
+
* getValidComponent(MyComponent)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // With a pre-rendered element
|
|
20
|
+
* getValidComponent(<MyComponent />)
|
|
21
|
+
*/
|
|
22
|
+
var getValidComponent = function (component) {
|
|
23
|
+
if (react_1.default.isValidElement(component)) {
|
|
24
|
+
return component;
|
|
25
|
+
}
|
|
26
|
+
else if (typeof component === "function") {
|
|
27
|
+
return react_1.default.createElement(component);
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
exports.getValidComponent = getValidComponent;
|
|
32
|
+
//# sourceMappingURL=componentUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentUtils.js","sourceRoot":"","sources":["../../../src/recyclerview/utils/componentUtils.ts"],"names":[],"mappings":";;;;AAAA,wDAA0B;AAE1B;;;;;;;;;;;;;;;GAeG;AACI,IAAM,iBAAiB,GAAG,UAC/B,SAA2E;IAE3E,IAAI,eAAK,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;QACnC,OAAO,SAAS,CAAC;KAClB;SAAM,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;QAC1C,OAAO,eAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;KACvC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AATW,QAAA,iBAAiB,qBAS5B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RVLayout } from "../layout-managers/LayoutManager";
|
|
2
|
+
/**
|
|
3
|
+
* Finds the first visible index in a sorted array of RVLayout objects.
|
|
4
|
+
* This is a wrapper around binarySearchVisibleIndex that specifically finds
|
|
5
|
+
* the first item that becomes visible in the viewport.
|
|
6
|
+
*
|
|
7
|
+
* @param layouts - The sorted array of RVLayout objects
|
|
8
|
+
* @param threshold - The threshold value to determine visibility
|
|
9
|
+
* @param isSortedByX - A boolean indicating if the array is sorted by x (true) or y (false)
|
|
10
|
+
* @returns The index of the first visible layout or -1 if none are visible
|
|
11
|
+
*/
|
|
12
|
+
export declare function findFirstVisibleIndex(layouts: RVLayout[], threshold: number, isSortedByX: boolean): number;
|
|
13
|
+
/**
|
|
14
|
+
* Finds the last visible index in a sorted array of RVLayout objects.
|
|
15
|
+
* This is a wrapper around binarySearchVisibleIndex that specifically finds
|
|
16
|
+
* the last item that remains visible in the viewport.
|
|
17
|
+
*
|
|
18
|
+
* @param layouts - The sorted array of RVLayout objects
|
|
19
|
+
* @param threshold - The threshold value to determine visibility
|
|
20
|
+
* @param isSortedByX - A boolean indicating if the array is sorted by x (true) or y (false)
|
|
21
|
+
* @returns The index of the last visible layout or -1 if none are visible
|
|
22
|
+
*/
|
|
23
|
+
export declare function findLastVisibleIndex(layouts: RVLayout[], threshold: number, isSortedByX: boolean): number;
|
|
24
|
+
//# sourceMappingURL=findVisibleIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findVisibleIndex.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/utils/findVisibleIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AA2D5D;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,QAAQ,EAAE,EACnB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,OAAO,GACnB,MAAM,CAER;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,QAAQ,EAAE,EACnB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,OAAO,GACnB,MAAM,CAER"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findLastVisibleIndex = exports.findFirstVisibleIndex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A helper function to perform binary search for the first or last visible index.
|
|
6
|
+
* This function efficiently finds items that are visible within a viewport by using
|
|
7
|
+
* a binary search algorithm on sorted layouts.
|
|
8
|
+
*
|
|
9
|
+
* @param layouts - The sorted array of RVLayout objects, sorted by either x or y position
|
|
10
|
+
* @param threshold - The threshold value to determine visibility (viewport boundary)
|
|
11
|
+
* @param isSortedByX - A boolean indicating if the array is sorted by x (true) or y (false)
|
|
12
|
+
* @param findFirst - A boolean indicating whether to find the first (true) or last (false) visible index
|
|
13
|
+
* @returns The index of the visible layout or -1 if none are visible
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* The binary search implementation ensures O(log n) time complexity for finding visible items.
|
|
17
|
+
* The function assumes the layouts array is pre-sorted by the relevant dimension (x or y).
|
|
18
|
+
*/
|
|
19
|
+
function binarySearchVisibleIndex(layouts, threshold, isSortedByX, findFirst) {
|
|
20
|
+
var left = 0;
|
|
21
|
+
var right = layouts.length - 1;
|
|
22
|
+
var visibleIndex = -1;
|
|
23
|
+
while (left <= right) {
|
|
24
|
+
var mid = Math.floor((left + right) / 2);
|
|
25
|
+
var layout = layouts[mid];
|
|
26
|
+
// Check visibility based on the sorting criteria
|
|
27
|
+
var position = isSortedByX ? layout.x : layout.y;
|
|
28
|
+
var size = isSortedByX ? layout.width : layout.height;
|
|
29
|
+
//TODO: Will this find item bigger than viewport
|
|
30
|
+
if (findFirst) {
|
|
31
|
+
// Logic for finding the first visible index
|
|
32
|
+
if (position >= threshold || position + size >= threshold) {
|
|
33
|
+
// Potential visible index found, continue searching left for earlier visible items
|
|
34
|
+
visibleIndex = mid;
|
|
35
|
+
right = mid - 1;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// Search in the right half for visible items
|
|
39
|
+
left = mid + 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (position <= threshold) {
|
|
43
|
+
// Potential visible index found, continue searching right for later visible items
|
|
44
|
+
visibleIndex = mid;
|
|
45
|
+
left = mid + 1;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// Search in the left half for visible items
|
|
49
|
+
right = mid - 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return visibleIndex;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Finds the first visible index in a sorted array of RVLayout objects.
|
|
56
|
+
* This is a wrapper around binarySearchVisibleIndex that specifically finds
|
|
57
|
+
* the first item that becomes visible in the viewport.
|
|
58
|
+
*
|
|
59
|
+
* @param layouts - The sorted array of RVLayout objects
|
|
60
|
+
* @param threshold - The threshold value to determine visibility
|
|
61
|
+
* @param isSortedByX - A boolean indicating if the array is sorted by x (true) or y (false)
|
|
62
|
+
* @returns The index of the first visible layout or -1 if none are visible
|
|
63
|
+
*/
|
|
64
|
+
function findFirstVisibleIndex(layouts, threshold, isSortedByX) {
|
|
65
|
+
return binarySearchVisibleIndex(layouts, threshold, isSortedByX, true);
|
|
66
|
+
}
|
|
67
|
+
exports.findFirstVisibleIndex = findFirstVisibleIndex;
|
|
68
|
+
/**
|
|
69
|
+
* Finds the last visible index in a sorted array of RVLayout objects.
|
|
70
|
+
* This is a wrapper around binarySearchVisibleIndex that specifically finds
|
|
71
|
+
* the last item that remains visible in the viewport.
|
|
72
|
+
*
|
|
73
|
+
* @param layouts - The sorted array of RVLayout objects
|
|
74
|
+
* @param threshold - The threshold value to determine visibility
|
|
75
|
+
* @param isSortedByX - A boolean indicating if the array is sorted by x (true) or y (false)
|
|
76
|
+
* @returns The index of the last visible layout or -1 if none are visible
|
|
77
|
+
*/
|
|
78
|
+
function findLastVisibleIndex(layouts, threshold, isSortedByX) {
|
|
79
|
+
return binarySearchVisibleIndex(layouts, threshold, isSortedByX, false);
|
|
80
|
+
}
|
|
81
|
+
exports.findLastVisibleIndex = findLastVisibleIndex;
|
|
82
|
+
//# sourceMappingURL=findVisibleIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findVisibleIndex.js","sourceRoot":"","sources":["../../../src/recyclerview/utils/findVisibleIndex.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;GAcG;AACH,SAAS,wBAAwB,CAC/B,OAAmB,EACnB,SAAiB,EACjB,WAAoB,EACpB,SAAkB;IAElB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC;IAEtB,OAAO,IAAI,IAAI,KAAK,EAAE;QACpB,IAAM,GAAG,G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,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC;AAND,oDAMC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { View } from "react-native";
|
|
2
|
+
interface Layout {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Measures the layout of a view relative to itselft.
|
|
10
|
+
* Using measure wasn't returing accurate values but this workaround does.
|
|
11
|
+
* Returns the x, y coordinates and dimensions of the view.
|
|
12
|
+
*
|
|
13
|
+
* @param view - The React Native View component to measure
|
|
14
|
+
* @returns An object containing x, y, width, and height measurements
|
|
15
|
+
*/
|
|
16
|
+
export declare function measureLayout(view: View, oldLayout: Layout | undefined): {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Measures the layout of a view relative to another view.
|
|
24
|
+
* Useful for measuring positions relative to a specific reference view.
|
|
25
|
+
*
|
|
26
|
+
* @param view - The React Native View component to measure
|
|
27
|
+
* @param relativeTo - The reference view to measure against
|
|
28
|
+
* @returns An object containing x, y, width, and height measurements
|
|
29
|
+
*/
|
|
30
|
+
export declare function measureLayoutRelative(view: View, relativeTo: View, oldLayout: Layout | undefined): {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Checks if two dimension values are not equal, with a small tolerance.
|
|
38
|
+
* Used to handle floating-point precision issues in layout measurements.
|
|
39
|
+
*
|
|
40
|
+
* @param value1 - First dimension value to compare
|
|
41
|
+
* @param value2 - Second dimension value to compare
|
|
42
|
+
* @returns true if the values are significantly different, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
export declare function areDimensionsNotEqual(value1: number, value2: number): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if two dimension values are equal, with a small tolerance.
|
|
47
|
+
* Used to handle floating-point precision issues in layout measurements.
|
|
48
|
+
*
|
|
49
|
+
* @param value1 - First dimension value to compare
|
|
50
|
+
* @param value2 - Second dimension value to compare
|
|
51
|
+
* @returns true if the values are approximately equal, false otherwise
|
|
52
|
+
*/
|
|
53
|
+
export declare function areDimensionsEqual(value1: number, value2: number): boolean;
|
|
54
|
+
export declare function roundOffPixel(value: number): number;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=measureLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measureLayout.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/utils/measureLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhD,UAAU,MAAM;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS;;;;;EAMtE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS;;;;;EAmB9B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAO1E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.roundOffPixel = exports.areDimensionsEqual = exports.areDimensionsNotEqual = exports.measureLayoutRelative = exports.measureLayout = void 0;
|
|
4
|
+
var react_native_1 = require("react-native");
|
|
5
|
+
/**
|
|
6
|
+
* Measures the layout of a view relative to itselft.
|
|
7
|
+
* Using measure wasn't returing accurate values but this workaround does.
|
|
8
|
+
* Returns the x, y coordinates and dimensions of the view.
|
|
9
|
+
*
|
|
10
|
+
* @param view - The React Native View component to measure
|
|
11
|
+
* @returns An object containing x, y, width, and height measurements
|
|
12
|
+
*/
|
|
13
|
+
function measureLayout(view, oldLayout) {
|
|
14
|
+
// const layout = view.unstable_getBoundingClientRect();
|
|
15
|
+
// layout.width = roundOffPixel(layout.width);
|
|
16
|
+
// layout.height = roundOffPixel(layout.height);
|
|
17
|
+
// return layout;
|
|
18
|
+
return measureLayoutRelative(view, view, oldLayout);
|
|
19
|
+
}
|
|
20
|
+
exports.measureLayout = measureLayout;
|
|
21
|
+
/**
|
|
22
|
+
* Measures the layout of a view relative to another view.
|
|
23
|
+
* Useful for measuring positions relative to a specific reference view.
|
|
24
|
+
*
|
|
25
|
+
* @param view - The React Native View component to measure
|
|
26
|
+
* @param relativeTo - The reference view to measure against
|
|
27
|
+
* @returns An object containing x, y, width, and height measurements
|
|
28
|
+
*/
|
|
29
|
+
function measureLayoutRelative(view, relativeTo, oldLayout) {
|
|
30
|
+
var layout = { x: 0, y: 0, width: 0, height: 0 };
|
|
31
|
+
view.measureLayout(relativeTo, function (x, y, width, height) {
|
|
32
|
+
layout.x = x;
|
|
33
|
+
layout.y = y;
|
|
34
|
+
layout.width = roundOffPixel(width);
|
|
35
|
+
layout.height = roundOffPixel(height);
|
|
36
|
+
});
|
|
37
|
+
if (oldLayout) {
|
|
38
|
+
if (areDimensionsEqual(layout.width, oldLayout.width)) {
|
|
39
|
+
layout.width = oldLayout.width;
|
|
40
|
+
}
|
|
41
|
+
if (areDimensionsEqual(layout.height, oldLayout.height)) {
|
|
42
|
+
layout.height = oldLayout.height;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return layout;
|
|
46
|
+
}
|
|
47
|
+
exports.measureLayoutRelative = measureLayoutRelative;
|
|
48
|
+
/**
|
|
49
|
+
* Checks if two dimension values are not equal, with a small tolerance.
|
|
50
|
+
* Used to handle floating-point precision issues in layout measurements.
|
|
51
|
+
*
|
|
52
|
+
* @param value1 - First dimension value to compare
|
|
53
|
+
* @param value2 - Second dimension value to compare
|
|
54
|
+
* @returns true if the values are significantly different, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
function areDimensionsNotEqual(value1, value2) {
|
|
57
|
+
return !areDimensionsEqual(value1, value2);
|
|
58
|
+
}
|
|
59
|
+
exports.areDimensionsNotEqual = areDimensionsNotEqual;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if two dimension values are equal, with a small tolerance.
|
|
62
|
+
* Used to handle floating-point precision issues in layout measurements.
|
|
63
|
+
*
|
|
64
|
+
* @param value1 - First dimension value to compare
|
|
65
|
+
* @param value2 - Second dimension value to compare
|
|
66
|
+
* @returns true if the values are approximately equal, false otherwise
|
|
67
|
+
*/
|
|
68
|
+
function areDimensionsEqual(value1, value2) {
|
|
69
|
+
return (Math.abs(react_native_1.PixelRatio.getPixelSizeForLayoutSize(value1) -
|
|
70
|
+
react_native_1.PixelRatio.getPixelSizeForLayoutSize(value2)) <= 1);
|
|
71
|
+
}
|
|
72
|
+
exports.areDimensionsEqual = areDimensionsEqual;
|
|
73
|
+
function roundOffPixel(value) {
|
|
74
|
+
return react_native_1.PixelRatio.roundToNearestPixel(value);
|
|
75
|
+
}
|
|
76
|
+
exports.roundOffPixel = roundOffPixel;
|
|
77
|
+
//# sourceMappingURL=measureLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measureLayout.js","sourceRoot":"","sources":["../../../src/recyclerview/utils/measureLayout.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;A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