@legendapp/list 3.1.2 → 3.2.0
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/CHANGELOG.md +6 -0
- package/animated.d.ts +17 -3
- package/package.json +1 -1
- package/react-native.d.ts +17 -3
- package/react-native.js +2052 -1963
- package/react-native.mjs +2052 -1963
- package/react-native.web.d.ts +17 -3
- package/react-native.web.js +4796 -4692
- package/react-native.web.mjs +4796 -4692
- package/react.d.ts +17 -3
- package/react.js +4796 -4692
- package/react.mjs +4796 -4692
- package/reanimated.d.ts +17 -3
- package/section-list.d.ts +17 -3
package/react-native.js
CHANGED
|
@@ -165,7 +165,7 @@ function StateProvider({ children }) {
|
|
|
165
165
|
["isNearEnd", false],
|
|
166
166
|
["isNearStart", false],
|
|
167
167
|
["isWithinMaintainScrollAtEndThreshold", false],
|
|
168
|
-
["adaptiveRender", "
|
|
168
|
+
["adaptiveRender", "normal"],
|
|
169
169
|
["totalSize", 0],
|
|
170
170
|
["scrollAdjustPending", 0]
|
|
171
171
|
]),
|
|
@@ -779,563 +779,564 @@ function Separator({ ItemSeparatorComponent, leadingItem }) {
|
|
|
779
779
|
const isLastItem = useIsLastItem();
|
|
780
780
|
return isLastItem ? null : /* @__PURE__ */ React2__namespace.createElement(ItemSeparatorComponent, { leadingItem });
|
|
781
781
|
}
|
|
782
|
-
var PixelRatio = ReactNative.PixelRatio;
|
|
783
782
|
|
|
784
|
-
// src/
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
function isNativeLayoutSizeNoise(heightDelta, widthDelta) {
|
|
794
|
-
return isWithinEpsilon(heightDelta) && isWithinEpsilon(widthDelta);
|
|
783
|
+
// src/core/deferredPublicOnScroll.ts
|
|
784
|
+
function withResolvedContentOffset(state, event, resolvedOffset) {
|
|
785
|
+
return {
|
|
786
|
+
...event,
|
|
787
|
+
nativeEvent: {
|
|
788
|
+
...event.nativeEvent,
|
|
789
|
+
contentOffset: state.props.horizontal ? { x: resolvedOffset, y: 0 } : { x: 0, y: resolvedOffset }
|
|
790
|
+
}
|
|
791
|
+
};
|
|
795
792
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
layout.height - lastLayout.measuredLayout.height,
|
|
811
|
-
layout.width - lastLayout.measuredLayout.width
|
|
812
|
-
);
|
|
813
|
-
if (!lastLayout || didLayoutSizeChange && !isMeasuredLayoutNoise) {
|
|
814
|
-
onLayoutChange(layout, false);
|
|
815
|
-
}
|
|
816
|
-
if (!lastLayout || didLayoutSizeChange) {
|
|
817
|
-
lastLayoutRef.current = {
|
|
818
|
-
...layout,
|
|
819
|
-
measuredLayout: isMeasuredLayoutNoise ? lastLayout == null ? void 0 : lastLayout.measuredLayout : void 0
|
|
820
|
-
};
|
|
821
|
-
}
|
|
822
|
-
onLayoutProp == null ? void 0 : onLayoutProp(event);
|
|
823
|
-
},
|
|
824
|
-
[onLayoutChange, onLayoutProp]
|
|
825
|
-
);
|
|
826
|
-
if (IsNewArchitecture) {
|
|
827
|
-
React2.useLayoutEffect(() => {
|
|
828
|
-
if (ref.current) {
|
|
829
|
-
ref.current.measure((x, y, width, height) => {
|
|
830
|
-
const layout = { height, width, x, y };
|
|
831
|
-
lastLayoutRef.current = { ...layout, measuredLayout: layout };
|
|
832
|
-
onLayoutChange(layout, true);
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
}, deps);
|
|
793
|
+
function releaseDeferredPublicOnScroll(ctx, resolvedOffset) {
|
|
794
|
+
var _a3, _b, _c, _d;
|
|
795
|
+
const state = ctx.state;
|
|
796
|
+
const deferredEvent = state.deferredPublicOnScrollEvent;
|
|
797
|
+
state.deferredPublicOnScrollEvent = void 0;
|
|
798
|
+
if (deferredEvent) {
|
|
799
|
+
(_d = (_c = state.props).onScroll) == null ? void 0 : _d.call(
|
|
800
|
+
_c,
|
|
801
|
+
withResolvedContentOffset(
|
|
802
|
+
state,
|
|
803
|
+
deferredEvent,
|
|
804
|
+
(_b = (_a3 = resolvedOffset != null ? resolvedOffset : state.scrollPending) != null ? _a3 : state.scroll) != null ? _b : 0
|
|
805
|
+
)
|
|
806
|
+
);
|
|
836
807
|
}
|
|
837
|
-
return { onLayout };
|
|
838
808
|
}
|
|
839
809
|
|
|
840
|
-
// src/
|
|
841
|
-
|
|
842
|
-
|
|
810
|
+
// src/core/initialScrollSession.ts
|
|
811
|
+
var INITIAL_SCROLL_MIN_TARGET_OFFSET = 1;
|
|
812
|
+
function hasInitialScrollSessionCompletion(completion) {
|
|
813
|
+
return !!((completion == null ? void 0 : completion.didDispatchNativeScroll) || (completion == null ? void 0 : completion.didRetrySilentInitialScroll) || (completion == null ? void 0 : completion.watchdog));
|
|
843
814
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
otherAxisSize
|
|
855
|
-
}) {
|
|
856
|
-
let paddingStyles;
|
|
857
|
-
if (columnWrapperStyle) {
|
|
858
|
-
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
859
|
-
if (horizontal) {
|
|
860
|
-
paddingStyles = {
|
|
861
|
-
paddingBottom: numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0,
|
|
862
|
-
paddingRight: columnGap || gap || void 0,
|
|
863
|
-
paddingTop: numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0
|
|
864
|
-
};
|
|
865
|
-
} else {
|
|
866
|
-
paddingStyles = {
|
|
867
|
-
paddingBottom: rowGap || gap || void 0,
|
|
868
|
-
paddingLeft: numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0,
|
|
869
|
-
paddingRight: numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
return horizontal ? {
|
|
874
|
-
bottom: contentContainerAlignItems === "flex-end" && numColumns === 1 ? 0 : void 0,
|
|
875
|
-
boxSizing: paddingStyles ? "border-box" : void 0,
|
|
876
|
-
direction: isHorizontalRTLList && Platform.OS === "web" ? "ltr" : void 0,
|
|
877
|
-
flexDirection: hasItemSeparator ? "row" : void 0,
|
|
878
|
-
height: otherAxisSize,
|
|
879
|
-
left: 0,
|
|
880
|
-
position: "absolute",
|
|
881
|
-
top: contentContainerAlignItems === "flex-end" && numColumns === 1 ? void 0 : otherAxisPos,
|
|
882
|
-
...paddingStyles || {}
|
|
815
|
+
function clearInitialScrollSession(state) {
|
|
816
|
+
state.initialScrollSession = void 0;
|
|
817
|
+
return void 0;
|
|
818
|
+
}
|
|
819
|
+
function createInitialScrollSession(options) {
|
|
820
|
+
const { bootstrap, completion, kind, previousDataLength } = options;
|
|
821
|
+
return kind === "offset" ? {
|
|
822
|
+
completion,
|
|
823
|
+
kind,
|
|
824
|
+
previousDataLength
|
|
883
825
|
} : {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
top: 0,
|
|
889
|
-
width: otherAxisSize,
|
|
890
|
-
...paddingStyles || {}
|
|
826
|
+
bootstrap,
|
|
827
|
+
completion,
|
|
828
|
+
kind,
|
|
829
|
+
previousDataLength
|
|
891
830
|
};
|
|
892
831
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
`containerSticky${id}`
|
|
915
|
-
]);
|
|
916
|
-
const itemLayoutRef = React2.useRef({
|
|
917
|
-
didLayout: false,
|
|
918
|
-
horizontal,
|
|
919
|
-
itemKey,
|
|
920
|
-
pendingShrinkToken: 0,
|
|
921
|
-
updateItemSize: updateItemSize2
|
|
922
|
-
});
|
|
923
|
-
itemLayoutRef.current.horizontal = horizontal;
|
|
924
|
-
itemLayoutRef.current.itemKey = itemKey;
|
|
925
|
-
itemLayoutRef.current.updateItemSize = updateItemSize2;
|
|
926
|
-
const ref = React2.useRef(null);
|
|
927
|
-
const [layoutRenderCount, forceLayoutRender] = React2.useState(0);
|
|
928
|
-
const resolvedColumn = column > 0 ? column : 1;
|
|
929
|
-
const resolvedSpan = Math.min(Math.max(span || 1, 1), numColumns);
|
|
930
|
-
const otherAxisPos = numColumns > 1 ? `${(resolvedColumn - 1) / numColumns * 100}%` : 0;
|
|
931
|
-
const otherAxisSize = numColumns > 1 ? `${resolvedSpan / numColumns * 100}%` : void 0;
|
|
932
|
-
const style = React2.useMemo(
|
|
933
|
-
() => getContainerPositionStyle({
|
|
934
|
-
columnWrapperStyle,
|
|
935
|
-
contentContainerAlignItems: ctx.state.props.contentContainerAlignItems,
|
|
936
|
-
hasItemSeparator: !!ItemSeparatorComponent,
|
|
937
|
-
horizontal,
|
|
938
|
-
isHorizontalRTLList,
|
|
939
|
-
numColumns,
|
|
940
|
-
otherAxisPos,
|
|
941
|
-
otherAxisSize
|
|
942
|
-
}),
|
|
943
|
-
[
|
|
944
|
-
horizontal,
|
|
945
|
-
isHorizontalRTLList,
|
|
946
|
-
otherAxisPos,
|
|
947
|
-
otherAxisSize,
|
|
948
|
-
columnWrapperStyle,
|
|
949
|
-
ctx.state.props.contentContainerAlignItems,
|
|
950
|
-
numColumns,
|
|
951
|
-
ItemSeparatorComponent
|
|
952
|
-
]
|
|
953
|
-
);
|
|
954
|
-
const renderedItemInfo = React2.useMemo(
|
|
955
|
-
() => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
|
|
956
|
-
[itemKey, data, extraData]
|
|
957
|
-
);
|
|
958
|
-
const { index, renderedItem } = renderedItemInfo || {};
|
|
959
|
-
const onLayoutChange = React2.useCallback((rectangle) => {
|
|
832
|
+
function ensureInitialScrollSessionCompletion(state, kind = ((_b) => (_b = ((_a3) => (_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind)()) != null ? _b : "bootstrap")()) {
|
|
833
|
+
var _a4, _b2;
|
|
834
|
+
if (!state.initialScrollSession) {
|
|
835
|
+
state.initialScrollSession = createInitialScrollSession({
|
|
836
|
+
completion: {},
|
|
837
|
+
kind,
|
|
838
|
+
previousDataLength: 0
|
|
839
|
+
});
|
|
840
|
+
} else if (state.initialScrollSession.kind !== kind) {
|
|
841
|
+
state.initialScrollSession = createInitialScrollSession({
|
|
842
|
+
bootstrap: state.initialScrollSession.kind === "bootstrap" ? state.initialScrollSession.bootstrap : void 0,
|
|
843
|
+
completion: state.initialScrollSession.completion,
|
|
844
|
+
kind,
|
|
845
|
+
previousDataLength: state.initialScrollSession.previousDataLength
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
(_b2 = (_a4 = state.initialScrollSession).completion) != null ? _b2 : _a4.completion = {};
|
|
849
|
+
return state.initialScrollSession.completion;
|
|
850
|
+
}
|
|
851
|
+
var initialScrollCompletion = {
|
|
852
|
+
didDispatchNativeScroll(state) {
|
|
960
853
|
var _a3, _b;
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
const prevSize = lastSize ? roundSize(lastSize[axis]) : void 0;
|
|
976
|
-
const doUpdate = () => {
|
|
977
|
-
itemLayoutRef.current.lastSize = layout;
|
|
978
|
-
updateItemSizeFn(currentItemKey, layout);
|
|
979
|
-
itemLayoutRef.current.didLayout = true;
|
|
980
|
-
};
|
|
981
|
-
const shouldDeferWebShrinkLayoutUpdate = Platform.OS === "web" && !isInMVCPActiveMode(ctx.state) && prevSize !== void 0 && size + 1 < prevSize;
|
|
982
|
-
if (shouldDeferWebShrinkLayoutUpdate) {
|
|
983
|
-
const token = pendingShrinkToken + 1;
|
|
984
|
-
itemLayoutRef.current.pendingShrinkToken = token;
|
|
985
|
-
requestAnimationFrame(() => {
|
|
986
|
-
var _a4;
|
|
987
|
-
if (itemLayoutRef.current.pendingShrinkToken !== token) {
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
const element = ref.current;
|
|
991
|
-
const rect = (_a4 = element == null ? void 0 : element.getBoundingClientRect) == null ? void 0 : _a4.call(element);
|
|
992
|
-
if (rect) {
|
|
993
|
-
layout = { height: rect.height, width: rect.width };
|
|
994
|
-
}
|
|
995
|
-
doUpdate();
|
|
996
|
-
});
|
|
854
|
+
return !!((_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.completion) == null ? void 0 : _b.didDispatchNativeScroll);
|
|
855
|
+
},
|
|
856
|
+
didRetrySilentInitialScroll(state) {
|
|
857
|
+
var _a3, _b;
|
|
858
|
+
return !!((_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.completion) == null ? void 0 : _b.didRetrySilentInitialScroll);
|
|
859
|
+
},
|
|
860
|
+
markInitialScrollNativeDispatch(state) {
|
|
861
|
+
ensureInitialScrollSessionCompletion(state).didDispatchNativeScroll = true;
|
|
862
|
+
},
|
|
863
|
+
markSilentInitialScrollRetry(state) {
|
|
864
|
+
ensureInitialScrollSessionCompletion(state).didRetrySilentInitialScroll = true;
|
|
865
|
+
},
|
|
866
|
+
resetFlags(state) {
|
|
867
|
+
if (!state.initialScrollSession) {
|
|
997
868
|
return;
|
|
998
869
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
870
|
+
const completion = ensureInitialScrollSessionCompletion(state, state.initialScrollSession.kind);
|
|
871
|
+
completion.didDispatchNativeScroll = void 0;
|
|
872
|
+
completion.didRetrySilentInitialScroll = void 0;
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
var initialScrollWatchdog = {
|
|
876
|
+
clear(state) {
|
|
877
|
+
initialScrollWatchdog.set(state, void 0);
|
|
878
|
+
},
|
|
879
|
+
didReachTarget(newScroll, watchdog) {
|
|
880
|
+
const nextDistance = Math.abs(newScroll - watchdog.targetOffset);
|
|
881
|
+
return nextDistance <= INITIAL_SCROLL_MIN_TARGET_OFFSET;
|
|
882
|
+
},
|
|
883
|
+
get(state) {
|
|
884
|
+
var _a3, _b;
|
|
885
|
+
return (_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.completion) == null ? void 0 : _b.watchdog;
|
|
886
|
+
},
|
|
887
|
+
hasNonZeroTargetOffset(targetOffset) {
|
|
888
|
+
return targetOffset !== void 0 && targetOffset > INITIAL_SCROLL_MIN_TARGET_OFFSET;
|
|
889
|
+
},
|
|
890
|
+
isAtZeroTargetOffset(targetOffset) {
|
|
891
|
+
return targetOffset <= INITIAL_SCROLL_MIN_TARGET_OFFSET;
|
|
892
|
+
},
|
|
893
|
+
set(state, watchdog) {
|
|
894
|
+
var _a3, _b;
|
|
895
|
+
if (!watchdog && !((_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.completion) == null ? void 0 : _b.watchdog)) {
|
|
896
|
+
return;
|
|
1006
897
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
ctx.viewRefs.set(id, ref);
|
|
1013
|
-
return {
|
|
1014
|
-
containerId: id,
|
|
1015
|
-
index,
|
|
1016
|
-
itemKey,
|
|
1017
|
-
triggerLayout,
|
|
1018
|
-
value: data
|
|
1019
|
-
};
|
|
1020
|
-
}, [id, itemKey, index, data, triggerLayout]);
|
|
1021
|
-
React2.useLayoutEffect(() => {
|
|
1022
|
-
ctx.containerLayoutTriggers.set(id, triggerLayout);
|
|
1023
|
-
return () => {
|
|
1024
|
-
if (ctx.containerLayoutTriggers.get(id) === triggerLayout) {
|
|
1025
|
-
ctx.containerLayoutTriggers.delete(id);
|
|
1026
|
-
}
|
|
1027
|
-
};
|
|
1028
|
-
}, [ctx, id, triggerLayout]);
|
|
1029
|
-
const { onLayout } = useOnLayoutSync(
|
|
1030
|
-
{
|
|
1031
|
-
onLayoutChange,
|
|
1032
|
-
ref},
|
|
1033
|
-
[itemKey, layoutRenderCount]
|
|
1034
|
-
);
|
|
1035
|
-
if (!IsNewArchitecture) {
|
|
1036
|
-
React2.useEffect(() => {
|
|
1037
|
-
if (!isNullOrUndefined(itemKey)) {
|
|
1038
|
-
itemLayoutRef.current.didLayout = false;
|
|
1039
|
-
const timeout = setTimeout(() => {
|
|
1040
|
-
if (!itemLayoutRef.current.didLayout) {
|
|
1041
|
-
const {
|
|
1042
|
-
itemKey: currentItemKey,
|
|
1043
|
-
lastSize,
|
|
1044
|
-
updateItemSize: updateItemSizeFn
|
|
1045
|
-
} = itemLayoutRef.current;
|
|
1046
|
-
if (lastSize && !isNullOrUndefined(currentItemKey)) {
|
|
1047
|
-
updateItemSizeFn(currentItemKey, lastSize);
|
|
1048
|
-
itemLayoutRef.current.didLayout = true;
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
}, 16);
|
|
1052
|
-
return () => {
|
|
1053
|
-
clearTimeout(timeout);
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
}, [itemKey]);
|
|
898
|
+
const completion = ensureInitialScrollSessionCompletion(state);
|
|
899
|
+
completion.watchdog = watchdog ? {
|
|
900
|
+
startScroll: watchdog.startScroll,
|
|
901
|
+
targetOffset: watchdog.targetOffset
|
|
902
|
+
} : void 0;
|
|
1057
903
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
refView: ref,
|
|
1069
|
-
stickyHeaderConfig,
|
|
1070
|
-
style
|
|
1071
|
-
},
|
|
1072
|
-
/* @__PURE__ */ React2__namespace.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React2__namespace.createElement(Separator, { ItemSeparatorComponent, leadingItem: renderedItemInfo.item }))
|
|
1073
|
-
);
|
|
1074
|
-
});
|
|
1075
|
-
|
|
1076
|
-
// src/components/ContainerSlot.tsx
|
|
1077
|
-
function ContainerSlotBase({
|
|
1078
|
-
id,
|
|
1079
|
-
horizontal,
|
|
1080
|
-
recycleItems,
|
|
1081
|
-
ItemSeparatorComponent,
|
|
1082
|
-
updateItemSize: updateItemSize2,
|
|
1083
|
-
getRenderedItem: getRenderedItem2,
|
|
1084
|
-
stickyHeaderConfig,
|
|
1085
|
-
ContainerComponent = Container
|
|
1086
|
-
}) {
|
|
1087
|
-
const [itemKey] = useArr$([`containerItemKey${id}`]);
|
|
1088
|
-
if (itemKey === void 0) {
|
|
1089
|
-
return null;
|
|
904
|
+
};
|
|
905
|
+
function setInitialScrollSession(state, options = {}) {
|
|
906
|
+
var _a3, _b, _c, _d;
|
|
907
|
+
const existingSession = state.initialScrollSession;
|
|
908
|
+
const kind = (_a3 = options.kind) != null ? _a3 : existingSession == null ? void 0 : existingSession.kind;
|
|
909
|
+
const completion = existingSession == null ? void 0 : existingSession.completion;
|
|
910
|
+
const existingBootstrap = (existingSession == null ? void 0 : existingSession.kind) === "bootstrap" ? existingSession.bootstrap : void 0;
|
|
911
|
+
const bootstrap = kind === "bootstrap" ? options.bootstrap === null ? void 0 : (_b = options.bootstrap) != null ? _b : existingBootstrap : void 0;
|
|
912
|
+
if (!kind) {
|
|
913
|
+
return clearInitialScrollSession(state);
|
|
1090
914
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
}
|
|
1103
|
-
);
|
|
915
|
+
if (!state.initialScroll && !bootstrap && !hasInitialScrollSessionCompletion(completion)) {
|
|
916
|
+
return clearInitialScrollSession(state);
|
|
917
|
+
}
|
|
918
|
+
const previousDataLength = (_d = (_c = options.previousDataLength) != null ? _c : existingSession == null ? void 0 : existingSession.previousDataLength) != null ? _d : 0;
|
|
919
|
+
state.initialScrollSession = createInitialScrollSession({
|
|
920
|
+
bootstrap,
|
|
921
|
+
completion,
|
|
922
|
+
kind,
|
|
923
|
+
previousDataLength
|
|
924
|
+
});
|
|
925
|
+
return state.initialScrollSession;
|
|
1104
926
|
}
|
|
1105
|
-
var ContainerSlot = typedMemo(function ContainerSlot2(props) {
|
|
1106
|
-
return /* @__PURE__ */ React2__namespace.createElement(ContainerSlotBase, { ...props });
|
|
1107
|
-
});
|
|
1108
927
|
|
|
1109
|
-
// src/
|
|
1110
|
-
var
|
|
1111
|
-
|
|
1112
|
-
const
|
|
1113
|
-
const
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
if (horizontal) {
|
|
1126
|
-
if (gapY && numColumns > 1) {
|
|
1127
|
-
style.marginVertical = -gapY / 2;
|
|
1128
|
-
}
|
|
1129
|
-
if (gapX) {
|
|
1130
|
-
style.marginRight = -gapX;
|
|
1131
|
-
}
|
|
1132
|
-
} else {
|
|
1133
|
-
if (gapX && numColumns > 1) {
|
|
1134
|
-
style.marginHorizontal = -gapX;
|
|
1135
|
-
}
|
|
1136
|
-
if (gapY) {
|
|
1137
|
-
style.marginBottom = -gapY;
|
|
1138
|
-
}
|
|
928
|
+
// src/utils/checkThreshold.ts
|
|
929
|
+
var HYSTERESIS_MULTIPLIER = 1.3;
|
|
930
|
+
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot, allowReentryOnChange) => {
|
|
931
|
+
const absDistance = Math.abs(distance);
|
|
932
|
+
const within = atThreshold || threshold > 0 && absDistance <= threshold;
|
|
933
|
+
const updateSnapshot = () => {
|
|
934
|
+
setSnapshot({
|
|
935
|
+
atThreshold,
|
|
936
|
+
contentSize: context.contentSize,
|
|
937
|
+
dataLength: context.dataLength,
|
|
938
|
+
scrollPosition: context.scrollPosition
|
|
939
|
+
});
|
|
940
|
+
};
|
|
941
|
+
if (!wasReached) {
|
|
942
|
+
if (!within) {
|
|
943
|
+
return false;
|
|
1139
944
|
}
|
|
945
|
+
onReached(distance);
|
|
946
|
+
updateSnapshot();
|
|
947
|
+
return true;
|
|
1140
948
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
recycleItems,
|
|
1146
|
-
ItemSeparatorComponent,
|
|
1147
|
-
stickyHeaderConfig,
|
|
1148
|
-
updateItemSize: updateItemSize2,
|
|
1149
|
-
getRenderedItem: getRenderedItem2
|
|
1150
|
-
}) {
|
|
1151
|
-
const [numContainersPooled] = useArr$(["numContainersPooled"]);
|
|
1152
|
-
const containers = [];
|
|
1153
|
-
for (let i = 0; i < numContainersPooled; i++) {
|
|
1154
|
-
containers.push(
|
|
1155
|
-
/* @__PURE__ */ React2__namespace.createElement(
|
|
1156
|
-
ContainerSlot,
|
|
1157
|
-
{
|
|
1158
|
-
getRenderedItem: getRenderedItem2,
|
|
1159
|
-
horizontal,
|
|
1160
|
-
ItemSeparatorComponent,
|
|
1161
|
-
id: i,
|
|
1162
|
-
key: i,
|
|
1163
|
-
recycleItems,
|
|
1164
|
-
stickyHeaderConfig,
|
|
1165
|
-
updateItemSize: updateItemSize2
|
|
1166
|
-
}
|
|
1167
|
-
)
|
|
1168
|
-
);
|
|
949
|
+
const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
|
|
950
|
+
if (reset) {
|
|
951
|
+
setSnapshot(void 0);
|
|
952
|
+
return false;
|
|
1169
953
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
otherAxisSize
|
|
1179
|
-
}) {
|
|
1180
|
-
if (!needsOtherAxisSize || !otherAxisSize || otherAxisSize <= 0) {
|
|
1181
|
-
return void 0;
|
|
954
|
+
if (within) {
|
|
955
|
+
const changed = !snapshot || snapshot.atThreshold !== atThreshold || snapshot.contentSize !== context.contentSize || snapshot.dataLength !== context.dataLength;
|
|
956
|
+
if (changed) {
|
|
957
|
+
if (allowReentryOnChange) {
|
|
958
|
+
onReached(distance);
|
|
959
|
+
}
|
|
960
|
+
updateSnapshot();
|
|
961
|
+
}
|
|
1182
962
|
}
|
|
1183
|
-
return
|
|
963
|
+
return true;
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
// src/utils/hasActiveInitialScroll.ts
|
|
967
|
+
function hasActiveInitialScroll(state) {
|
|
968
|
+
return !!(state == null ? void 0 : state.initialScroll) && !state.didFinishInitialScroll;
|
|
1184
969
|
}
|
|
1185
|
-
|
|
970
|
+
|
|
971
|
+
// src/utils/checkAtBottom.ts
|
|
972
|
+
function checkAtBottom(ctx) {
|
|
1186
973
|
var _a3;
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
974
|
+
const state = ctx.state;
|
|
975
|
+
if (!state) {
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
const {
|
|
979
|
+
queuedInitialLayout,
|
|
980
|
+
scrollLength,
|
|
981
|
+
scroll,
|
|
982
|
+
maintainingScrollAtEnd,
|
|
983
|
+
props: { maintainScrollAtEndThreshold, onEndReachedThreshold }
|
|
984
|
+
} = state;
|
|
985
|
+
const contentSize = getContentSize(ctx);
|
|
986
|
+
if (contentSize > 0 && queuedInitialLayout) {
|
|
987
|
+
const insetEnd = getContentInsetEnd(ctx);
|
|
988
|
+
const distanceFromEnd = contentSize - scroll - scrollLength - insetEnd;
|
|
989
|
+
const isContentLess = contentSize < scrollLength;
|
|
990
|
+
set$(ctx, "isAtEnd", isContentLess || distanceFromEnd <= EDGE_POSITION_EPSILON);
|
|
991
|
+
set$(ctx, "isNearEnd", isContentLess || distanceFromEnd <= onEndReachedThreshold * scrollLength);
|
|
992
|
+
set$(
|
|
993
|
+
ctx,
|
|
994
|
+
"isWithinMaintainScrollAtEndThreshold",
|
|
995
|
+
isContentLess || distanceFromEnd <= maintainScrollAtEndThreshold * scrollLength
|
|
996
|
+
);
|
|
997
|
+
const shouldSkipThresholdChecks = hasActiveInitialScroll(state) || maintainingScrollAtEnd;
|
|
998
|
+
if (!shouldSkipThresholdChecks) {
|
|
999
|
+
state.isEndReached = checkThreshold(
|
|
1000
|
+
distanceFromEnd,
|
|
1001
|
+
isContentLess,
|
|
1002
|
+
onEndReachedThreshold * scrollLength,
|
|
1003
|
+
state.isEndReached,
|
|
1004
|
+
state.endReachedSnapshot,
|
|
1005
|
+
{
|
|
1006
|
+
contentSize,
|
|
1007
|
+
dataLength: (_a3 = state.props.data) == null ? void 0 : _a3.length,
|
|
1008
|
+
scrollPosition: scroll
|
|
1009
|
+
},
|
|
1010
|
+
(distance) => {
|
|
1011
|
+
var _a4, _b;
|
|
1012
|
+
return (_b = (_a4 = state.props).onEndReached) == null ? void 0 : _b.call(_a4, { distanceFromEnd: distance });
|
|
1013
|
+
},
|
|
1014
|
+
(snapshot) => {
|
|
1015
|
+
state.endReachedSnapshot = snapshot;
|
|
1016
|
+
},
|
|
1017
|
+
true
|
|
1018
|
+
);
|
|
1202
1019
|
}
|
|
1203
|
-
);
|
|
1204
|
-
}
|
|
1205
|
-
var SnapWrapper = React2__namespace.forwardRef(function SnapWrapperInner({ ScrollComponent, ...props }, ref) {
|
|
1206
|
-
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
1207
|
-
return /* @__PURE__ */ React2__namespace.createElement(ScrollComponent, { ...props, ref, snapToOffsets });
|
|
1208
|
-
});
|
|
1209
|
-
function WebAnchoredEndSpace({ horizontal }) {
|
|
1210
|
-
const ctx = useStateContext();
|
|
1211
|
-
const [anchoredEndSpaceSize] = useArr$(["anchoredEndSpaceSize"]);
|
|
1212
|
-
const shouldRenderAnchoredEndSpace = !!ctx.state.props.anchoredEndSpace && (anchoredEndSpaceSize || 0) > 0;
|
|
1213
|
-
if (!shouldRenderAnchoredEndSpace) {
|
|
1214
|
-
return null;
|
|
1215
1020
|
}
|
|
1216
|
-
const style = horizontal ? { height: "100%", width: anchoredEndSpaceSize || 0 } : { height: anchoredEndSpaceSize || 0 };
|
|
1217
|
-
return /* @__PURE__ */ React2__namespace.createElement("div", { style }, null);
|
|
1218
1021
|
}
|
|
1219
1022
|
|
|
1220
|
-
// src/
|
|
1221
|
-
function
|
|
1222
|
-
|
|
1023
|
+
// src/utils/isInMVCPActiveMode.native.ts
|
|
1024
|
+
function isInMVCPActiveMode(state) {
|
|
1025
|
+
return state.dataChangeNeedsScrollUpdate;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/utils/checkAtTop.ts
|
|
1029
|
+
function checkAtTop(ctx) {
|
|
1030
|
+
const state = ctx == null ? void 0 : ctx.state;
|
|
1031
|
+
if (!state) {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1223
1034
|
const {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1035
|
+
dataChangeEpoch,
|
|
1036
|
+
isStartReached,
|
|
1037
|
+
props: { data, onStartReachedThreshold },
|
|
1038
|
+
scroll,
|
|
1039
|
+
scrollLength,
|
|
1040
|
+
startReachedSnapshot,
|
|
1041
|
+
startReachedSnapshotDataChangeEpoch,
|
|
1042
|
+
totalSize
|
|
1228
1043
|
} = state;
|
|
1229
|
-
const
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1044
|
+
const dataLength = data.length;
|
|
1045
|
+
const threshold = onStartReachedThreshold * scrollLength;
|
|
1046
|
+
const dataChanged = startReachedSnapshotDataChangeEpoch !== dataChangeEpoch;
|
|
1047
|
+
const withinThreshold = threshold > 0 && Math.abs(scroll) <= threshold;
|
|
1048
|
+
const allowReentryOnDataChange = !!isStartReached && withinThreshold && !!dataChanged && !isInMVCPActiveMode(state);
|
|
1049
|
+
if (isStartReached && threshold > 0 && scroll > threshold && startReachedSnapshot && (dataChanged || startReachedSnapshot.contentSize !== totalSize || startReachedSnapshot.dataLength !== dataLength)) {
|
|
1050
|
+
state.isStartReached = false;
|
|
1051
|
+
state.startReachedSnapshot = void 0;
|
|
1052
|
+
state.startReachedSnapshotDataChangeEpoch = void 0;
|
|
1234
1053
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
state.
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
});
|
|
1262
|
-
}
|
|
1263
|
-
setTimeout(
|
|
1264
|
-
() => {
|
|
1265
|
-
if (state.maintainingScrollAtEnd === activeState) {
|
|
1266
|
-
state.maintainingScrollAtEnd = void 0;
|
|
1267
|
-
}
|
|
1268
|
-
},
|
|
1269
|
-
maintainScrollAtEnd.animated ? 500 : 0
|
|
1270
|
-
);
|
|
1271
|
-
} else if (state.maintainingScrollAtEnd === pendingState) {
|
|
1272
|
-
state.maintainingScrollAtEnd = void 0;
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
}
|
|
1276
|
-
return true;
|
|
1054
|
+
set$(ctx, "isAtStart", scroll <= EDGE_POSITION_EPSILON);
|
|
1055
|
+
set$(ctx, "isNearStart", scroll <= threshold);
|
|
1056
|
+
const shouldSkipThresholdChecks = hasActiveInitialScroll(state) || !!state.scrollingTo;
|
|
1057
|
+
const shouldDeferDataChangeRefire = isStartReached && withinThreshold && dataChanged && !allowReentryOnDataChange;
|
|
1058
|
+
if (!shouldSkipThresholdChecks && !shouldDeferDataChangeRefire) {
|
|
1059
|
+
state.isStartReached = checkThreshold(
|
|
1060
|
+
scroll,
|
|
1061
|
+
false,
|
|
1062
|
+
threshold,
|
|
1063
|
+
state.isStartReached,
|
|
1064
|
+
allowReentryOnDataChange ? void 0 : startReachedSnapshot,
|
|
1065
|
+
{
|
|
1066
|
+
contentSize: totalSize,
|
|
1067
|
+
dataLength,
|
|
1068
|
+
scrollPosition: scroll
|
|
1069
|
+
},
|
|
1070
|
+
(distance) => {
|
|
1071
|
+
var _a3, _b;
|
|
1072
|
+
return (_b = (_a3 = state.props).onStartReached) == null ? void 0 : _b.call(_a3, { distanceFromStart: distance });
|
|
1073
|
+
},
|
|
1074
|
+
(snapshot) => {
|
|
1075
|
+
state.startReachedSnapshot = snapshot;
|
|
1076
|
+
state.startReachedSnapshotDataChangeEpoch = snapshot ? dataChangeEpoch : void 0;
|
|
1077
|
+
},
|
|
1078
|
+
allowReentryOnDataChange
|
|
1079
|
+
);
|
|
1277
1080
|
}
|
|
1278
|
-
return false;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
// src/core/calculateOffsetForIndex.ts
|
|
1282
|
-
function calculateOffsetForIndex(ctx, index) {
|
|
1283
|
-
const state = ctx.state;
|
|
1284
|
-
return index !== void 0 ? state.positions[index] || 0 : 0;
|
|
1285
1081
|
}
|
|
1286
1082
|
|
|
1287
|
-
// src/
|
|
1288
|
-
function
|
|
1289
|
-
|
|
1083
|
+
// src/utils/checkThresholds.ts
|
|
1084
|
+
function checkThresholds(ctx) {
|
|
1085
|
+
checkAtBottom(ctx);
|
|
1086
|
+
checkAtTop(ctx);
|
|
1290
1087
|
}
|
|
1291
1088
|
|
|
1292
|
-
// src/
|
|
1293
|
-
function
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1089
|
+
// src/core/recalculateSettledScroll.ts
|
|
1090
|
+
function recalculateSettledScroll(ctx) {
|
|
1091
|
+
var _a3, _b;
|
|
1092
|
+
const state = ctx.state;
|
|
1093
|
+
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1094
|
+
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1297
1095
|
}
|
|
1298
|
-
|
|
1299
|
-
const id = ret;
|
|
1300
|
-
state.idCache[index] = id;
|
|
1301
|
-
return id;
|
|
1096
|
+
checkThresholds(ctx);
|
|
1302
1097
|
}
|
|
1303
1098
|
|
|
1304
|
-
// src/core/
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
if (previousPadding !== nextPadding) {
|
|
1319
|
-
set$(ctx, "alignItemsAtEndPadding", nextPadding);
|
|
1099
|
+
// src/core/adaptiveRender.ts
|
|
1100
|
+
var DEFAULT_ADAPTIVE_RENDER_ENTER_VELOCITY = 3;
|
|
1101
|
+
var DEFAULT_ADAPTIVE_RENDER_EXIT_VELOCITY = 1;
|
|
1102
|
+
var DEFAULT_ADAPTIVE_RENDER_EXIT_DELAY = 250;
|
|
1103
|
+
var DEFAULT_WEB_ADAPTIVE_RENDER_ENTER_VELOCITY = 6;
|
|
1104
|
+
var DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_VELOCITY = 3;
|
|
1105
|
+
var DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_DELAY = 250;
|
|
1106
|
+
function clearAdaptiveRenderExitTimeout(ctx) {
|
|
1107
|
+
const state = ctx.state;
|
|
1108
|
+
const previousTimeout = state.timeoutAdaptiveRender;
|
|
1109
|
+
if (previousTimeout !== void 0) {
|
|
1110
|
+
clearTimeout(previousTimeout);
|
|
1111
|
+
state.timeouts.delete(previousTimeout);
|
|
1112
|
+
state.timeoutAdaptiveRender = void 0;
|
|
1320
1113
|
}
|
|
1321
1114
|
}
|
|
1322
|
-
|
|
1323
|
-
// src/core/addTotalSize.ts
|
|
1324
|
-
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
1115
|
+
function scheduleAdaptiveRenderExit(ctx, exitDelay) {
|
|
1325
1116
|
const state = ctx.state;
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
totalSize = add;
|
|
1330
|
-
if (state.timeoutSetPaddingTop) {
|
|
1331
|
-
clearTimeout(state.timeoutSetPaddingTop);
|
|
1332
|
-
state.timeoutSetPaddingTop = void 0;
|
|
1333
|
-
}
|
|
1117
|
+
clearAdaptiveRenderExitTimeout(ctx);
|
|
1118
|
+
if (exitDelay <= 0) {
|
|
1119
|
+
setAdaptiveRender(ctx, "normal");
|
|
1334
1120
|
} else {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1121
|
+
const timeout = setTimeout(() => {
|
|
1122
|
+
state.timeouts.delete(timeout);
|
|
1123
|
+
state.timeoutAdaptiveRender = void 0;
|
|
1124
|
+
setAdaptiveRender(ctx, "normal");
|
|
1125
|
+
}, exitDelay);
|
|
1126
|
+
state.timeoutAdaptiveRender = timeout;
|
|
1127
|
+
state.timeouts.add(timeout);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
function setAdaptiveRender(ctx, mode) {
|
|
1131
|
+
var _a3, _b;
|
|
1132
|
+
const previousMode = peek$(ctx, "adaptiveRender");
|
|
1133
|
+
if (previousMode !== mode) {
|
|
1134
|
+
set$(ctx, "adaptiveRender", mode);
|
|
1135
|
+
(_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.onChange) == null ? void 0 : _b.call(_a3, mode);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
function resetAdaptiveRender(ctx) {
|
|
1139
|
+
clearAdaptiveRenderExitTimeout(ctx);
|
|
1140
|
+
if (peek$(ctx, "adaptiveRender") !== "normal") {
|
|
1141
|
+
setAdaptiveRender(ctx, "normal");
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
function updateAdaptiveRender(ctx, scrollVelocity) {
|
|
1145
|
+
var _a3, _b, _c;
|
|
1146
|
+
const state = ctx.state;
|
|
1147
|
+
const adaptiveRender = state.props.adaptiveRender;
|
|
1148
|
+
const currentMode = peek$(ctx, "adaptiveRender");
|
|
1149
|
+
if (peek$(ctx, "readyToRender")) {
|
|
1150
|
+
if (adaptiveRender) {
|
|
1151
|
+
const isWeb = Platform.OS === "web";
|
|
1152
|
+
const enterVelocity = (_a3 = adaptiveRender.enterVelocity) != null ? _a3 : isWeb ? DEFAULT_WEB_ADAPTIVE_RENDER_ENTER_VELOCITY : DEFAULT_ADAPTIVE_RENDER_ENTER_VELOCITY;
|
|
1153
|
+
const exitVelocity = (_b = adaptiveRender.exitVelocity) != null ? _b : isWeb ? DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_VELOCITY : DEFAULT_ADAPTIVE_RENDER_EXIT_VELOCITY;
|
|
1154
|
+
const exitDelay = (_c = adaptiveRender.exitDelay) != null ? _c : isWeb ? DEFAULT_WEB_ADAPTIVE_RENDER_EXIT_DELAY : DEFAULT_ADAPTIVE_RENDER_EXIT_DELAY;
|
|
1155
|
+
const threshold = currentMode === "light" ? exitVelocity : enterVelocity;
|
|
1156
|
+
const nextMode = Math.abs(scrollVelocity) > threshold ? "light" : "normal";
|
|
1157
|
+
const previousMode = state.timeoutAdaptiveRender !== void 0 ? "normal" : currentMode;
|
|
1158
|
+
if (nextMode !== previousMode) {
|
|
1159
|
+
if (nextMode === "light") {
|
|
1160
|
+
setAdaptiveRender(ctx, "light");
|
|
1161
|
+
scheduleAdaptiveRenderExit(ctx, exitDelay);
|
|
1162
|
+
} else if (currentMode === "light") {
|
|
1163
|
+
scheduleAdaptiveRenderExit(ctx, exitDelay);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
} else {
|
|
1167
|
+
resetAdaptiveRender(ctx);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
// src/utils/getEffectiveDrawDistance.ts
|
|
1173
|
+
var INITIAL_DRAW_DISTANCE = 100;
|
|
1174
|
+
function getEffectiveDrawDistance(ctx) {
|
|
1175
|
+
var _a3;
|
|
1176
|
+
const drawDistance = ctx.state.props.drawDistance;
|
|
1177
|
+
const initialScroll = ctx.state.initialScroll;
|
|
1178
|
+
const needsFullInitialDrawDistance = initialScroll !== void 0 && ((_a3 = initialScroll.viewPosition) != null ? _a3 : 0) > 0;
|
|
1179
|
+
return peek$(ctx, "readyToRender") || needsFullInitialDrawDistance ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// src/utils/setInitialRenderState.ts
|
|
1183
|
+
function setInitialRenderState(ctx, {
|
|
1184
|
+
didLayout,
|
|
1185
|
+
didInitialScroll
|
|
1186
|
+
}) {
|
|
1187
|
+
const { state } = ctx;
|
|
1188
|
+
const {
|
|
1189
|
+
loadStartTime,
|
|
1190
|
+
props: { onLoad }
|
|
1191
|
+
} = state;
|
|
1192
|
+
if (didLayout) {
|
|
1193
|
+
state.didContainersLayout = true;
|
|
1194
|
+
}
|
|
1195
|
+
if (didInitialScroll) {
|
|
1196
|
+
state.didFinishInitialScroll = true;
|
|
1197
|
+
}
|
|
1198
|
+
const isReadyToRender = Boolean(state.didContainersLayout && state.didFinishInitialScroll);
|
|
1199
|
+
if (isReadyToRender && !peek$(ctx, "readyToRender")) {
|
|
1200
|
+
set$(ctx, "readyToRender", true);
|
|
1201
|
+
setAdaptiveRender(ctx, "normal");
|
|
1202
|
+
if (state.props.drawDistance > INITIAL_DRAW_DISTANCE) {
|
|
1203
|
+
requestAnimationFrame(() => {
|
|
1204
|
+
var _a3;
|
|
1205
|
+
(_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
if (onLoad) {
|
|
1209
|
+
onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// src/core/finishInitialScroll.ts
|
|
1215
|
+
var PRESERVED_INITIAL_SCROLL_FALLBACK_CLEAR_DELAY_MS = 2e3;
|
|
1216
|
+
function syncInitialScrollOffset(state, offset) {
|
|
1217
|
+
state.scroll = offset;
|
|
1218
|
+
state.scrollPending = offset;
|
|
1219
|
+
state.scrollPrev = offset;
|
|
1220
|
+
}
|
|
1221
|
+
function clearPreservedInitialScrollTargetTimeout(state) {
|
|
1222
|
+
if (state.timeoutPreservedInitialScrollClear !== void 0) {
|
|
1223
|
+
clearTimeout(state.timeoutPreservedInitialScrollClear);
|
|
1224
|
+
state.timeoutPreservedInitialScrollClear = void 0;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
function clearPreservedInitialScrollTarget(state) {
|
|
1228
|
+
clearPreservedInitialScrollTargetTimeout(state);
|
|
1229
|
+
state.clearPreservedInitialScrollOnNextFinish = void 0;
|
|
1230
|
+
state.initialScroll = void 0;
|
|
1231
|
+
setInitialScrollSession(state);
|
|
1232
|
+
}
|
|
1233
|
+
function finishInitialScroll(ctx, options) {
|
|
1234
|
+
var _a3, _b, _c;
|
|
1235
|
+
const state = ctx.state;
|
|
1236
|
+
if ((options == null ? void 0 : options.resolvedOffset) !== void 0) {
|
|
1237
|
+
syncInitialScrollOffset(state, options.resolvedOffset);
|
|
1238
|
+
} else if ((options == null ? void 0 : options.syncObservedOffset) && ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset") {
|
|
1239
|
+
const observedOffset = (_c = (_b = state.refScroller.current) == null ? void 0 : _b.getCurrentScrollOffset) == null ? void 0 : _c.call(_b);
|
|
1240
|
+
if (typeof observedOffset === "number" && Number.isFinite(observedOffset)) {
|
|
1241
|
+
syncInitialScrollOffset(state, observedOffset);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
const complete = () => {
|
|
1245
|
+
var _a4, _b2, _c2, _d, _e;
|
|
1246
|
+
const shouldReleaseDeferredPublicOnScroll = Platform.OS === "web" && ((_a4 = state.initialScrollSession) == null ? void 0 : _a4.kind) === "bootstrap";
|
|
1247
|
+
const finalScrollOffset = (_d = (_c2 = (_b2 = options == null ? void 0 : options.resolvedOffset) != null ? _b2 : state.scrollPending) != null ? _c2 : state.scroll) != null ? _d : 0;
|
|
1248
|
+
initialScrollWatchdog.clear(state);
|
|
1249
|
+
if ((options == null ? void 0 : options.preserveTarget) && state.initialScroll) {
|
|
1250
|
+
state.clearPreservedInitialScrollOnNextFinish = void 0;
|
|
1251
|
+
setInitialScrollSession(state);
|
|
1252
|
+
clearPreservedInitialScrollTargetTimeout(state);
|
|
1253
|
+
if (options == null ? void 0 : options.schedulePreservedTargetClear) {
|
|
1254
|
+
state.timeoutPreservedInitialScrollClear = setTimeout(() => {
|
|
1255
|
+
var _a5;
|
|
1256
|
+
state.timeoutPreservedInitialScrollClear = void 0;
|
|
1257
|
+
if (!state.didFinishInitialScroll || ((_a5 = state.scrollingTo) == null ? void 0 : _a5.isInitialScroll) || !state.initialScroll) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
clearPreservedInitialScrollTarget(state);
|
|
1261
|
+
}, PRESERVED_INITIAL_SCROLL_FALLBACK_CLEAR_DELAY_MS);
|
|
1262
|
+
}
|
|
1263
|
+
} else {
|
|
1264
|
+
clearPreservedInitialScrollTarget(state);
|
|
1265
|
+
}
|
|
1266
|
+
if (options == null ? void 0 : options.recalculateItems) {
|
|
1267
|
+
recalculateSettledScroll(ctx);
|
|
1268
|
+
}
|
|
1269
|
+
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
1270
|
+
if (shouldReleaseDeferredPublicOnScroll) {
|
|
1271
|
+
releaseDeferredPublicOnScroll(ctx, finalScrollOffset);
|
|
1272
|
+
}
|
|
1273
|
+
(_e = options == null ? void 0 : options.onFinished) == null ? void 0 : _e.call(options);
|
|
1274
|
+
};
|
|
1275
|
+
if (options == null ? void 0 : options.waitForCompletionFrame) {
|
|
1276
|
+
requestAnimationFrame(complete);
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
complete();
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
// src/core/calculateOffsetForIndex.ts
|
|
1283
|
+
function calculateOffsetForIndex(ctx, index) {
|
|
1284
|
+
const state = ctx.state;
|
|
1285
|
+
return index !== void 0 ? state.positions[index] || 0 : 0;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
// src/core/getTopOffsetAdjustment.ts
|
|
1289
|
+
function getTopOffsetAdjustment(ctx) {
|
|
1290
|
+
return (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "alignItemsAtEndPadding") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// src/utils/getId.ts
|
|
1294
|
+
function getId(state, index) {
|
|
1295
|
+
const { data, keyExtractor } = state.props;
|
|
1296
|
+
if (!data) {
|
|
1297
|
+
return "";
|
|
1298
|
+
}
|
|
1299
|
+
const ret = index < data.length ? keyExtractor ? keyExtractor(data[index], index) : index : null;
|
|
1300
|
+
const id = ret;
|
|
1301
|
+
state.idCache[index] = id;
|
|
1302
|
+
return id;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
// src/core/updateContentMetricsState.ts
|
|
1306
|
+
function getRawContentLength(ctx) {
|
|
1307
|
+
var _a3, _b, _c;
|
|
1308
|
+
const { state, values } = ctx;
|
|
1309
|
+
return (values.get("headerSize") || 0) + (values.get("footerSize") || 0) + ((_c = (_b = (_a3 = state.pendingTotalSize) != null ? _a3 : state.totalSize) != null ? _b : values.get("totalSize")) != null ? _c : 0) + (state.props.stylePaddingTop || 0) + (state.props.stylePaddingBottom || 0);
|
|
1310
|
+
}
|
|
1311
|
+
function getAlignItemsAtEndPadding(ctx) {
|
|
1312
|
+
const { state } = ctx;
|
|
1313
|
+
const shouldPad = !!state.props.alignItemsAtEndPaddingEnabled && !state.props.horizontal && state.props.data.length > 0 && state.scrollLength > 0;
|
|
1314
|
+
return shouldPad ? Math.max(0, state.scrollLength - getRawContentLength(ctx) - getContentInsetEnd(ctx)) : 0;
|
|
1315
|
+
}
|
|
1316
|
+
function updateContentMetricsState(ctx) {
|
|
1317
|
+
const previousPadding = peek$(ctx, "alignItemsAtEndPadding") || 0;
|
|
1318
|
+
const nextPadding = getAlignItemsAtEndPadding(ctx);
|
|
1319
|
+
if (previousPadding !== nextPadding) {
|
|
1320
|
+
set$(ctx, "alignItemsAtEndPadding", nextPadding);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// src/core/addTotalSize.ts
|
|
1325
|
+
function addTotalSize(ctx, key, add, notifyTotalSize = true) {
|
|
1326
|
+
const state = ctx.state;
|
|
1327
|
+
const prevTotalSize = state.totalSize;
|
|
1328
|
+
let totalSize = state.totalSize;
|
|
1329
|
+
if (key === null) {
|
|
1330
|
+
totalSize = add;
|
|
1331
|
+
if (state.timeoutSetPaddingTop) {
|
|
1332
|
+
clearTimeout(state.timeoutSetPaddingTop);
|
|
1333
|
+
state.timeoutSetPaddingTop = void 0;
|
|
1334
|
+
}
|
|
1335
|
+
} else {
|
|
1336
|
+
totalSize += add;
|
|
1337
|
+
}
|
|
1338
|
+
if (prevTotalSize !== totalSize) {
|
|
1339
|
+
if (!IsNewArchitecture && state.initialScroll && totalSize < prevTotalSize) {
|
|
1339
1340
|
state.pendingTotalSize = totalSize;
|
|
1340
1341
|
} else {
|
|
1341
1342
|
state.pendingTotalSize = void 0;
|
|
@@ -1494,1223 +1495,539 @@ function clampScrollOffset(ctx, offset, scrollTarget) {
|
|
|
1494
1495
|
return clampedOffset;
|
|
1495
1496
|
}
|
|
1496
1497
|
|
|
1497
|
-
// src/core/
|
|
1498
|
-
function
|
|
1499
|
-
|
|
1500
|
-
...event,
|
|
1501
|
-
nativeEvent: {
|
|
1502
|
-
...event.nativeEvent,
|
|
1503
|
-
contentOffset: state.props.horizontal ? { x: resolvedOffset, y: 0 } : { x: 0, y: resolvedOffset }
|
|
1504
|
-
}
|
|
1505
|
-
};
|
|
1506
|
-
}
|
|
1507
|
-
function releaseDeferredPublicOnScroll(ctx, resolvedOffset) {
|
|
1508
|
-
var _a3, _b, _c, _d;
|
|
1498
|
+
// src/core/finishScrollTo.ts
|
|
1499
|
+
function finishScrollTo(ctx) {
|
|
1500
|
+
var _a3, _b;
|
|
1509
1501
|
const state = ctx.state;
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1502
|
+
if (state == null ? void 0 : state.scrollingTo) {
|
|
1503
|
+
const resolvePendingScroll = state.pendingScrollResolve;
|
|
1504
|
+
state.pendingScrollResolve = void 0;
|
|
1505
|
+
const scrollingTo = state.scrollingTo;
|
|
1506
|
+
state.scrollHistory.length = 0;
|
|
1507
|
+
state.scrollingTo = void 0;
|
|
1508
|
+
if (state.pendingTotalSize !== void 0) {
|
|
1509
|
+
addTotalSize(ctx, null, state.pendingTotalSize);
|
|
1510
|
+
}
|
|
1511
|
+
if (PlatformAdjustBreaksScroll) {
|
|
1512
|
+
state.scrollAdjustHandler.commitPendingAdjust(scrollingTo);
|
|
1513
|
+
}
|
|
1514
|
+
if (scrollingTo.isInitialScroll || state.initialScroll) {
|
|
1515
|
+
const isOffsetSession = ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "offset";
|
|
1516
|
+
const shouldPreserveResizeTarget = !!scrollingTo.isInitialScroll && !state.clearPreservedInitialScrollOnNextFinish && state.props.data.length > 0 && ((_b = state.initialScroll) == null ? void 0 : _b.viewPosition) === 1;
|
|
1517
|
+
finishInitialScroll(ctx, {
|
|
1518
|
+
onFinished: () => {
|
|
1519
|
+
resolvePendingScroll == null ? void 0 : resolvePendingScroll();
|
|
1520
|
+
},
|
|
1521
|
+
preserveTarget: isOffsetSession && state.props.data.length === 0 || shouldPreserveResizeTarget,
|
|
1522
|
+
recalculateItems: true,
|
|
1523
|
+
schedulePreservedTargetClear: shouldPreserveResizeTarget,
|
|
1524
|
+
syncObservedOffset: isOffsetSession,
|
|
1525
|
+
waitForCompletionFrame: !!scrollingTo.waitForInitialScrollCompletionFrame
|
|
1526
|
+
});
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
recalculateSettledScroll(ctx);
|
|
1530
|
+
resolvePendingScroll == null ? void 0 : resolvePendingScroll();
|
|
1521
1531
|
}
|
|
1522
1532
|
}
|
|
1523
1533
|
|
|
1524
|
-
// src/core/
|
|
1525
|
-
var
|
|
1526
|
-
|
|
1527
|
-
|
|
1534
|
+
// src/core/checkFinishedScroll.ts
|
|
1535
|
+
var INITIAL_SCROLL_MAX_FALLBACK_CHECKS = 20;
|
|
1536
|
+
var INITIAL_SCROLL_COMPLETION_TARGET_EPSILON = 1;
|
|
1537
|
+
var INITIAL_SCROLL_ZERO_TARGET_EPSILON = 1;
|
|
1538
|
+
var SILENT_INITIAL_SCROLL_RETRY_DELAY_MS = 16;
|
|
1539
|
+
var SILENT_INITIAL_SCROLL_TARGET_EPSILON = 1;
|
|
1540
|
+
function checkFinishedScroll(ctx, options) {
|
|
1541
|
+
const scrollingTo = ctx.state.scrollingTo;
|
|
1542
|
+
if (options == null ? void 0 : options.onlyIfAligned) {
|
|
1543
|
+
if (!(scrollingTo == null ? void 0 : scrollingTo.isInitialScroll) || scrollingTo.animated) {
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
if (!getResolvedScrollCompletionState(ctx, scrollingTo).isAtResolvedTarget) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
ctx.state.animFrameCheckFinishedScroll = requestAnimationFrame(() => checkFinishedScrollFrame(ctx));
|
|
1528
1551
|
}
|
|
1529
|
-
function
|
|
1530
|
-
|
|
1531
|
-
return
|
|
1552
|
+
function hasScrollCompletionOwnership(state, options) {
|
|
1553
|
+
const { clampedTargetOffset, scrollingTo } = options;
|
|
1554
|
+
return !scrollingTo.isInitialScroll || state.hasScrolled || clampedTargetOffset <= INITIAL_SCROLL_COMPLETION_TARGET_EPSILON;
|
|
1532
1555
|
}
|
|
1533
|
-
function
|
|
1534
|
-
|
|
1535
|
-
return kind === "offset" ? {
|
|
1536
|
-
completion,
|
|
1537
|
-
kind,
|
|
1538
|
-
previousDataLength
|
|
1539
|
-
} : {
|
|
1540
|
-
bootstrap,
|
|
1541
|
-
completion,
|
|
1542
|
-
kind,
|
|
1543
|
-
previousDataLength
|
|
1544
|
-
};
|
|
1556
|
+
function isSilentInitialDispatch(state, scrollingTo) {
|
|
1557
|
+
return !!(scrollingTo == null ? void 0 : scrollingTo.isInitialScroll) && initialScrollCompletion.didDispatchNativeScroll(state) && !state.hasScrolled;
|
|
1545
1558
|
}
|
|
1546
|
-
function
|
|
1547
|
-
var
|
|
1548
|
-
|
|
1549
|
-
state.initialScrollSession = createInitialScrollSession({
|
|
1550
|
-
completion: {},
|
|
1551
|
-
kind,
|
|
1552
|
-
previousDataLength: 0
|
|
1553
|
-
});
|
|
1554
|
-
} else if (state.initialScrollSession.kind !== kind) {
|
|
1555
|
-
state.initialScrollSession = createInitialScrollSession({
|
|
1556
|
-
bootstrap: state.initialScrollSession.kind === "bootstrap" ? state.initialScrollSession.bootstrap : void 0,
|
|
1557
|
-
completion: state.initialScrollSession.completion,
|
|
1558
|
-
kind,
|
|
1559
|
-
previousDataLength: state.initialScrollSession.previousDataLength
|
|
1560
|
-
});
|
|
1561
|
-
}
|
|
1562
|
-
(_b2 = (_a4 = state.initialScrollSession).completion) != null ? _b2 : _a4.completion = {};
|
|
1563
|
-
return state.initialScrollSession.completion;
|
|
1559
|
+
function getInitialScrollWatchdogTargetOffset(state) {
|
|
1560
|
+
var _a3;
|
|
1561
|
+
return (_a3 = initialScrollWatchdog.get(state)) == null ? void 0 : _a3.targetOffset;
|
|
1564
1562
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
return
|
|
1573
|
-
},
|
|
1574
|
-
markInitialScrollNativeDispatch(state) {
|
|
1575
|
-
ensureInitialScrollSessionCompletion(state).didDispatchNativeScroll = true;
|
|
1576
|
-
},
|
|
1577
|
-
markSilentInitialScrollRetry(state) {
|
|
1578
|
-
ensureInitialScrollSessionCompletion(state).didRetrySilentInitialScroll = true;
|
|
1579
|
-
},
|
|
1580
|
-
resetFlags(state) {
|
|
1581
|
-
if (!state.initialScrollSession) {
|
|
1582
|
-
return;
|
|
1583
|
-
}
|
|
1584
|
-
const completion = ensureInitialScrollSessionCompletion(state, state.initialScrollSession.kind);
|
|
1585
|
-
completion.didDispatchNativeScroll = void 0;
|
|
1586
|
-
completion.didRetrySilentInitialScroll = void 0;
|
|
1563
|
+
function isNativeInitialNonZeroTarget(state) {
|
|
1564
|
+
const targetOffset = getInitialScrollWatchdogTargetOffset(state);
|
|
1565
|
+
return !state.didFinishInitialScroll && initialScrollWatchdog.hasNonZeroTargetOffset(targetOffset);
|
|
1566
|
+
}
|
|
1567
|
+
function shouldFinishInitialScrollWithoutNativeProgress(state, scrollingTo) {
|
|
1568
|
+
var _a3, _b;
|
|
1569
|
+
if (!scrollingTo.isInitialScroll || scrollingTo.animated || !state.didContainersLayout) {
|
|
1570
|
+
return false;
|
|
1587
1571
|
}
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
clear(state) {
|
|
1591
|
-
initialScrollWatchdog.set(state, void 0);
|
|
1592
|
-
},
|
|
1593
|
-
didReachTarget(newScroll, watchdog) {
|
|
1594
|
-
const nextDistance = Math.abs(newScroll - watchdog.targetOffset);
|
|
1595
|
-
return nextDistance <= INITIAL_SCROLL_MIN_TARGET_OFFSET;
|
|
1596
|
-
},
|
|
1597
|
-
get(state) {
|
|
1598
|
-
var _a3, _b;
|
|
1599
|
-
return (_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.completion) == null ? void 0 : _b.watchdog;
|
|
1600
|
-
},
|
|
1601
|
-
hasNonZeroTargetOffset(targetOffset) {
|
|
1602
|
-
return targetOffset !== void 0 && targetOffset > INITIAL_SCROLL_MIN_TARGET_OFFSET;
|
|
1603
|
-
},
|
|
1604
|
-
isAtZeroTargetOffset(targetOffset) {
|
|
1605
|
-
return targetOffset <= INITIAL_SCROLL_MIN_TARGET_OFFSET;
|
|
1606
|
-
},
|
|
1607
|
-
set(state, watchdog) {
|
|
1608
|
-
var _a3, _b;
|
|
1609
|
-
if (!watchdog && !((_b = (_a3 = state.initialScrollSession) == null ? void 0 : _a3.completion) == null ? void 0 : _b.watchdog)) {
|
|
1610
|
-
return;
|
|
1611
|
-
}
|
|
1612
|
-
const completion = ensureInitialScrollSessionCompletion(state);
|
|
1613
|
-
completion.watchdog = watchdog ? {
|
|
1614
|
-
startScroll: watchdog.startScroll,
|
|
1615
|
-
targetOffset: watchdog.targetOffset
|
|
1616
|
-
} : void 0;
|
|
1572
|
+
if (((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "bootstrap") {
|
|
1573
|
+
return false;
|
|
1617
1574
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
const existingSession = state.initialScrollSession;
|
|
1622
|
-
const kind = (_a3 = options.kind) != null ? _a3 : existingSession == null ? void 0 : existingSession.kind;
|
|
1623
|
-
const completion = existingSession == null ? void 0 : existingSession.completion;
|
|
1624
|
-
const existingBootstrap = (existingSession == null ? void 0 : existingSession.kind) === "bootstrap" ? existingSession.bootstrap : void 0;
|
|
1625
|
-
const bootstrap = kind === "bootstrap" ? options.bootstrap === null ? void 0 : (_b = options.bootstrap) != null ? _b : existingBootstrap : void 0;
|
|
1626
|
-
if (!kind) {
|
|
1627
|
-
return clearInitialScrollSession(state);
|
|
1575
|
+
const targetOffset = (_b = scrollingTo.targetOffset) != null ? _b : scrollingTo.offset;
|
|
1576
|
+
if (initialScrollWatchdog.hasNonZeroTargetOffset(targetOffset) && initialScrollCompletion.didDispatchNativeScroll(state) && !state.hasScrolled) {
|
|
1577
|
+
return false;
|
|
1628
1578
|
}
|
|
1629
|
-
if (
|
|
1630
|
-
return
|
|
1579
|
+
if (initialScrollWatchdog.isAtZeroTargetOffset(targetOffset) || Math.abs(state.scroll - targetOffset) > 1 || Math.abs(state.scrollPending - targetOffset) > 1) {
|
|
1580
|
+
return false;
|
|
1631
1581
|
}
|
|
1632
|
-
|
|
1633
|
-
state.initialScrollSession = createInitialScrollSession({
|
|
1634
|
-
bootstrap,
|
|
1635
|
-
completion,
|
|
1636
|
-
kind,
|
|
1637
|
-
previousDataLength
|
|
1638
|
-
});
|
|
1639
|
-
return state.initialScrollSession;
|
|
1582
|
+
return !!scrollingTo.waitForInitialScrollCompletionFrame || isNativeInitialNonZeroTarget(state);
|
|
1640
1583
|
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1584
|
+
function shouldFinishInitialZeroTargetScroll(ctx) {
|
|
1585
|
+
var _a3;
|
|
1586
|
+
const { state } = ctx;
|
|
1587
|
+
return !!((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) && state.props.data.length > 0 && getContentSize(ctx) <= state.scrollLength && state.scrollPending <= INITIAL_SCROLL_ZERO_TARGET_EPSILON;
|
|
1588
|
+
}
|
|
1589
|
+
function isEndAlignedLastItemTarget(ctx, scrollingTo) {
|
|
1590
|
+
return scrollingTo.index === ctx.state.props.data.length - 1 && scrollingTo.viewPosition === 1;
|
|
1591
|
+
}
|
|
1592
|
+
function getCurrentTargetOffset(ctx, scrollingTo) {
|
|
1593
|
+
var _a3;
|
|
1594
|
+
const index = scrollingTo.index;
|
|
1595
|
+
const shouldRecomputeEndTarget = isEndAlignedLastItemTarget(ctx, scrollingTo);
|
|
1596
|
+
const requestedTargetOffset = shouldRecomputeEndTarget && index !== void 0 ? calculateOffsetWithOffsetPosition(ctx, calculateOffsetForIndex(ctx, index), scrollingTo) : (_a3 = scrollingTo.targetOffset) != null ? _a3 : clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0), scrollingTo);
|
|
1597
|
+
return clampScrollOffset(ctx, requestedTargetOffset, scrollingTo);
|
|
1598
|
+
}
|
|
1599
|
+
function getResolvedScrollCompletionState(ctx, scrollingTo) {
|
|
1600
|
+
const { state } = ctx;
|
|
1601
|
+
const scroll = state.scrollPending;
|
|
1602
|
+
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
1603
|
+
const clampedTargetOffset = getCurrentTargetOffset(ctx, scrollingTo);
|
|
1604
|
+
const maxOffset = clampScrollOffset(ctx, scroll, scrollingTo);
|
|
1605
|
+
const diff1 = Math.abs(scroll - clampedTargetOffset);
|
|
1606
|
+
const adjustedTargetOffset = clampedTargetOffset + adjust;
|
|
1607
|
+
const diff2 = Math.abs(scroll - adjustedTargetOffset);
|
|
1608
|
+
const canUseAdjustedCompletion = !scrollingTo.animated || Platform.OS === "ios";
|
|
1609
|
+
return {
|
|
1610
|
+
clampedTargetOffset,
|
|
1611
|
+
isAtResolvedTarget: Math.abs(scroll - maxOffset) < 1 && (diff1 < 1 || canUseAdjustedCompletion && diff2 < 1)
|
|
1654
1612
|
};
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
updateSnapshot();
|
|
1661
|
-
return true;
|
|
1662
|
-
}
|
|
1663
|
-
const reset = !atThreshold && threshold > 0 && absDistance >= threshold * HYSTERESIS_MULTIPLIER || !atThreshold && threshold <= 0 && absDistance > 0;
|
|
1664
|
-
if (reset) {
|
|
1665
|
-
setSnapshot(void 0);
|
|
1666
|
-
return false;
|
|
1613
|
+
}
|
|
1614
|
+
function checkFinishedScrollFrame(ctx) {
|
|
1615
|
+
const scrollingTo = ctx.state.scrollingTo;
|
|
1616
|
+
if (!scrollingTo) {
|
|
1617
|
+
return;
|
|
1667
1618
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1619
|
+
const { state } = ctx;
|
|
1620
|
+
state.animFrameCheckFinishedScroll = void 0;
|
|
1621
|
+
const completionState = getResolvedScrollCompletionState(ctx, scrollingTo);
|
|
1622
|
+
if (completionState.isAtResolvedTarget && hasScrollCompletionOwnership(state, {
|
|
1623
|
+
clampedTargetOffset: completionState.clampedTargetOffset,
|
|
1624
|
+
scrollingTo
|
|
1625
|
+
})) {
|
|
1626
|
+
finishScrollTo(ctx);
|
|
1676
1627
|
}
|
|
1677
|
-
return true;
|
|
1678
|
-
};
|
|
1679
|
-
|
|
1680
|
-
// src/utils/hasActiveInitialScroll.ts
|
|
1681
|
-
function hasActiveInitialScroll(state) {
|
|
1682
|
-
return !!(state == null ? void 0 : state.initialScroll) && !state.didFinishInitialScroll;
|
|
1683
1628
|
}
|
|
1684
|
-
|
|
1685
|
-
// src/utils/checkAtBottom.ts
|
|
1686
|
-
function checkAtBottom(ctx) {
|
|
1629
|
+
function scrollToFallbackOffset(ctx, offset) {
|
|
1687
1630
|
var _a3;
|
|
1631
|
+
(_a3 = ctx.state.refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
1632
|
+
animated: false,
|
|
1633
|
+
x: ctx.state.props.horizontal ? offset : 0,
|
|
1634
|
+
y: ctx.state.props.horizontal ? 0 : offset
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
function checkFinishedScrollFallback(ctx) {
|
|
1688
1638
|
const state = ctx.state;
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
{
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
(
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1639
|
+
const scrollingTo = state.scrollingTo;
|
|
1640
|
+
const shouldFinishInitialZeroTarget = shouldFinishInitialZeroTargetScroll(ctx);
|
|
1641
|
+
const silentInitialDispatch = isSilentInitialDispatch(state, scrollingTo);
|
|
1642
|
+
const canFinishInitialWithoutNativeProgress = scrollingTo !== void 0 ? shouldFinishInitialScrollWithoutNativeProgress(state, scrollingTo) : false;
|
|
1643
|
+
const slowTimeout = (scrollingTo == null ? void 0 : scrollingTo.isInitialScroll) && !shouldFinishInitialZeroTarget && !canFinishInitialWithoutNativeProgress || !state.didContainersLayout;
|
|
1644
|
+
const initialDelay = shouldFinishInitialZeroTarget || canFinishInitialWithoutNativeProgress ? 0 : silentInitialDispatch ? SILENT_INITIAL_SCROLL_RETRY_DELAY_MS : slowTimeout ? 500 : 100;
|
|
1645
|
+
state.timeoutCheckFinishedScrollFallback = setTimeout(() => {
|
|
1646
|
+
let numChecks = 0;
|
|
1647
|
+
const scheduleFallbackCheck = (delay) => {
|
|
1648
|
+
state.timeoutCheckFinishedScrollFallback = setTimeout(checkHasScrolled, delay);
|
|
1649
|
+
};
|
|
1650
|
+
const checkHasScrolled = () => {
|
|
1651
|
+
var _a3, _b, _c, _d;
|
|
1652
|
+
state.timeoutCheckFinishedScrollFallback = void 0;
|
|
1653
|
+
const isStillScrollingTo = state.scrollingTo;
|
|
1654
|
+
if (isStillScrollingTo) {
|
|
1655
|
+
numChecks++;
|
|
1656
|
+
const isNativeInitialPending = isNativeInitialNonZeroTarget(state) && !state.hasScrolled;
|
|
1657
|
+
const maxChecks = silentInitialDispatch ? 5 : isNativeInitialPending ? INITIAL_SCROLL_MAX_FALLBACK_CHECKS : 5;
|
|
1658
|
+
const shouldFinishZeroTarget = shouldFinishInitialZeroTargetScroll(ctx);
|
|
1659
|
+
const canFinishInitialScrollWithoutNativeProgress = shouldFinishInitialScrollWithoutNativeProgress(
|
|
1660
|
+
state,
|
|
1661
|
+
isStillScrollingTo
|
|
1662
|
+
);
|
|
1663
|
+
const completionState = getResolvedScrollCompletionState(ctx, isStillScrollingTo);
|
|
1664
|
+
const canFinishAfterSilentNativeDispatch = Platform.OS === "android" && silentInitialDispatch && completionState.isAtResolvedTarget && numChecks >= 1;
|
|
1665
|
+
const shouldRetrySilentInitialNativeScroll = Platform.OS === "android" && canFinishAfterSilentNativeDispatch && !initialScrollCompletion.didRetrySilentInitialScroll(state);
|
|
1666
|
+
const shouldFinishAfterObservedScroll = state.hasScrolled && (!isStillScrollingTo.isInitialScroll || completionState.isAtResolvedTarget);
|
|
1667
|
+
const shouldRetryUnalignedInitialScroll = isStillScrollingTo.isInitialScroll && !completionState.isAtResolvedTarget && numChecks <= maxChecks;
|
|
1668
|
+
const shouldRetryUnalignedEndScroll = Platform.OS === "ios" && !isStillScrollingTo.isInitialScroll && isEndAlignedLastItemTarget(ctx, isStillScrollingTo) && !completionState.isAtResolvedTarget && numChecks <= maxChecks;
|
|
1669
|
+
if (shouldRetrySilentInitialNativeScroll) {
|
|
1670
|
+
const targetOffset = (_b = (_a3 = getInitialScrollWatchdogTargetOffset(state)) != null ? _a3 : isStillScrollingTo.targetOffset) != null ? _b : 0;
|
|
1671
|
+
const jiggleOffset = targetOffset >= SILENT_INITIAL_SCROLL_TARGET_EPSILON ? targetOffset - SILENT_INITIAL_SCROLL_TARGET_EPSILON : targetOffset + SILENT_INITIAL_SCROLL_TARGET_EPSILON;
|
|
1672
|
+
initialScrollCompletion.markSilentInitialScrollRetry(state);
|
|
1673
|
+
scrollToFallbackOffset(ctx, jiggleOffset);
|
|
1674
|
+
requestAnimationFrame(() => {
|
|
1675
|
+
scrollToFallbackOffset(ctx, targetOffset);
|
|
1676
|
+
});
|
|
1677
|
+
scheduleFallbackCheck(SILENT_INITIAL_SCROLL_RETRY_DELAY_MS);
|
|
1678
|
+
} else if (shouldRetryUnalignedEndScroll) {
|
|
1679
|
+
scrollToFallbackOffset(ctx, completionState.clampedTargetOffset);
|
|
1680
|
+
scheduleFallbackCheck(100);
|
|
1681
|
+
} else if (shouldFinishZeroTarget || shouldFinishAfterObservedScroll || canFinishInitialScrollWithoutNativeProgress || canFinishAfterSilentNativeDispatch || numChecks > maxChecks) {
|
|
1682
|
+
finishScrollTo(ctx);
|
|
1683
|
+
} else if ((isNativeInitialPending || shouldRetryUnalignedInitialScroll) && numChecks <= maxChecks) {
|
|
1684
|
+
const targetOffset = (_d = (_c = getInitialScrollWatchdogTargetOffset(state)) != null ? _c : isStillScrollingTo.targetOffset) != null ? _d : state.scrollPending;
|
|
1685
|
+
scrollToFallbackOffset(ctx, targetOffset);
|
|
1686
|
+
scheduleFallbackCheck(silentInitialDispatch ? SILENT_INITIAL_SCROLL_RETRY_DELAY_MS : 100);
|
|
1687
|
+
} else {
|
|
1688
|
+
scheduleFallbackCheck(silentInitialDispatch ? SILENT_INITIAL_SCROLL_RETRY_DELAY_MS : 100);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
checkHasScrolled();
|
|
1693
|
+
}, initialDelay);
|
|
1735
1694
|
}
|
|
1736
1695
|
|
|
1737
|
-
// src/
|
|
1738
|
-
function
|
|
1739
|
-
const state = ctx
|
|
1740
|
-
|
|
1696
|
+
// src/core/doScrollTo.native.ts
|
|
1697
|
+
function doScrollTo(ctx, params) {
|
|
1698
|
+
const state = ctx.state;
|
|
1699
|
+
const { animated, horizontal, isInitialScroll, offset } = params;
|
|
1700
|
+
const isAnimated = !!animated;
|
|
1701
|
+
const { refScroller } = state;
|
|
1702
|
+
const scroller = refScroller.current;
|
|
1703
|
+
if (!scroller) {
|
|
1741
1704
|
return;
|
|
1742
1705
|
}
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
const dataLength = data.length;
|
|
1754
|
-
const threshold = onStartReachedThreshold * scrollLength;
|
|
1755
|
-
const dataChanged = startReachedSnapshotDataChangeEpoch !== dataChangeEpoch;
|
|
1756
|
-
const withinThreshold = threshold > 0 && Math.abs(scroll) <= threshold;
|
|
1757
|
-
const allowReentryOnDataChange = !!isStartReached && withinThreshold && !!dataChanged && !isInMVCPActiveMode(state);
|
|
1758
|
-
if (isStartReached && threshold > 0 && scroll > threshold && startReachedSnapshot && (dataChanged || startReachedSnapshot.contentSize !== totalSize || startReachedSnapshot.dataLength !== dataLength)) {
|
|
1759
|
-
state.isStartReached = false;
|
|
1760
|
-
state.startReachedSnapshot = void 0;
|
|
1761
|
-
state.startReachedSnapshotDataChangeEpoch = void 0;
|
|
1762
|
-
}
|
|
1763
|
-
set$(ctx, "isAtStart", scroll <= EDGE_POSITION_EPSILON);
|
|
1764
|
-
set$(ctx, "isNearStart", scroll <= threshold);
|
|
1765
|
-
const shouldSkipThresholdChecks = hasActiveInitialScroll(state) || !!state.scrollingTo;
|
|
1766
|
-
const shouldDeferDataChangeRefire = isStartReached && withinThreshold && dataChanged && !allowReentryOnDataChange;
|
|
1767
|
-
if (!shouldSkipThresholdChecks && !shouldDeferDataChangeRefire) {
|
|
1768
|
-
state.isStartReached = checkThreshold(
|
|
1769
|
-
scroll,
|
|
1770
|
-
false,
|
|
1771
|
-
threshold,
|
|
1772
|
-
state.isStartReached,
|
|
1773
|
-
allowReentryOnDataChange ? void 0 : startReachedSnapshot,
|
|
1774
|
-
{
|
|
1775
|
-
contentSize: totalSize,
|
|
1776
|
-
dataLength,
|
|
1777
|
-
scrollPosition: scroll
|
|
1778
|
-
},
|
|
1779
|
-
(distance) => {
|
|
1780
|
-
var _a3, _b;
|
|
1781
|
-
return (_b = (_a3 = state.props).onStartReached) == null ? void 0 : _b.call(_a3, { distanceFromStart: distance });
|
|
1782
|
-
},
|
|
1783
|
-
(snapshot) => {
|
|
1784
|
-
state.startReachedSnapshot = snapshot;
|
|
1785
|
-
state.startReachedSnapshotDataChangeEpoch = snapshot ? dataChangeEpoch : void 0;
|
|
1786
|
-
},
|
|
1787
|
-
allowReentryOnDataChange
|
|
1788
|
-
);
|
|
1706
|
+
const isHorizontal = !!horizontal;
|
|
1707
|
+
const contentSize = isHorizontal ? getContentSize(ctx) : void 0;
|
|
1708
|
+
const nativeOffset = toNativeHorizontalOffset(state, offset, contentSize);
|
|
1709
|
+
scroller.scrollTo({
|
|
1710
|
+
animated: isAnimated,
|
|
1711
|
+
x: isHorizontal ? nativeOffset : 0,
|
|
1712
|
+
y: isHorizontal ? 0 : offset
|
|
1713
|
+
});
|
|
1714
|
+
if (isInitialScroll) {
|
|
1715
|
+
initialScrollCompletion.markInitialScrollNativeDispatch(state);
|
|
1789
1716
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
function checkThresholds(ctx) {
|
|
1794
|
-
checkAtBottom(ctx);
|
|
1795
|
-
checkAtTop(ctx);
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
// src/core/recalculateSettledScroll.ts
|
|
1799
|
-
function recalculateSettledScroll(ctx) {
|
|
1800
|
-
var _a3, _b;
|
|
1801
|
-
const state = ctx.state;
|
|
1802
|
-
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1803
|
-
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1717
|
+
if (!isAnimated) {
|
|
1718
|
+
state.scroll = offset;
|
|
1719
|
+
checkFinishedScrollFallback(ctx);
|
|
1804
1720
|
}
|
|
1805
|
-
checkThresholds(ctx);
|
|
1806
1721
|
}
|
|
1807
1722
|
|
|
1808
|
-
// src/core/
|
|
1809
|
-
|
|
1810
|
-
var DEFAULT_EXIT_VELOCITY = 1;
|
|
1811
|
-
var DEFAULT_EXIT_DELAY = 1e3;
|
|
1812
|
-
function scheduleAdaptiveRenderExit(ctx, exitDelay) {
|
|
1813
|
-
const state = ctx.state;
|
|
1814
|
-
const previousTimeout = state.timeoutAdaptiveRender;
|
|
1815
|
-
if (previousTimeout !== void 0) {
|
|
1816
|
-
clearTimeout(previousTimeout);
|
|
1817
|
-
state.timeouts.delete(previousTimeout);
|
|
1818
|
-
state.timeoutAdaptiveRender = void 0;
|
|
1819
|
-
}
|
|
1820
|
-
if (exitDelay <= 0) {
|
|
1821
|
-
setAdaptiveRender(ctx, "normal");
|
|
1822
|
-
} else {
|
|
1823
|
-
const timeout = setTimeout(() => {
|
|
1824
|
-
state.timeouts.delete(timeout);
|
|
1825
|
-
state.timeoutAdaptiveRender = void 0;
|
|
1826
|
-
setAdaptiveRender(ctx, "normal");
|
|
1827
|
-
}, exitDelay);
|
|
1828
|
-
state.timeoutAdaptiveRender = timeout;
|
|
1829
|
-
state.timeouts.add(timeout);
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
function setAdaptiveRender(ctx, mode) {
|
|
1833
|
-
var _a3, _b;
|
|
1834
|
-
const previousMode = peek$(ctx, "adaptiveRender");
|
|
1835
|
-
if (previousMode !== mode) {
|
|
1836
|
-
set$(ctx, "adaptiveRender", mode);
|
|
1837
|
-
(_b = (_a3 = ctx.state.props.adaptiveRender) == null ? void 0 : _a3.onChange) == null ? void 0 : _b.call(_a3, mode);
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
function updateAdaptiveRender(ctx, scrollVelocity) {
|
|
1841
|
-
var _a3, _b, _c;
|
|
1723
|
+
// src/core/doMaintainScrollAtEnd.ts
|
|
1724
|
+
function doMaintainScrollAtEnd(ctx) {
|
|
1842
1725
|
const state = ctx.state;
|
|
1843
|
-
const adaptiveRender = state.props.adaptiveRender;
|
|
1844
|
-
const enterVelocity = (_a3 = adaptiveRender == null ? void 0 : adaptiveRender.enterVelocity) != null ? _a3 : DEFAULT_ENTER_VELOCITY;
|
|
1845
|
-
const exitVelocity = (_b = adaptiveRender == null ? void 0 : adaptiveRender.exitVelocity) != null ? _b : DEFAULT_EXIT_VELOCITY;
|
|
1846
|
-
const exitDelay = (_c = adaptiveRender == null ? void 0 : adaptiveRender.exitDelay) != null ? _c : DEFAULT_EXIT_DELAY;
|
|
1847
|
-
const currentMode = peek$(ctx, "adaptiveRender");
|
|
1848
|
-
const threshold = currentMode === "light" ? exitVelocity : enterVelocity;
|
|
1849
|
-
const nextMode = Math.abs(scrollVelocity) > threshold ? "light" : "normal";
|
|
1850
|
-
const previousMode = state.timeoutAdaptiveRender !== void 0 ? "normal" : currentMode;
|
|
1851
|
-
if (nextMode !== previousMode) {
|
|
1852
|
-
if (nextMode === "light") {
|
|
1853
|
-
setAdaptiveRender(ctx, "light");
|
|
1854
|
-
scheduleAdaptiveRenderExit(ctx, exitDelay);
|
|
1855
|
-
} else if (currentMode === "light") {
|
|
1856
|
-
scheduleAdaptiveRenderExit(ctx, exitDelay);
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
// src/utils/getEffectiveDrawDistance.ts
|
|
1862
|
-
var INITIAL_DRAW_DISTANCE = 100;
|
|
1863
|
-
function getEffectiveDrawDistance(ctx) {
|
|
1864
|
-
var _a3;
|
|
1865
|
-
const drawDistance = ctx.state.props.drawDistance;
|
|
1866
|
-
const initialScroll = ctx.state.initialScroll;
|
|
1867
|
-
const needsFullInitialDrawDistance = initialScroll !== void 0 && ((_a3 = initialScroll.viewPosition) != null ? _a3 : 0) > 0;
|
|
1868
|
-
return peek$(ctx, "readyToRender") || needsFullInitialDrawDistance ? drawDistance : Math.min(drawDistance, INITIAL_DRAW_DISTANCE);
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
|
-
// src/utils/setInitialRenderState.ts
|
|
1872
|
-
function setInitialRenderState(ctx, {
|
|
1873
|
-
didLayout,
|
|
1874
|
-
didInitialScroll
|
|
1875
|
-
}) {
|
|
1876
|
-
const { state } = ctx;
|
|
1877
1726
|
const {
|
|
1878
|
-
|
|
1879
|
-
|
|
1727
|
+
didContainersLayout,
|
|
1728
|
+
pendingNativeMVCPAdjust,
|
|
1729
|
+
refScroller,
|
|
1730
|
+
props: { maintainScrollAtEnd }
|
|
1880
1731
|
} = state;
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1732
|
+
const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
|
|
1733
|
+
const shouldMaintainScrollAtEnd = !!(isWithinMaintainScrollAtEndThreshold && maintainScrollAtEnd && didContainersLayout);
|
|
1734
|
+
if (pendingNativeMVCPAdjust) {
|
|
1735
|
+
state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
|
|
1736
|
+
return false;
|
|
1886
1737
|
}
|
|
1887
|
-
|
|
1888
|
-
if (
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
requestAnimationFrame(() => {
|
|
1893
|
-
var _a3;
|
|
1894
|
-
(_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state);
|
|
1895
|
-
});
|
|
1738
|
+
state.pendingMaintainScrollAtEnd = false;
|
|
1739
|
+
if (shouldMaintainScrollAtEnd) {
|
|
1740
|
+
const contentSize = getContentSize(ctx);
|
|
1741
|
+
if (contentSize < state.scrollLength) {
|
|
1742
|
+
state.scroll = 0;
|
|
1896
1743
|
}
|
|
1897
|
-
if (
|
|
1898
|
-
|
|
1744
|
+
if (!state.maintainingScrollAtEnd) {
|
|
1745
|
+
const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
|
|
1746
|
+
const activeState = maintainScrollAtEnd.animated ? "animated" : "instant";
|
|
1747
|
+
state.maintainingScrollAtEnd = pendingState;
|
|
1748
|
+
requestAnimationFrame(() => {
|
|
1749
|
+
if (peek$(ctx, "isWithinMaintainScrollAtEndThreshold")) {
|
|
1750
|
+
state.maintainingScrollAtEnd = activeState;
|
|
1751
|
+
const scroller = refScroller.current;
|
|
1752
|
+
if (state.props.horizontal && isHorizontalRTL(state)) {
|
|
1753
|
+
const currentContentSize = getContentSize(ctx);
|
|
1754
|
+
const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
|
|
1755
|
+
const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
|
|
1756
|
+
scroller == null ? void 0 : scroller.scrollTo({
|
|
1757
|
+
animated: maintainScrollAtEnd.animated,
|
|
1758
|
+
x: nativeOffset,
|
|
1759
|
+
y: 0
|
|
1760
|
+
});
|
|
1761
|
+
} else {
|
|
1762
|
+
scroller == null ? void 0 : scroller.scrollToEnd({
|
|
1763
|
+
animated: maintainScrollAtEnd.animated
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
setTimeout(
|
|
1767
|
+
() => {
|
|
1768
|
+
if (state.maintainingScrollAtEnd === activeState) {
|
|
1769
|
+
state.maintainingScrollAtEnd = void 0;
|
|
1770
|
+
}
|
|
1771
|
+
},
|
|
1772
|
+
maintainScrollAtEnd.animated ? 500 : 0
|
|
1773
|
+
);
|
|
1774
|
+
} else if (state.maintainingScrollAtEnd === pendingState) {
|
|
1775
|
+
state.maintainingScrollAtEnd = void 0;
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1899
1778
|
}
|
|
1779
|
+
return true;
|
|
1900
1780
|
}
|
|
1781
|
+
return false;
|
|
1901
1782
|
}
|
|
1902
1783
|
|
|
1903
|
-
// src/
|
|
1904
|
-
|
|
1905
|
-
function syncInitialScrollOffset(state, offset) {
|
|
1906
|
-
state.scroll = offset;
|
|
1907
|
-
state.scrollPending = offset;
|
|
1908
|
-
state.scrollPrev = offset;
|
|
1909
|
-
}
|
|
1910
|
-
function clearPreservedInitialScrollTargetTimeout(state) {
|
|
1911
|
-
if (state.timeoutPreservedInitialScrollClear !== void 0) {
|
|
1912
|
-
clearTimeout(state.timeoutPreservedInitialScrollClear);
|
|
1913
|
-
state.timeoutPreservedInitialScrollClear = void 0;
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
function clearPreservedInitialScrollTarget(state) {
|
|
1917
|
-
clearPreservedInitialScrollTargetTimeout(state);
|
|
1918
|
-
state.clearPreservedInitialScrollOnNextFinish = void 0;
|
|
1919
|
-
state.initialScroll = void 0;
|
|
1920
|
-
setInitialScrollSession(state);
|
|
1921
|
-
}
|
|
1922
|
-
function finishInitialScroll(ctx, options) {
|
|
1923
|
-
var _a3, _b, _c;
|
|
1784
|
+
// src/utils/requestAdjust.ts
|
|
1785
|
+
function requestAdjust(ctx, positionDiff, dataChanged) {
|
|
1924
1786
|
const state = ctx.state;
|
|
1925
|
-
if ((
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
if (
|
|
1943
|
-
state.
|
|
1944
|
-
|
|
1945
|
-
state.
|
|
1946
|
-
|
|
1947
|
-
|
|
1787
|
+
if (Math.abs(positionDiff) > 0.1) {
|
|
1788
|
+
const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
|
|
1789
|
+
const doit = () => {
|
|
1790
|
+
if (needsScrollWorkaround) {
|
|
1791
|
+
doScrollTo(ctx, { horizontal: state.props.horizontal, offset: state.scroll });
|
|
1792
|
+
} else {
|
|
1793
|
+
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1794
|
+
if (state.adjustingFromInitialMount) {
|
|
1795
|
+
state.adjustingFromInitialMount--;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
state.scroll += positionDiff;
|
|
1800
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
1801
|
+
const readyToRender = peek$(ctx, "readyToRender");
|
|
1802
|
+
if (readyToRender) {
|
|
1803
|
+
doit();
|
|
1804
|
+
if (Platform.OS !== "web") {
|
|
1805
|
+
const threshold = state.scroll - positionDiff / 2;
|
|
1806
|
+
if (!state.ignoreScrollFromMVCP) {
|
|
1807
|
+
state.ignoreScrollFromMVCP = {};
|
|
1808
|
+
}
|
|
1809
|
+
if (positionDiff > 0) {
|
|
1810
|
+
state.ignoreScrollFromMVCP.lt = threshold;
|
|
1811
|
+
} else {
|
|
1812
|
+
state.ignoreScrollFromMVCP.gt = threshold;
|
|
1813
|
+
}
|
|
1814
|
+
if (state.ignoreScrollFromMVCPTimeout) {
|
|
1815
|
+
clearTimeout(state.ignoreScrollFromMVCPTimeout);
|
|
1816
|
+
}
|
|
1817
|
+
const delay = needsScrollWorkaround ? 250 : 100;
|
|
1818
|
+
state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
|
|
1819
|
+
var _a3;
|
|
1820
|
+
state.ignoreScrollFromMVCP = void 0;
|
|
1821
|
+
const shouldForceUpdate = state.ignoreScrollFromMVCPIgnored && state.scrollProcessingEnabled !== false;
|
|
1822
|
+
if (shouldForceUpdate) {
|
|
1823
|
+
state.ignoreScrollFromMVCPIgnored = false;
|
|
1824
|
+
state.scrollPending = state.scroll;
|
|
1825
|
+
(_a3 = state.reprocessCurrentScroll) == null ? void 0 : _a3.call(state);
|
|
1948
1826
|
}
|
|
1949
|
-
|
|
1950
|
-
}, PRESERVED_INITIAL_SCROLL_FALLBACK_CLEAR_DELAY_MS);
|
|
1827
|
+
}, delay);
|
|
1951
1828
|
}
|
|
1952
1829
|
} else {
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
if (options == null ? void 0 : options.recalculateItems) {
|
|
1956
|
-
recalculateSettledScroll(ctx);
|
|
1957
|
-
}
|
|
1958
|
-
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
1959
|
-
if (shouldReleaseDeferredPublicOnScroll) {
|
|
1960
|
-
releaseDeferredPublicOnScroll(ctx, finalScrollOffset);
|
|
1830
|
+
state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
|
|
1831
|
+
requestAnimationFrame(doit);
|
|
1961
1832
|
}
|
|
1962
|
-
(_e = options == null ? void 0 : options.onFinished) == null ? void 0 : _e.call(options);
|
|
1963
|
-
};
|
|
1964
|
-
if (options == null ? void 0 : options.waitForCompletionFrame) {
|
|
1965
|
-
requestAnimationFrame(complete);
|
|
1966
|
-
return;
|
|
1967
1833
|
}
|
|
1968
|
-
complete();
|
|
1969
1834
|
}
|
|
1970
1835
|
|
|
1971
|
-
// src/core/
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
finishInitialScroll(ctx, {
|
|
1991
|
-
onFinished: () => {
|
|
1992
|
-
resolvePendingScroll == null ? void 0 : resolvePendingScroll();
|
|
1993
|
-
},
|
|
1994
|
-
preserveTarget: isOffsetSession && state.props.data.length === 0 || shouldPreserveResizeTarget,
|
|
1995
|
-
recalculateItems: true,
|
|
1996
|
-
schedulePreservedTargetClear: shouldPreserveResizeTarget,
|
|
1997
|
-
syncObservedOffset: isOffsetSession,
|
|
1998
|
-
waitForCompletionFrame: !!scrollingTo.waitForInitialScrollCompletionFrame
|
|
1999
|
-
});
|
|
2000
|
-
return;
|
|
2001
|
-
}
|
|
2002
|
-
recalculateSettledScroll(ctx);
|
|
2003
|
-
resolvePendingScroll == null ? void 0 : resolvePendingScroll();
|
|
1836
|
+
// src/core/mvcp.ts
|
|
1837
|
+
var MVCP_POSITION_EPSILON = 0.1;
|
|
1838
|
+
var MVCP_ANCHOR_LOCK_TTL_MS = 300;
|
|
1839
|
+
var MVCP_ANCHOR_LOCK_QUIET_PASSES_TO_RELEASE = 2;
|
|
1840
|
+
var NATIVE_END_CLAMP_EPSILON = 1;
|
|
1841
|
+
function resolveAnchorLock(state, enableMVCPAnchorLock, mvcpData, now) {
|
|
1842
|
+
if (!enableMVCPAnchorLock) {
|
|
1843
|
+
state.mvcpAnchorLock = void 0;
|
|
1844
|
+
return void 0;
|
|
1845
|
+
}
|
|
1846
|
+
const lock = state.mvcpAnchorLock;
|
|
1847
|
+
if (!lock) {
|
|
1848
|
+
return void 0;
|
|
1849
|
+
}
|
|
1850
|
+
const isExpired = now > lock.expiresAt;
|
|
1851
|
+
const isMissing = state.indexByKey.get(lock.id) === void 0;
|
|
1852
|
+
if (isExpired || isMissing || !mvcpData) {
|
|
1853
|
+
state.mvcpAnchorLock = void 0;
|
|
1854
|
+
return void 0;
|
|
2004
1855
|
}
|
|
1856
|
+
return lock;
|
|
2005
1857
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
var SILENT_INITIAL_SCROLL_TARGET_EPSILON = 1;
|
|
2013
|
-
function checkFinishedScroll(ctx, options) {
|
|
2014
|
-
const scrollingTo = ctx.state.scrollingTo;
|
|
2015
|
-
if (options == null ? void 0 : options.onlyIfAligned) {
|
|
2016
|
-
if (!(scrollingTo == null ? void 0 : scrollingTo.isInitialScroll) || scrollingTo.animated) {
|
|
1858
|
+
function updateAnchorLock(state, params) {
|
|
1859
|
+
if (Platform.OS === "web") {
|
|
1860
|
+
const { anchorId, anchorPosition, dataChanged, now, positionDiff } = params;
|
|
1861
|
+
const enableMVCPAnchorLock = !!dataChanged || !!state.mvcpAnchorLock;
|
|
1862
|
+
const mvcpData = state.props.maintainVisibleContentPosition.data;
|
|
1863
|
+
if (!enableMVCPAnchorLock || !mvcpData || state.scrollingTo || !anchorId || anchorPosition === void 0) {
|
|
2017
1864
|
return;
|
|
2018
1865
|
}
|
|
2019
|
-
|
|
1866
|
+
const existingLock = state.mvcpAnchorLock;
|
|
1867
|
+
const quietPasses = !dataChanged && Math.abs(positionDiff) <= MVCP_POSITION_EPSILON && (existingLock == null ? void 0 : existingLock.id) === anchorId ? existingLock.quietPasses + 1 : 0;
|
|
1868
|
+
if (!dataChanged && quietPasses >= MVCP_ANCHOR_LOCK_QUIET_PASSES_TO_RELEASE) {
|
|
1869
|
+
state.mvcpAnchorLock = void 0;
|
|
2020
1870
|
return;
|
|
2021
1871
|
}
|
|
1872
|
+
state.mvcpAnchorLock = {
|
|
1873
|
+
expiresAt: now + MVCP_ANCHOR_LOCK_TTL_MS,
|
|
1874
|
+
id: anchorId,
|
|
1875
|
+
position: anchorPosition,
|
|
1876
|
+
quietPasses
|
|
1877
|
+
};
|
|
2022
1878
|
}
|
|
2023
|
-
ctx.state.animFrameCheckFinishedScroll = requestAnimationFrame(() => checkFinishedScrollFrame(ctx));
|
|
2024
|
-
}
|
|
2025
|
-
function hasScrollCompletionOwnership(state, options) {
|
|
2026
|
-
const { clampedTargetOffset, scrollingTo } = options;
|
|
2027
|
-
return !scrollingTo.isInitialScroll || state.hasScrolled || clampedTargetOffset <= INITIAL_SCROLL_COMPLETION_TARGET_EPSILON;
|
|
2028
|
-
}
|
|
2029
|
-
function isSilentInitialDispatch(state, scrollingTo) {
|
|
2030
|
-
return !!(scrollingTo == null ? void 0 : scrollingTo.isInitialScroll) && initialScrollCompletion.didDispatchNativeScroll(state) && !state.hasScrolled;
|
|
2031
|
-
}
|
|
2032
|
-
function getInitialScrollWatchdogTargetOffset(state) {
|
|
2033
|
-
var _a3;
|
|
2034
|
-
return (_a3 = initialScrollWatchdog.get(state)) == null ? void 0 : _a3.targetOffset;
|
|
2035
|
-
}
|
|
2036
|
-
function isNativeInitialNonZeroTarget(state) {
|
|
2037
|
-
const targetOffset = getInitialScrollWatchdogTargetOffset(state);
|
|
2038
|
-
return !state.didFinishInitialScroll && initialScrollWatchdog.hasNonZeroTargetOffset(targetOffset);
|
|
2039
1879
|
}
|
|
2040
|
-
function
|
|
2041
|
-
|
|
2042
|
-
if (!scrollingTo.isInitialScroll || scrollingTo.animated || !state.didContainersLayout) {
|
|
2043
|
-
return false;
|
|
2044
|
-
}
|
|
2045
|
-
if (((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "bootstrap") {
|
|
2046
|
-
return false;
|
|
2047
|
-
}
|
|
2048
|
-
const targetOffset = (_b = scrollingTo.targetOffset) != null ? _b : scrollingTo.offset;
|
|
2049
|
-
if (initialScrollWatchdog.hasNonZeroTargetOffset(targetOffset) && initialScrollCompletion.didDispatchNativeScroll(state) && !state.hasScrolled) {
|
|
2050
|
-
return false;
|
|
2051
|
-
}
|
|
2052
|
-
if (initialScrollWatchdog.isAtZeroTargetOffset(targetOffset) || Math.abs(state.scroll - targetOffset) > 1 || Math.abs(state.scrollPending - targetOffset) > 1) {
|
|
1880
|
+
function shouldQueueNativeMVCPAdjust(dataChanged, state, positionDiff, prevTotalSize, prevScroll, scrollTarget) {
|
|
1881
|
+
if (!dataChanged || Platform.OS === "web" || !state.props.maintainVisibleContentPosition.data || scrollTarget !== void 0 || positionDiff >= -MVCP_POSITION_EPSILON) {
|
|
2053
1882
|
return false;
|
|
2054
1883
|
}
|
|
2055
|
-
|
|
1884
|
+
const distanceFromEnd = prevTotalSize - prevScroll - state.scrollLength;
|
|
1885
|
+
return distanceFromEnd < Math.abs(positionDiff) - MVCP_POSITION_EPSILON;
|
|
2056
1886
|
}
|
|
2057
|
-
function
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
return !!((_a3 = state.scrollingTo) == null ? void 0 : _a3.isInitialScroll) && state.props.data.length > 0 && getContentSize(ctx) <= state.scrollLength && state.scrollPending <= INITIAL_SCROLL_ZERO_TARGET_EPSILON;
|
|
2061
|
-
}
|
|
2062
|
-
function isEndAlignedLastItemTarget(ctx, scrollingTo) {
|
|
2063
|
-
return scrollingTo.index === ctx.state.props.data.length - 1 && scrollingTo.viewPosition === 1;
|
|
2064
|
-
}
|
|
2065
|
-
function getCurrentTargetOffset(ctx, scrollingTo) {
|
|
2066
|
-
var _a3;
|
|
2067
|
-
const index = scrollingTo.index;
|
|
2068
|
-
const shouldRecomputeEndTarget = isEndAlignedLastItemTarget(ctx, scrollingTo);
|
|
2069
|
-
const requestedTargetOffset = shouldRecomputeEndTarget && index !== void 0 ? calculateOffsetWithOffsetPosition(ctx, calculateOffsetForIndex(ctx, index), scrollingTo) : (_a3 = scrollingTo.targetOffset) != null ? _a3 : clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0), scrollingTo);
|
|
2070
|
-
return clampScrollOffset(ctx, requestedTargetOffset, scrollingTo);
|
|
2071
|
-
}
|
|
2072
|
-
function getResolvedScrollCompletionState(ctx, scrollingTo) {
|
|
2073
|
-
const { state } = ctx;
|
|
2074
|
-
const scroll = state.scrollPending;
|
|
2075
|
-
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
2076
|
-
const clampedTargetOffset = getCurrentTargetOffset(ctx, scrollingTo);
|
|
2077
|
-
const maxOffset = clampScrollOffset(ctx, scroll, scrollingTo);
|
|
2078
|
-
const diff1 = Math.abs(scroll - clampedTargetOffset);
|
|
2079
|
-
const adjustedTargetOffset = clampedTargetOffset + adjust;
|
|
2080
|
-
const diff2 = Math.abs(scroll - adjustedTargetOffset);
|
|
2081
|
-
const canUseAdjustedCompletion = !scrollingTo.animated || Platform.OS === "ios";
|
|
2082
|
-
return {
|
|
2083
|
-
clampedTargetOffset,
|
|
2084
|
-
isAtResolvedTarget: Math.abs(scroll - maxOffset) < 1 && (diff1 < 1 || canUseAdjustedCompletion && diff2 < 1)
|
|
2085
|
-
};
|
|
2086
|
-
}
|
|
2087
|
-
function checkFinishedScrollFrame(ctx) {
|
|
2088
|
-
const scrollingTo = ctx.state.scrollingTo;
|
|
2089
|
-
if (!scrollingTo) {
|
|
2090
|
-
return;
|
|
1887
|
+
function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
|
|
1888
|
+
if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
|
|
1889
|
+
return 0;
|
|
2091
1890
|
}
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
finishScrollTo(ctx);
|
|
1891
|
+
const maxScroll = Math.max(0, totalSize - state.scrollLength);
|
|
1892
|
+
const clampDelta = maxScroll - state.scroll;
|
|
1893
|
+
if (unresolvedAmount < 0) {
|
|
1894
|
+
return Math.max(unresolvedAmount, Math.min(0, clampDelta));
|
|
1895
|
+
}
|
|
1896
|
+
if (unresolvedAmount > 0) {
|
|
1897
|
+
return Math.min(unresolvedAmount, Math.max(0, clampDelta));
|
|
2100
1898
|
}
|
|
1899
|
+
return 0;
|
|
2101
1900
|
}
|
|
2102
|
-
function
|
|
2103
|
-
|
|
2104
|
-
(_a3 = ctx.state.refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
2105
|
-
animated: false,
|
|
2106
|
-
x: ctx.state.props.horizontal ? offset : 0,
|
|
2107
|
-
y: ctx.state.props.horizontal ? 0 : offset
|
|
2108
|
-
});
|
|
1901
|
+
function getProgressTowardAmount(targetDelta, nativeDelta) {
|
|
1902
|
+
return targetDelta < 0 ? -nativeDelta : nativeDelta;
|
|
2109
1903
|
}
|
|
2110
|
-
function
|
|
1904
|
+
function settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta) {
|
|
2111
1905
|
const state = ctx.state;
|
|
2112
|
-
|
|
2113
|
-
const
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
const initialDelay = shouldFinishInitialZeroTarget || canFinishInitialWithoutNativeProgress ? 0 : silentInitialDispatch ? SILENT_INITIAL_SCROLL_RETRY_DELAY_MS : slowTimeout ? 500 : 100;
|
|
2118
|
-
state.timeoutCheckFinishedScrollFallback = setTimeout(() => {
|
|
2119
|
-
let numChecks = 0;
|
|
2120
|
-
const scheduleFallbackCheck = (delay) => {
|
|
2121
|
-
state.timeoutCheckFinishedScrollFallback = setTimeout(checkHasScrolled, delay);
|
|
2122
|
-
};
|
|
2123
|
-
const checkHasScrolled = () => {
|
|
2124
|
-
var _a3, _b, _c, _d;
|
|
2125
|
-
state.timeoutCheckFinishedScrollFallback = void 0;
|
|
2126
|
-
const isStillScrollingTo = state.scrollingTo;
|
|
2127
|
-
if (isStillScrollingTo) {
|
|
2128
|
-
numChecks++;
|
|
2129
|
-
const isNativeInitialPending = isNativeInitialNonZeroTarget(state) && !state.hasScrolled;
|
|
2130
|
-
const maxChecks = silentInitialDispatch ? 5 : isNativeInitialPending ? INITIAL_SCROLL_MAX_FALLBACK_CHECKS : 5;
|
|
2131
|
-
const shouldFinishZeroTarget = shouldFinishInitialZeroTargetScroll(ctx);
|
|
2132
|
-
const canFinishInitialScrollWithoutNativeProgress = shouldFinishInitialScrollWithoutNativeProgress(
|
|
2133
|
-
state,
|
|
2134
|
-
isStillScrollingTo
|
|
2135
|
-
);
|
|
2136
|
-
const completionState = getResolvedScrollCompletionState(ctx, isStillScrollingTo);
|
|
2137
|
-
const canFinishAfterSilentNativeDispatch = Platform.OS === "android" && silentInitialDispatch && completionState.isAtResolvedTarget && numChecks >= 1;
|
|
2138
|
-
const shouldRetrySilentInitialNativeScroll = Platform.OS === "android" && canFinishAfterSilentNativeDispatch && !initialScrollCompletion.didRetrySilentInitialScroll(state);
|
|
2139
|
-
const shouldFinishAfterObservedScroll = state.hasScrolled && (!isStillScrollingTo.isInitialScroll || completionState.isAtResolvedTarget);
|
|
2140
|
-
const shouldRetryUnalignedInitialScroll = isStillScrollingTo.isInitialScroll && !completionState.isAtResolvedTarget && numChecks <= maxChecks;
|
|
2141
|
-
const shouldRetryUnalignedEndScroll = Platform.OS === "ios" && !isStillScrollingTo.isInitialScroll && isEndAlignedLastItemTarget(ctx, isStillScrollingTo) && !completionState.isAtResolvedTarget && numChecks <= maxChecks;
|
|
2142
|
-
if (shouldRetrySilentInitialNativeScroll) {
|
|
2143
|
-
const targetOffset = (_b = (_a3 = getInitialScrollWatchdogTargetOffset(state)) != null ? _a3 : isStillScrollingTo.targetOffset) != null ? _b : 0;
|
|
2144
|
-
const jiggleOffset = targetOffset >= SILENT_INITIAL_SCROLL_TARGET_EPSILON ? targetOffset - SILENT_INITIAL_SCROLL_TARGET_EPSILON : targetOffset + SILENT_INITIAL_SCROLL_TARGET_EPSILON;
|
|
2145
|
-
initialScrollCompletion.markSilentInitialScrollRetry(state);
|
|
2146
|
-
scrollToFallbackOffset(ctx, jiggleOffset);
|
|
2147
|
-
requestAnimationFrame(() => {
|
|
2148
|
-
scrollToFallbackOffset(ctx, targetOffset);
|
|
2149
|
-
});
|
|
2150
|
-
scheduleFallbackCheck(SILENT_INITIAL_SCROLL_RETRY_DELAY_MS);
|
|
2151
|
-
} else if (shouldRetryUnalignedEndScroll) {
|
|
2152
|
-
scrollToFallbackOffset(ctx, completionState.clampedTargetOffset);
|
|
2153
|
-
scheduleFallbackCheck(100);
|
|
2154
|
-
} else if (shouldFinishZeroTarget || shouldFinishAfterObservedScroll || canFinishInitialScrollWithoutNativeProgress || canFinishAfterSilentNativeDispatch || numChecks > maxChecks) {
|
|
2155
|
-
finishScrollTo(ctx);
|
|
2156
|
-
} else if ((isNativeInitialPending || shouldRetryUnalignedInitialScroll) && numChecks <= maxChecks) {
|
|
2157
|
-
const targetOffset = (_d = (_c = getInitialScrollWatchdogTargetOffset(state)) != null ? _c : isStillScrollingTo.targetOffset) != null ? _d : state.scrollPending;
|
|
2158
|
-
scrollToFallbackOffset(ctx, targetOffset);
|
|
2159
|
-
scheduleFallbackCheck(silentInitialDispatch ? SILENT_INITIAL_SCROLL_RETRY_DELAY_MS : 100);
|
|
2160
|
-
} else {
|
|
2161
|
-
scheduleFallbackCheck(silentInitialDispatch ? SILENT_INITIAL_SCROLL_RETRY_DELAY_MS : 100);
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
};
|
|
2165
|
-
checkHasScrolled();
|
|
2166
|
-
}, initialDelay);
|
|
1906
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
1907
|
+
const remaining = remainingAfterManual - nativeDelta;
|
|
1908
|
+
if (Math.abs(remaining) > MVCP_POSITION_EPSILON) {
|
|
1909
|
+
requestAdjust(ctx, remaining, true);
|
|
1910
|
+
}
|
|
2167
1911
|
}
|
|
2168
|
-
|
|
2169
|
-
// src/core/doScrollTo.native.ts
|
|
2170
|
-
function doScrollTo(ctx, params) {
|
|
1912
|
+
function maybeApplyPredictedNativeMVCPAdjust(ctx) {
|
|
2171
1913
|
const state = ctx.state;
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2174
|
-
const { refScroller } = state;
|
|
2175
|
-
const scroller = refScroller.current;
|
|
2176
|
-
if (!scroller) {
|
|
1914
|
+
const pending = state.pendingNativeMVCPAdjust;
|
|
1915
|
+
if (!pending || Math.abs(pending.manualApplied) > MVCP_POSITION_EPSILON) {
|
|
2177
1916
|
return;
|
|
2178
1917
|
}
|
|
2179
|
-
const
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
animated: isAnimated,
|
|
2184
|
-
x: isHorizontal ? nativeOffset : 0,
|
|
2185
|
-
y: isHorizontal ? 0 : offset
|
|
2186
|
-
});
|
|
2187
|
-
if (isInitialScroll) {
|
|
2188
|
-
initialScrollCompletion.markInitialScrollNativeDispatch(state);
|
|
1918
|
+
const totalSize = getContentSize(ctx);
|
|
1919
|
+
const predictedNativeClamp = getPredictedNativeClamp(state, pending.amount, totalSize);
|
|
1920
|
+
if (Math.abs(predictedNativeClamp) <= MVCP_POSITION_EPSILON) {
|
|
1921
|
+
return;
|
|
2189
1922
|
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
1923
|
+
const manualDesired = pending.amount - predictedNativeClamp;
|
|
1924
|
+
if (Math.abs(manualDesired) <= MVCP_POSITION_EPSILON) {
|
|
1925
|
+
return;
|
|
2193
1926
|
}
|
|
1927
|
+
pending.manualApplied = manualDesired;
|
|
1928
|
+
requestAdjust(ctx, manualDesired, true);
|
|
1929
|
+
pending.furthestProgressTowardAmount = 0;
|
|
2194
1930
|
}
|
|
2195
|
-
|
|
2196
|
-
// src/utils/requestAdjust.ts
|
|
2197
|
-
function requestAdjust(ctx, positionDiff, dataChanged) {
|
|
1931
|
+
function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
|
|
2198
1932
|
const state = ctx.state;
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
if (needsScrollWorkaround) {
|
|
2203
|
-
doScrollTo(ctx, { horizontal: state.props.horizontal, offset: state.scroll });
|
|
2204
|
-
} else {
|
|
2205
|
-
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
2206
|
-
if (state.adjustingFromInitialMount) {
|
|
2207
|
-
state.adjustingFromInitialMount--;
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
};
|
|
2211
|
-
state.scroll += positionDiff;
|
|
2212
|
-
state.scrollForNextCalculateItemsInView = void 0;
|
|
2213
|
-
const readyToRender = peek$(ctx, "readyToRender");
|
|
2214
|
-
if (readyToRender) {
|
|
2215
|
-
doit();
|
|
2216
|
-
if (Platform.OS !== "web") {
|
|
2217
|
-
const threshold = state.scroll - positionDiff / 2;
|
|
2218
|
-
if (!state.ignoreScrollFromMVCP) {
|
|
2219
|
-
state.ignoreScrollFromMVCP = {};
|
|
2220
|
-
}
|
|
2221
|
-
if (positionDiff > 0) {
|
|
2222
|
-
state.ignoreScrollFromMVCP.lt = threshold;
|
|
2223
|
-
} else {
|
|
2224
|
-
state.ignoreScrollFromMVCP.gt = threshold;
|
|
2225
|
-
}
|
|
2226
|
-
if (state.ignoreScrollFromMVCPTimeout) {
|
|
2227
|
-
clearTimeout(state.ignoreScrollFromMVCPTimeout);
|
|
2228
|
-
}
|
|
2229
|
-
const delay = needsScrollWorkaround ? 250 : 100;
|
|
2230
|
-
state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
|
|
2231
|
-
var _a3;
|
|
2232
|
-
state.ignoreScrollFromMVCP = void 0;
|
|
2233
|
-
const shouldForceUpdate = state.ignoreScrollFromMVCPIgnored && state.scrollProcessingEnabled !== false;
|
|
2234
|
-
if (shouldForceUpdate) {
|
|
2235
|
-
state.ignoreScrollFromMVCPIgnored = false;
|
|
2236
|
-
state.scrollPending = state.scroll;
|
|
2237
|
-
(_a3 = state.reprocessCurrentScroll) == null ? void 0 : _a3.call(state);
|
|
2238
|
-
}
|
|
2239
|
-
}, delay);
|
|
2240
|
-
}
|
|
2241
|
-
} else {
|
|
2242
|
-
state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
|
|
2243
|
-
requestAnimationFrame(doit);
|
|
2244
|
-
}
|
|
1933
|
+
const pending = state.pendingNativeMVCPAdjust;
|
|
1934
|
+
if (!pending) {
|
|
1935
|
+
return false;
|
|
2245
1936
|
}
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
set$(ctx, signalName, size);
|
|
2254
|
-
updateContentMetricsState(ctx);
|
|
1937
|
+
const remainingAfterManual = pending.amount - pending.manualApplied;
|
|
1938
|
+
const nativeDelta = newScroll - (pending.startScroll + pending.manualApplied);
|
|
1939
|
+
const isWrongDirection = remainingAfterManual < 0 && nativeDelta > MVCP_POSITION_EPSILON || remainingAfterManual > 0 && nativeDelta < -MVCP_POSITION_EPSILON;
|
|
1940
|
+
const progressTowardAmount = getProgressTowardAmount(remainingAfterManual, nativeDelta);
|
|
1941
|
+
if (Math.abs(remainingAfterManual) <= MVCP_POSITION_EPSILON) {
|
|
1942
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
1943
|
+
return true;
|
|
2255
1944
|
}
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
const { didContainersLayout, didFinishInitialScroll, props, scroll, scrollingTo } = ctx.state;
|
|
2260
|
-
const sizeDiff = nextHeaderSize - previousHeaderSize;
|
|
2261
|
-
const leadingPadding = props.horizontal ? props.stylePaddingLeft : props.stylePaddingTop;
|
|
2262
|
-
const previousHeaderEnd = (leadingPadding || 0) + previousHeaderSize;
|
|
2263
|
-
return Platform.OS === "web" && props.maintainVisibleContentPosition.size && didContainersLayout && didFinishInitialScroll && !scrollingTo && scroll >= previousHeaderEnd - SCROLL_ADJUST_EPSILON && Math.abs(sizeDiff) > SCROLL_ADJUST_EPSILON;
|
|
2264
|
-
}
|
|
2265
|
-
function setHeaderSize(ctx, size) {
|
|
2266
|
-
const { state } = ctx;
|
|
2267
|
-
const previousHeaderSize = peek$(ctx, "headerSize") || 0;
|
|
2268
|
-
const didChange = previousHeaderSize !== size;
|
|
2269
|
-
const hasMeasuredOrEstimatedHeaderBaseline = state.didMeasureHeader || previousHeaderSize > SCROLL_ADJUST_EPSILON;
|
|
2270
|
-
if (didChange) {
|
|
2271
|
-
set$(ctx, "headerSize", size);
|
|
2272
|
-
updateContentMetricsState(ctx);
|
|
2273
|
-
if (hasMeasuredOrEstimatedHeaderBaseline && shouldAdjustForHeaderSizeChange(ctx, previousHeaderSize, size)) {
|
|
2274
|
-
requestAdjust(ctx, size - previousHeaderSize);
|
|
2275
|
-
}
|
|
1945
|
+
if (isWrongDirection) {
|
|
1946
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
1947
|
+
return false;
|
|
2276
1948
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
return setContentLengthSignal(ctx, "footerSize", size);
|
|
2281
|
-
}
|
|
2282
|
-
function areInsetsEqual(left, right) {
|
|
2283
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
2284
|
-
return ((_a3 = left == null ? void 0 : left.top) != null ? _a3 : 0) === ((_b = right == null ? void 0 : right.top) != null ? _b : 0) && ((_c = left == null ? void 0 : left.bottom) != null ? _c : 0) === ((_d = right == null ? void 0 : right.bottom) != null ? _d : 0) && ((_e = left == null ? void 0 : left.left) != null ? _e : 0) === ((_f = right == null ? void 0 : right.left) != null ? _f : 0) && ((_g = left == null ? void 0 : left.right) != null ? _g : 0) === ((_h = right == null ? void 0 : right.right) != null ? _h : 0);
|
|
2285
|
-
}
|
|
2286
|
-
function setContentInsetOverride(ctx, inset) {
|
|
2287
|
-
const { state } = ctx;
|
|
2288
|
-
const previousInset = state.contentInsetOverride;
|
|
2289
|
-
const nextInset = inset != null ? inset : void 0;
|
|
2290
|
-
const didChange = !areInsetsEqual(previousInset, nextInset);
|
|
2291
|
-
state.contentInsetOverride = nextInset;
|
|
2292
|
-
if (didChange) {
|
|
2293
|
-
updateContentMetricsState(ctx);
|
|
1949
|
+
if (progressTowardAmount + MVCP_POSITION_EPSILON >= Math.abs(remainingAfterManual)) {
|
|
1950
|
+
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
|
|
1951
|
+
return true;
|
|
2294
1952
|
}
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
);
|
|
1953
|
+
const expectedNativeClampScroll = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
1954
|
+
const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
|
|
1955
|
+
const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
|
|
1956
|
+
if (isAtExpectedNativeClamp) {
|
|
1957
|
+
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
|
|
1958
|
+
return true;
|
|
1959
|
+
}
|
|
1960
|
+
if (state.pendingMaintainScrollAtEnd && peek$(ctx, "isWithinMaintainScrollAtEndThreshold") && progressTowardAmount > MVCP_POSITION_EPSILON) {
|
|
1961
|
+
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
|
|
1962
|
+
return true;
|
|
1963
|
+
}
|
|
1964
|
+
if (progressTowardAmount > pending.furthestProgressTowardAmount + MVCP_POSITION_EPSILON) {
|
|
1965
|
+
pending.furthestProgressTowardAmount = progressTowardAmount;
|
|
1966
|
+
return false;
|
|
1967
|
+
}
|
|
1968
|
+
if (pending.furthestProgressTowardAmount > MVCP_POSITION_EPSILON && progressTowardAmount < pending.furthestProgressTowardAmount - MVCP_POSITION_EPSILON) {
|
|
1969
|
+
state.pendingNativeMVCPAdjust = void 0;
|
|
1970
|
+
return false;
|
|
1971
|
+
}
|
|
1972
|
+
return false;
|
|
2316
1973
|
}
|
|
2317
|
-
|
|
2318
|
-
const
|
|
2319
|
-
const
|
|
2320
|
-
const {
|
|
2321
|
-
|
|
2322
|
-
};
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
const
|
|
2327
|
-
if (
|
|
2328
|
-
|
|
1974
|
+
function prepareMVCP(ctx, dataChanged) {
|
|
1975
|
+
const state = ctx.state;
|
|
1976
|
+
const { idsInView, positions, props } = state;
|
|
1977
|
+
const {
|
|
1978
|
+
maintainVisibleContentPosition: { data: mvcpData, size: mvcpScroll, shouldRestorePosition }
|
|
1979
|
+
} = props;
|
|
1980
|
+
const isWeb = Platform.OS === "web";
|
|
1981
|
+
const now = Date.now();
|
|
1982
|
+
const enableMVCPAnchorLock = isWeb && (!!dataChanged || !!state.mvcpAnchorLock);
|
|
1983
|
+
const scrollingTo = state.scrollingTo;
|
|
1984
|
+
if (isWeb && dataChanged && state.pendingScrollToEnd && scrollingTo === void 0) {
|
|
1985
|
+
state.mvcpAnchorLock = void 0;
|
|
1986
|
+
return void 0;
|
|
2329
1987
|
}
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
);
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
ListFooterComponentStyle,
|
|
2353
|
-
ListEmptyComponent,
|
|
2354
|
-
getRenderedItem: getRenderedItem2,
|
|
2355
|
-
updateItemSize: updateItemSize2,
|
|
2356
|
-
refScrollView,
|
|
2357
|
-
renderScrollComponent,
|
|
2358
|
-
onLayoutFooter,
|
|
2359
|
-
scrollAdjustHandler,
|
|
2360
|
-
snapToIndices,
|
|
2361
|
-
stickyHeaderConfig,
|
|
2362
|
-
stickyHeaderIndices,
|
|
2363
|
-
useWindowScroll = false,
|
|
2364
|
-
...rest
|
|
2365
|
-
}) {
|
|
2366
|
-
const ctx = useStateContext();
|
|
2367
|
-
const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
|
|
2368
|
-
const [otherAxisSize = 0] = useArr$(["otherAxisSize"]);
|
|
2369
|
-
const shouldRenderAlignItemsAtEndSpacer = ctx.state.props.alignItemsAtEndPaddingEnabled;
|
|
2370
|
-
const autoOtherAxisStyle = getAutoOtherAxisStyle({
|
|
2371
|
-
horizontal,
|
|
2372
|
-
needsOtherAxisSize: ctx.state.needsOtherAxisSize,
|
|
2373
|
-
otherAxisSize
|
|
2374
|
-
});
|
|
2375
|
-
const CustomScrollComponent = useStableRenderComponent(
|
|
2376
|
-
renderScrollComponent,
|
|
2377
|
-
(props, ref) => ({ ...props, ref })
|
|
2378
|
-
);
|
|
2379
|
-
const ScrollComponent = renderScrollComponent ? CustomScrollComponent : ListComponentScrollView;
|
|
2380
|
-
const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
|
|
2381
|
-
const updateFooterSize = React2.useCallback(
|
|
2382
|
-
(size, afterSizeUpdate) => {
|
|
2383
|
-
var _a3;
|
|
2384
|
-
const didFooterSizeChange = setFooterSize(ctx, size);
|
|
2385
|
-
afterSizeUpdate == null ? void 0 : afterSizeUpdate();
|
|
2386
|
-
if (didFooterSizeChange && ((_a3 = ctx.state.props.maintainScrollAtEnd) == null ? void 0 : _a3.onFooterLayout)) {
|
|
2387
|
-
doMaintainScrollAtEnd(ctx);
|
|
1988
|
+
const anchorLock = isWeb ? resolveAnchorLock(state, enableMVCPAnchorLock, mvcpData, now) : void 0;
|
|
1989
|
+
let prevPosition;
|
|
1990
|
+
let targetId;
|
|
1991
|
+
const idsInViewWithPositions = [];
|
|
1992
|
+
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1993
|
+
const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
|
|
1994
|
+
const isEndAnchoredScrollTarget = scrollTarget !== void 0 && state.props.data.length > 0 && scrollTarget >= state.props.data.length - 1 && (scrollingToViewPosition != null ? scrollingToViewPosition : 0) > 0;
|
|
1995
|
+
const shouldMVCP = dataChanged ? mvcpData : mvcpScroll;
|
|
1996
|
+
const indexByKey = state.indexByKey;
|
|
1997
|
+
const prevScroll = state.scroll;
|
|
1998
|
+
const prevTotalSize = getContentSize(ctx);
|
|
1999
|
+
if (shouldMVCP) {
|
|
2000
|
+
if (!isWeb && state.pendingNativeMVCPAdjust && scrollTarget === void 0) {
|
|
2001
|
+
maybeApplyPredictedNativeMVCPAdjust(ctx);
|
|
2002
|
+
return void 0;
|
|
2003
|
+
}
|
|
2004
|
+
if (anchorLock && scrollTarget === void 0) {
|
|
2005
|
+
targetId = anchorLock.id;
|
|
2006
|
+
prevPosition = anchorLock.position;
|
|
2007
|
+
} else if (scrollTarget !== void 0) {
|
|
2008
|
+
if (!IsNewArchitecture && (scrollingTo == null ? void 0 : scrollingTo.isInitialScroll)) {
|
|
2009
|
+
return void 0;
|
|
2388
2010
|
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
React2.useLayoutEffect(() => {
|
|
2393
|
-
if (!ListHeaderComponent) {
|
|
2394
|
-
setHeaderSize(ctx, 0);
|
|
2011
|
+
targetId = getId(state, scrollTarget);
|
|
2012
|
+
} else if (idsInView.length > 0 && state.didContainersLayout && !dataChanged) {
|
|
2013
|
+
targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
2395
2014
|
}
|
|
2396
|
-
if (
|
|
2397
|
-
|
|
2015
|
+
if (dataChanged && idsInView.length > 0 && state.didContainersLayout) {
|
|
2016
|
+
for (let i = 0; i < idsInView.length; i++) {
|
|
2017
|
+
const id = idsInView[i];
|
|
2018
|
+
const index = indexByKey.get(id);
|
|
2019
|
+
if (index !== void 0) {
|
|
2020
|
+
const position = positions[index];
|
|
2021
|
+
if (position !== void 0) {
|
|
2022
|
+
idsInViewWithPositions.push({ id, position });
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2398
2026
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
setHeaderSize(ctx, size);
|
|
2404
|
-
},
|
|
2405
|
-
[ctx, horizontal]
|
|
2406
|
-
);
|
|
2407
|
-
const onLayoutFooterInternal = React2.useCallback(
|
|
2408
|
-
(rect, fromLayoutEffect) => {
|
|
2409
|
-
const size = rect[horizontal ? "width" : "height"];
|
|
2410
|
-
updateFooterSize(size, () => {
|
|
2411
|
-
onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
|
|
2412
|
-
});
|
|
2413
|
-
},
|
|
2414
|
-
[horizontal, onLayoutFooter, updateFooterSize]
|
|
2415
|
-
);
|
|
2416
|
-
return /* @__PURE__ */ React2__namespace.createElement(
|
|
2417
|
-
SnapOrScroll,
|
|
2418
|
-
{
|
|
2419
|
-
...rest,
|
|
2420
|
-
...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
|
|
2421
|
-
contentContainerStyle: [
|
|
2422
|
-
horizontal ? {
|
|
2423
|
-
height: "100%"
|
|
2424
|
-
} : {},
|
|
2425
|
-
contentContainerStyle
|
|
2426
|
-
],
|
|
2427
|
-
contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
2428
|
-
horizontal,
|
|
2429
|
-
maintainVisibleContentPosition: maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
|
|
2430
|
-
onLayout,
|
|
2431
|
-
onScroll: onScroll2,
|
|
2432
|
-
ref: refScrollView,
|
|
2433
|
-
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
2434
|
-
style: autoOtherAxisStyle ? [autoOtherAxisStyle, style] : style
|
|
2435
|
-
},
|
|
2436
|
-
/* @__PURE__ */ React2__namespace.createElement(ScrollAdjust, null),
|
|
2437
|
-
ListHeaderComponent && /* @__PURE__ */ React2__namespace.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
2438
|
-
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
2439
|
-
shouldRenderAlignItemsAtEndSpacer && /* @__PURE__ */ React2__namespace.createElement(AlignItemsAtEndSpacer, { horizontal }),
|
|
2440
|
-
canRender && !ListEmptyComponent && /* @__PURE__ */ React2__namespace.createElement(
|
|
2441
|
-
Containers,
|
|
2442
|
-
{
|
|
2443
|
-
getRenderedItem: getRenderedItem2,
|
|
2444
|
-
horizontal,
|
|
2445
|
-
ItemSeparatorComponent,
|
|
2446
|
-
recycleItems,
|
|
2447
|
-
stickyHeaderConfig,
|
|
2448
|
-
updateItemSize: updateItemSize2
|
|
2449
|
-
}
|
|
2450
|
-
),
|
|
2451
|
-
ListFooterComponent && /* @__PURE__ */ React2__namespace.createElement(LayoutView, { onLayoutChange: onLayoutFooterInternal, style: ListFooterComponentStyle }, getComponent(ListFooterComponent)),
|
|
2452
|
-
Platform.OS === "web" && /* @__PURE__ */ React2__namespace.createElement(WebAnchoredEndSpace, { horizontal }),
|
|
2453
|
-
IS_DEV && ENABLE_DEVMODE
|
|
2454
|
-
);
|
|
2455
|
-
});
|
|
2456
|
-
var WEB_UNBOUNDED_HEIGHT_MIN_DATA_LENGTH = 100;
|
|
2457
|
-
var WEB_UNBOUNDED_HEIGHT_CONTAINER_RATIO = 0.9;
|
|
2458
|
-
var WEB_UNBOUNDED_HEIGHT_VIEWPORT_RATIO = 0.9;
|
|
2459
|
-
function useDevChecksImpl(props) {
|
|
2460
|
-
const ctx = useStateContext();
|
|
2461
|
-
const { childrenMode, keyExtractor, renderScrollComponent, useWindowScroll } = props;
|
|
2462
|
-
React2.useEffect(() => {
|
|
2463
|
-
if (useWindowScroll && renderScrollComponent) {
|
|
2464
|
-
warnDevOnce(
|
|
2465
|
-
"useWindowScrollRenderScrollComponent",
|
|
2466
|
-
"useWindowScroll is not supported when renderScrollComponent is provided."
|
|
2467
|
-
);
|
|
2468
|
-
}
|
|
2469
|
-
}, [renderScrollComponent, useWindowScroll]);
|
|
2470
|
-
React2.useEffect(() => {
|
|
2471
|
-
if (!keyExtractor && !ctx.state.isFirst && ctx.state.didDataChange && !childrenMode) {
|
|
2472
|
-
warnDevOnce(
|
|
2473
|
-
"keyExtractor",
|
|
2474
|
-
"Changing data without a keyExtractor can cause slow performance and resetting scroll. If your list data can change you should use a keyExtractor with a unique id for best performance and behavior."
|
|
2475
|
-
);
|
|
2476
|
-
}
|
|
2477
|
-
}, [childrenMode, ctx, keyExtractor]);
|
|
2478
|
-
React2.useEffect(() => {
|
|
2479
|
-
const state = ctx.state;
|
|
2480
|
-
const dataLength = state.props.data.length;
|
|
2481
|
-
const useWindowScrollResolved = state.props.useWindowScroll;
|
|
2482
|
-
if (Platform.OS !== "web" || useWindowScrollResolved || dataLength < WEB_UNBOUNDED_HEIGHT_MIN_DATA_LENGTH) {
|
|
2483
|
-
return;
|
|
2484
|
-
}
|
|
2485
|
-
const warnIfUnboundedOuterSize = () => {
|
|
2486
|
-
const readyToRender = peek$(ctx, "readyToRender");
|
|
2487
|
-
const numContainers = peek$(ctx, "numContainers") || 0;
|
|
2488
|
-
const totalSize = peek$(ctx, "totalSize") || 0;
|
|
2489
|
-
const scrollLength = ctx.state.scrollLength || 0;
|
|
2490
|
-
if (!readyToRender || totalSize <= 0 || scrollLength <= 0) {
|
|
2491
|
-
return;
|
|
2492
|
-
}
|
|
2493
|
-
const rendersAlmostEverything = numContainers >= Math.ceil(dataLength * WEB_UNBOUNDED_HEIGHT_CONTAINER_RATIO);
|
|
2494
|
-
const viewportMatchesContent = scrollLength >= totalSize * WEB_UNBOUNDED_HEIGHT_VIEWPORT_RATIO;
|
|
2495
|
-
if (rendersAlmostEverything && viewportMatchesContent) {
|
|
2496
|
-
warnDevOnce(
|
|
2497
|
-
"webUnboundedOuterSize",
|
|
2498
|
-
"LegendList appears to have an unbounded outer height on web, so virtualization is effectively disabled. Set a bounded height or flex: 1 on the list container, or use useWindowScroll."
|
|
2499
|
-
);
|
|
2500
|
-
}
|
|
2501
|
-
};
|
|
2502
|
-
warnIfUnboundedOuterSize();
|
|
2503
|
-
const unsubscribe = [
|
|
2504
|
-
listen$(ctx, "numContainers", warnIfUnboundedOuterSize),
|
|
2505
|
-
listen$(ctx, "readyToRender", warnIfUnboundedOuterSize),
|
|
2506
|
-
listen$(ctx, "totalSize", warnIfUnboundedOuterSize)
|
|
2507
|
-
];
|
|
2508
|
-
return () => {
|
|
2509
|
-
for (const unsub of unsubscribe) {
|
|
2510
|
-
unsub();
|
|
2511
|
-
}
|
|
2512
|
-
};
|
|
2513
|
-
}, [ctx]);
|
|
2514
|
-
}
|
|
2515
|
-
function useDevChecksNoop(_props) {
|
|
2516
|
-
}
|
|
2517
|
-
var useDevChecks = IS_DEV ? useDevChecksImpl : useDevChecksNoop;
|
|
2518
|
-
|
|
2519
|
-
// src/core/mvcp.ts
|
|
2520
|
-
var MVCP_POSITION_EPSILON = 0.1;
|
|
2521
|
-
var MVCP_ANCHOR_LOCK_TTL_MS = 300;
|
|
2522
|
-
var MVCP_ANCHOR_LOCK_QUIET_PASSES_TO_RELEASE = 2;
|
|
2523
|
-
var NATIVE_END_CLAMP_EPSILON = 1;
|
|
2524
|
-
function resolveAnchorLock(state, enableMVCPAnchorLock, mvcpData, now) {
|
|
2525
|
-
if (!enableMVCPAnchorLock) {
|
|
2526
|
-
state.mvcpAnchorLock = void 0;
|
|
2527
|
-
return void 0;
|
|
2528
|
-
}
|
|
2529
|
-
const lock = state.mvcpAnchorLock;
|
|
2530
|
-
if (!lock) {
|
|
2531
|
-
return void 0;
|
|
2532
|
-
}
|
|
2533
|
-
const isExpired = now > lock.expiresAt;
|
|
2534
|
-
const isMissing = state.indexByKey.get(lock.id) === void 0;
|
|
2535
|
-
if (isExpired || isMissing || !mvcpData) {
|
|
2536
|
-
state.mvcpAnchorLock = void 0;
|
|
2537
|
-
return void 0;
|
|
2538
|
-
}
|
|
2539
|
-
return lock;
|
|
2540
|
-
}
|
|
2541
|
-
function updateAnchorLock(state, params) {
|
|
2542
|
-
if (Platform.OS === "web") {
|
|
2543
|
-
const { anchorId, anchorPosition, dataChanged, now, positionDiff } = params;
|
|
2544
|
-
const enableMVCPAnchorLock = !!dataChanged || !!state.mvcpAnchorLock;
|
|
2545
|
-
const mvcpData = state.props.maintainVisibleContentPosition.data;
|
|
2546
|
-
if (!enableMVCPAnchorLock || !mvcpData || state.scrollingTo || !anchorId || anchorPosition === void 0) {
|
|
2547
|
-
return;
|
|
2548
|
-
}
|
|
2549
|
-
const existingLock = state.mvcpAnchorLock;
|
|
2550
|
-
const quietPasses = !dataChanged && Math.abs(positionDiff) <= MVCP_POSITION_EPSILON && (existingLock == null ? void 0 : existingLock.id) === anchorId ? existingLock.quietPasses + 1 : 0;
|
|
2551
|
-
if (!dataChanged && quietPasses >= MVCP_ANCHOR_LOCK_QUIET_PASSES_TO_RELEASE) {
|
|
2552
|
-
state.mvcpAnchorLock = void 0;
|
|
2553
|
-
return;
|
|
2554
|
-
}
|
|
2555
|
-
state.mvcpAnchorLock = {
|
|
2556
|
-
expiresAt: now + MVCP_ANCHOR_LOCK_TTL_MS,
|
|
2557
|
-
id: anchorId,
|
|
2558
|
-
position: anchorPosition,
|
|
2559
|
-
quietPasses
|
|
2560
|
-
};
|
|
2561
|
-
}
|
|
2562
|
-
}
|
|
2563
|
-
function shouldQueueNativeMVCPAdjust(dataChanged, state, positionDiff, prevTotalSize, prevScroll, scrollTarget) {
|
|
2564
|
-
if (!dataChanged || Platform.OS === "web" || !state.props.maintainVisibleContentPosition.data || scrollTarget !== void 0 || positionDiff >= -MVCP_POSITION_EPSILON) {
|
|
2565
|
-
return false;
|
|
2566
|
-
}
|
|
2567
|
-
const distanceFromEnd = prevTotalSize - prevScroll - state.scrollLength;
|
|
2568
|
-
return distanceFromEnd < Math.abs(positionDiff) - MVCP_POSITION_EPSILON;
|
|
2569
|
-
}
|
|
2570
|
-
function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
|
|
2571
|
-
if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
|
|
2572
|
-
return 0;
|
|
2573
|
-
}
|
|
2574
|
-
const maxScroll = Math.max(0, totalSize - state.scrollLength);
|
|
2575
|
-
const clampDelta = maxScroll - state.scroll;
|
|
2576
|
-
if (unresolvedAmount < 0) {
|
|
2577
|
-
return Math.max(unresolvedAmount, Math.min(0, clampDelta));
|
|
2578
|
-
}
|
|
2579
|
-
if (unresolvedAmount > 0) {
|
|
2580
|
-
return Math.min(unresolvedAmount, Math.max(0, clampDelta));
|
|
2581
|
-
}
|
|
2582
|
-
return 0;
|
|
2583
|
-
}
|
|
2584
|
-
function getProgressTowardAmount(targetDelta, nativeDelta) {
|
|
2585
|
-
return targetDelta < 0 ? -nativeDelta : nativeDelta;
|
|
2586
|
-
}
|
|
2587
|
-
function settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta) {
|
|
2588
|
-
const state = ctx.state;
|
|
2589
|
-
state.pendingNativeMVCPAdjust = void 0;
|
|
2590
|
-
const remaining = remainingAfterManual - nativeDelta;
|
|
2591
|
-
if (Math.abs(remaining) > MVCP_POSITION_EPSILON) {
|
|
2592
|
-
requestAdjust(ctx, remaining, true);
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
function maybeApplyPredictedNativeMVCPAdjust(ctx) {
|
|
2596
|
-
const state = ctx.state;
|
|
2597
|
-
const pending = state.pendingNativeMVCPAdjust;
|
|
2598
|
-
if (!pending || Math.abs(pending.manualApplied) > MVCP_POSITION_EPSILON) {
|
|
2599
|
-
return;
|
|
2600
|
-
}
|
|
2601
|
-
const totalSize = getContentSize(ctx);
|
|
2602
|
-
const predictedNativeClamp = getPredictedNativeClamp(state, pending.amount, totalSize);
|
|
2603
|
-
if (Math.abs(predictedNativeClamp) <= MVCP_POSITION_EPSILON) {
|
|
2604
|
-
return;
|
|
2605
|
-
}
|
|
2606
|
-
const manualDesired = pending.amount - predictedNativeClamp;
|
|
2607
|
-
if (Math.abs(manualDesired) <= MVCP_POSITION_EPSILON) {
|
|
2608
|
-
return;
|
|
2609
|
-
}
|
|
2610
|
-
pending.manualApplied = manualDesired;
|
|
2611
|
-
requestAdjust(ctx, manualDesired, true);
|
|
2612
|
-
pending.furthestProgressTowardAmount = 0;
|
|
2613
|
-
}
|
|
2614
|
-
function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
|
|
2615
|
-
const state = ctx.state;
|
|
2616
|
-
const pending = state.pendingNativeMVCPAdjust;
|
|
2617
|
-
if (!pending) {
|
|
2618
|
-
return false;
|
|
2619
|
-
}
|
|
2620
|
-
const remainingAfterManual = pending.amount - pending.manualApplied;
|
|
2621
|
-
const nativeDelta = newScroll - (pending.startScroll + pending.manualApplied);
|
|
2622
|
-
const isWrongDirection = remainingAfterManual < 0 && nativeDelta > MVCP_POSITION_EPSILON || remainingAfterManual > 0 && nativeDelta < -MVCP_POSITION_EPSILON;
|
|
2623
|
-
const progressTowardAmount = getProgressTowardAmount(remainingAfterManual, nativeDelta);
|
|
2624
|
-
if (Math.abs(remainingAfterManual) <= MVCP_POSITION_EPSILON) {
|
|
2625
|
-
state.pendingNativeMVCPAdjust = void 0;
|
|
2626
|
-
return true;
|
|
2627
|
-
}
|
|
2628
|
-
if (isWrongDirection) {
|
|
2629
|
-
state.pendingNativeMVCPAdjust = void 0;
|
|
2630
|
-
return false;
|
|
2631
|
-
}
|
|
2632
|
-
if (progressTowardAmount + MVCP_POSITION_EPSILON >= Math.abs(remainingAfterManual)) {
|
|
2633
|
-
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
|
|
2634
|
-
return true;
|
|
2635
|
-
}
|
|
2636
|
-
const expectedNativeClampScroll = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
2637
|
-
const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
|
|
2638
|
-
const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
|
|
2639
|
-
if (isAtExpectedNativeClamp) {
|
|
2640
|
-
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
|
|
2641
|
-
return true;
|
|
2642
|
-
}
|
|
2643
|
-
if (state.pendingMaintainScrollAtEnd && peek$(ctx, "isWithinMaintainScrollAtEndThreshold") && progressTowardAmount > MVCP_POSITION_EPSILON) {
|
|
2644
|
-
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
|
|
2645
|
-
return true;
|
|
2646
|
-
}
|
|
2647
|
-
if (progressTowardAmount > pending.furthestProgressTowardAmount + MVCP_POSITION_EPSILON) {
|
|
2648
|
-
pending.furthestProgressTowardAmount = progressTowardAmount;
|
|
2649
|
-
return false;
|
|
2650
|
-
}
|
|
2651
|
-
if (pending.furthestProgressTowardAmount > MVCP_POSITION_EPSILON && progressTowardAmount < pending.furthestProgressTowardAmount - MVCP_POSITION_EPSILON) {
|
|
2652
|
-
state.pendingNativeMVCPAdjust = void 0;
|
|
2653
|
-
return false;
|
|
2654
|
-
}
|
|
2655
|
-
return false;
|
|
2656
|
-
}
|
|
2657
|
-
function prepareMVCP(ctx, dataChanged) {
|
|
2658
|
-
const state = ctx.state;
|
|
2659
|
-
const { idsInView, positions, props } = state;
|
|
2660
|
-
const {
|
|
2661
|
-
maintainVisibleContentPosition: { data: mvcpData, size: mvcpScroll, shouldRestorePosition }
|
|
2662
|
-
} = props;
|
|
2663
|
-
const isWeb = Platform.OS === "web";
|
|
2664
|
-
const now = Date.now();
|
|
2665
|
-
const enableMVCPAnchorLock = isWeb && (!!dataChanged || !!state.mvcpAnchorLock);
|
|
2666
|
-
const scrollingTo = state.scrollingTo;
|
|
2667
|
-
if (isWeb && dataChanged && state.pendingScrollToEnd && scrollingTo === void 0) {
|
|
2668
|
-
state.mvcpAnchorLock = void 0;
|
|
2669
|
-
return void 0;
|
|
2670
|
-
}
|
|
2671
|
-
const anchorLock = isWeb ? resolveAnchorLock(state, enableMVCPAnchorLock, mvcpData, now) : void 0;
|
|
2672
|
-
let prevPosition;
|
|
2673
|
-
let targetId;
|
|
2674
|
-
const idsInViewWithPositions = [];
|
|
2675
|
-
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
2676
|
-
const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
|
|
2677
|
-
const isEndAnchoredScrollTarget = scrollTarget !== void 0 && state.props.data.length > 0 && scrollTarget >= state.props.data.length - 1 && (scrollingToViewPosition != null ? scrollingToViewPosition : 0) > 0;
|
|
2678
|
-
const shouldMVCP = dataChanged ? mvcpData : mvcpScroll;
|
|
2679
|
-
const indexByKey = state.indexByKey;
|
|
2680
|
-
const prevScroll = state.scroll;
|
|
2681
|
-
const prevTotalSize = getContentSize(ctx);
|
|
2682
|
-
if (shouldMVCP) {
|
|
2683
|
-
if (!isWeb && state.pendingNativeMVCPAdjust && scrollTarget === void 0) {
|
|
2684
|
-
maybeApplyPredictedNativeMVCPAdjust(ctx);
|
|
2685
|
-
return void 0;
|
|
2686
|
-
}
|
|
2687
|
-
if (anchorLock && scrollTarget === void 0) {
|
|
2688
|
-
targetId = anchorLock.id;
|
|
2689
|
-
prevPosition = anchorLock.position;
|
|
2690
|
-
} else if (scrollTarget !== void 0) {
|
|
2691
|
-
if (!IsNewArchitecture && (scrollingTo == null ? void 0 : scrollingTo.isInitialScroll)) {
|
|
2692
|
-
return void 0;
|
|
2693
|
-
}
|
|
2694
|
-
targetId = getId(state, scrollTarget);
|
|
2695
|
-
} else if (idsInView.length > 0 && state.didContainersLayout && !dataChanged) {
|
|
2696
|
-
targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
2697
|
-
}
|
|
2698
|
-
if (dataChanged && idsInView.length > 0 && state.didContainersLayout) {
|
|
2699
|
-
for (let i = 0; i < idsInView.length; i++) {
|
|
2700
|
-
const id = idsInView[i];
|
|
2701
|
-
const index = indexByKey.get(id);
|
|
2702
|
-
if (index !== void 0) {
|
|
2703
|
-
const position = positions[index];
|
|
2704
|
-
if (position !== void 0) {
|
|
2705
|
-
idsInViewWithPositions.push({ id, position });
|
|
2706
|
-
}
|
|
2707
|
-
}
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
if (targetId !== void 0 && prevPosition === void 0) {
|
|
2711
|
-
const targetIndex = indexByKey.get(targetId);
|
|
2712
|
-
if (targetIndex !== void 0) {
|
|
2713
|
-
prevPosition = positions[targetIndex];
|
|
2027
|
+
if (targetId !== void 0 && prevPosition === void 0) {
|
|
2028
|
+
const targetIndex = indexByKey.get(targetId);
|
|
2029
|
+
if (targetIndex !== void 0) {
|
|
2030
|
+
prevPosition = positions[targetIndex];
|
|
2714
2031
|
}
|
|
2715
2032
|
}
|
|
2716
2033
|
return () => {
|
|
@@ -4778,7 +4095,21 @@ function getIdsInVisibleRange(state, range) {
|
|
|
4778
4095
|
}
|
|
4779
4096
|
return idsInView;
|
|
4780
4097
|
}
|
|
4781
|
-
function
|
|
4098
|
+
function maybeEmitFirstVisibleItemChanged(state, index) {
|
|
4099
|
+
var _a3;
|
|
4100
|
+
const onFirstVisibleItemChanged = state.props.onFirstVisibleItemChanged;
|
|
4101
|
+
if (!onFirstVisibleItemChanged || index === null || index < 0 || index >= state.props.data.length) {
|
|
4102
|
+
return;
|
|
4103
|
+
}
|
|
4104
|
+
const key = (_a3 = state.idCache[index]) != null ? _a3 : getId(state, index);
|
|
4105
|
+
const previous = state.lastFirstVisibleItemCallback;
|
|
4106
|
+
if ((previous == null ? void 0 : previous.index) === index && previous.key === key) {
|
|
4107
|
+
return;
|
|
4108
|
+
}
|
|
4109
|
+
state.lastFirstVisibleItemCallback = { index, key };
|
|
4110
|
+
onFirstVisibleItemChanged({ index, item: state.props.data[index], key });
|
|
4111
|
+
}
|
|
4112
|
+
function findFirstVisibleIndexInCachedRange(ctx, scroll) {
|
|
4782
4113
|
var _a3, _b;
|
|
4783
4114
|
const state = ctx.state;
|
|
4784
4115
|
const {
|
|
@@ -4790,13 +4121,37 @@ function updateViewabilityForCachedRange(ctx, viewabilityConfigCallbackPairs, sc
|
|
|
4790
4121
|
startBuffered
|
|
4791
4122
|
} = state;
|
|
4792
4123
|
if (startBuffered === null || endBuffered === null || startBuffered < 0 || endBuffered < startBuffered) {
|
|
4793
|
-
return;
|
|
4124
|
+
return null;
|
|
4794
4125
|
}
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4126
|
+
for (let i = startBuffered; i <= endBuffered && i < data.length; i++) {
|
|
4127
|
+
const id = (_a3 = idCache[i]) != null ? _a3 : getId(state, i);
|
|
4128
|
+
const size = (_b = sizes.get(id)) != null ? _b : getItemSize(ctx, id, i, data[i]);
|
|
4129
|
+
const top = positions[i];
|
|
4130
|
+
if (top + size > scroll) {
|
|
4131
|
+
return i;
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
return null;
|
|
4135
|
+
}
|
|
4136
|
+
function updateViewabilityForCachedRange(ctx, viewabilityConfigCallbackPairs, scrollLength, scroll, scrollBottom) {
|
|
4137
|
+
var _a3, _b;
|
|
4138
|
+
const state = ctx.state;
|
|
4139
|
+
const {
|
|
4140
|
+
endBuffered,
|
|
4141
|
+
idCache,
|
|
4142
|
+
positions,
|
|
4143
|
+
props: { data },
|
|
4144
|
+
sizes,
|
|
4145
|
+
startBuffered
|
|
4146
|
+
} = state;
|
|
4147
|
+
if (startBuffered === null || endBuffered === null || startBuffered < 0 || endBuffered < startBuffered) {
|
|
4148
|
+
return;
|
|
4149
|
+
}
|
|
4150
|
+
const visibleRange = {
|
|
4151
|
+
endNoBuffer: null,
|
|
4152
|
+
firstFullyOnScreenIndex: void 0,
|
|
4153
|
+
startNoBuffer: null
|
|
4154
|
+
};
|
|
4800
4155
|
for (let i = startBuffered; i <= endBuffered && i < data.length; i++) {
|
|
4801
4156
|
const id = (_a3 = idCache[i]) != null ? _a3 : getId(state, i);
|
|
4802
4157
|
const size = (_b = sizes.get(id)) != null ? _b : getItemSize(ctx, id, i, data[i]);
|
|
@@ -4812,6 +4167,7 @@ function updateViewabilityForCachedRange(ctx, viewabilityConfigCallbackPairs, sc
|
|
|
4812
4167
|
idsInView: getIdsInVisibleRange(state, visibleRange),
|
|
4813
4168
|
startNoBuffer: visibleRange.startNoBuffer
|
|
4814
4169
|
});
|
|
4170
|
+
maybeEmitFirstVisibleItemChanged(state, visibleRange.startNoBuffer);
|
|
4815
4171
|
if (visibleRange.startNoBuffer !== null && visibleRange.endNoBuffer !== null) {
|
|
4816
4172
|
updateViewableItems(
|
|
4817
4173
|
state,
|
|
@@ -4937,6 +4293,8 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4937
4293
|
scroll,
|
|
4938
4294
|
scrollBottom
|
|
4939
4295
|
);
|
|
4296
|
+
} else if (state.props.onFirstVisibleItemChanged) {
|
|
4297
|
+
maybeEmitFirstVisibleItemChanged(state, findFirstVisibleIndexInCachedRange(ctx, scroll));
|
|
4940
4298
|
}
|
|
4941
4299
|
(_d = stickyState == null ? void 0 : stickyState.finishCalculateItemsInView) == null ? void 0 : _d.call(stickyState);
|
|
4942
4300
|
return;
|
|
@@ -5172,87 +4530,1035 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
5172
4530
|
state.userScrollAnchorReset = void 0;
|
|
5173
4531
|
}
|
|
5174
4532
|
}
|
|
5175
|
-
if (alwaysRenderArr.length > 0) {
|
|
5176
|
-
for (const index of alwaysRenderArr) {
|
|
5177
|
-
if (index < 0 || index >= dataLength) continue;
|
|
5178
|
-
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
5179
|
-
const containerIndex = containerItemKeys.get(id);
|
|
5180
|
-
if (containerIndex !== void 0) {
|
|
5181
|
-
state.stickyContainerPool.add(containerIndex);
|
|
5182
|
-
}
|
|
5183
|
-
}
|
|
4533
|
+
if (alwaysRenderArr.length > 0) {
|
|
4534
|
+
for (const index of alwaysRenderArr) {
|
|
4535
|
+
if (index < 0 || index >= dataLength) continue;
|
|
4536
|
+
const id = (_r = idCache[index]) != null ? _r : getId(state, index);
|
|
4537
|
+
const containerIndex = containerItemKeys.get(id);
|
|
4538
|
+
if (containerIndex !== void 0) {
|
|
4539
|
+
state.stickyContainerPool.add(containerIndex);
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
}
|
|
4543
|
+
}
|
|
4544
|
+
if (state.stickyContainerPool.size > 0) {
|
|
4545
|
+
handleStickyRecycling(
|
|
4546
|
+
ctx,
|
|
4547
|
+
stickyHeaderIndicesArr,
|
|
4548
|
+
scroll,
|
|
4549
|
+
drawDistance,
|
|
4550
|
+
(_s = stickyState == null ? void 0 : stickyState.currentStickyIdx) != null ? _s : -1,
|
|
4551
|
+
pendingRemoval,
|
|
4552
|
+
alwaysRenderSet
|
|
4553
|
+
);
|
|
4554
|
+
}
|
|
4555
|
+
const pendingRemovalSet = pendingRemoval.length > 0 ? new Set(pendingRemoval) : void 0;
|
|
4556
|
+
let didChangePositions = false;
|
|
4557
|
+
for (let i = 0; i < numContainers; i++) {
|
|
4558
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
4559
|
+
if (pendingRemovalSet == null ? void 0 : pendingRemovalSet.has(i)) {
|
|
4560
|
+
if (itemKey !== void 0) {
|
|
4561
|
+
containerItemKeys.delete(itemKey);
|
|
4562
|
+
}
|
|
4563
|
+
state.containerItemTypes.delete(i);
|
|
4564
|
+
if (state.stickyContainerPool.has(i)) {
|
|
4565
|
+
set$(ctx, `containerSticky${i}`, false);
|
|
4566
|
+
state.stickyContainerPool.delete(i);
|
|
4567
|
+
}
|
|
4568
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
4569
|
+
set$(ctx, `containerItemData${i}`, void 0);
|
|
4570
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
4571
|
+
set$(ctx, `containerColumn${i}`, -1);
|
|
4572
|
+
set$(ctx, `containerSpan${i}`, 1);
|
|
4573
|
+
} else {
|
|
4574
|
+
const itemIndex = indexByKey.get(itemKey);
|
|
4575
|
+
if (itemIndex !== void 0) {
|
|
4576
|
+
didChangePositions = syncMountedContainer(ctx, i, itemIndex, {
|
|
4577
|
+
scrollAdjustPending,
|
|
4578
|
+
updateLayout: true
|
|
4579
|
+
}).didChangePosition || didChangePositions;
|
|
4580
|
+
}
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
if (Platform.OS === "web" && didChangePositions) {
|
|
4584
|
+
set$(ctx, "lastPositionUpdate", Date.now());
|
|
4585
|
+
}
|
|
4586
|
+
if (suppressInitialScrollSideEffects) {
|
|
4587
|
+
evaluateBootstrapInitialScroll(ctx);
|
|
4588
|
+
return;
|
|
4589
|
+
}
|
|
4590
|
+
maybeEmitFirstVisibleItemChanged(state, visibleRange.startNoBuffer);
|
|
4591
|
+
if (!queuedInitialLayout && !state.didContainersLayout) {
|
|
4592
|
+
const isInitialLayoutReady = hasActiveInitialScroll(state) ? checkAllSizesKnown(state, state.startBuffered, state.endBuffered) : checkAllSizesKnown(state, state.startNoBuffer, state.endNoBuffer) || checkAllSizesKnown(state, state.startBuffered, state.endBuffered);
|
|
4593
|
+
if (isInitialLayoutReady) {
|
|
4594
|
+
setDidLayout(ctx);
|
|
4595
|
+
handleInitialScrollLayoutReady(ctx);
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
if (viewabilityConfigCallbackPairs && visibleRange.startNoBuffer !== null && visibleRange.endNoBuffer !== null) {
|
|
4599
|
+
if (!didMVCPAdjustScroll) {
|
|
4600
|
+
updateViewableItems(
|
|
4601
|
+
ctx.state,
|
|
4602
|
+
ctx,
|
|
4603
|
+
viewabilityConfigCallbackPairs,
|
|
4604
|
+
scrollLength,
|
|
4605
|
+
visibleRange.startNoBuffer,
|
|
4606
|
+
visibleRange.endNoBuffer,
|
|
4607
|
+
startBuffered != null ? startBuffered : visibleRange.startNoBuffer,
|
|
4608
|
+
endBuffered != null ? endBuffered : visibleRange.endNoBuffer
|
|
4609
|
+
);
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
(_t = stickyState == null ? void 0 : stickyState.finishCalculateItemsInView) == null ? void 0 : _t.call(stickyState);
|
|
4613
|
+
});
|
|
4614
|
+
}
|
|
4615
|
+
|
|
4616
|
+
// src/core/updateAnchoredEndSpace.ts
|
|
4617
|
+
function maybeUpdateAnchoredEndSpace(ctx) {
|
|
4618
|
+
var _a3, _b;
|
|
4619
|
+
const state = ctx.state;
|
|
4620
|
+
const anchoredEndSpace = state.props.anchoredEndSpace;
|
|
4621
|
+
const previousSize = peek$(ctx, "anchoredEndSpaceSize");
|
|
4622
|
+
const previousReadyAnchorIndex = state.anchoredEndSpaceReadyAnchorIndex;
|
|
4623
|
+
const previousReadyAnchorKey = state.anchoredEndSpaceReadyAnchorKey;
|
|
4624
|
+
const nextAnchorIndex = anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex;
|
|
4625
|
+
let nextAnchorKey;
|
|
4626
|
+
let isReady = true;
|
|
4627
|
+
let nextSize = 0;
|
|
4628
|
+
if (anchoredEndSpace) {
|
|
4629
|
+
const { anchorIndex, anchorMaxSize, anchorOffset = 0 } = anchoredEndSpace;
|
|
4630
|
+
const { data } = state.props;
|
|
4631
|
+
if (anchorIndex >= 0 && anchorIndex < data.length && state.scrollLength > 0) {
|
|
4632
|
+
nextAnchorKey = getId(state, anchorIndex);
|
|
4633
|
+
let contentBelowAnchor = 0;
|
|
4634
|
+
const footerSize = ctx.values.get("footerSize") || 0;
|
|
4635
|
+
const stylePaddingBottom = state.props.stylePaddingBottom || 0;
|
|
4636
|
+
let hasUnknownTailSize = false;
|
|
4637
|
+
for (let index = anchorIndex; index < data.length; index++) {
|
|
4638
|
+
const size = getKnownOrFixedItemSize(ctx, index);
|
|
4639
|
+
const effectiveSize = index === anchorIndex && anchorMaxSize !== void 0 ? Math.min(size || 0, Math.max(0, anchorMaxSize)) : size;
|
|
4640
|
+
if (size === void 0) {
|
|
4641
|
+
hasUnknownTailSize = true;
|
|
4642
|
+
}
|
|
4643
|
+
if (effectiveSize !== null && effectiveSize !== void 0 && effectiveSize > 0) {
|
|
4644
|
+
contentBelowAnchor += effectiveSize;
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
contentBelowAnchor += footerSize + stylePaddingBottom;
|
|
4648
|
+
isReady = !hasUnknownTailSize;
|
|
4649
|
+
nextSize = hasUnknownTailSize ? previousSize || 0 : Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
|
|
4650
|
+
} else if (anchorIndex >= 0) {
|
|
4651
|
+
isReady = false;
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
const didSizeChange = previousSize !== nextSize;
|
|
4655
|
+
const didReadyAnchorChange = previousReadyAnchorIndex !== nextAnchorIndex || previousReadyAnchorKey !== nextAnchorKey;
|
|
4656
|
+
if (isReady && (didSizeChange || didReadyAnchorChange)) {
|
|
4657
|
+
state.anchoredEndSpaceReadyAnchorIndex = nextAnchorIndex;
|
|
4658
|
+
state.anchoredEndSpaceReadyAnchorKey = nextAnchorKey;
|
|
4659
|
+
if (didSizeChange) {
|
|
4660
|
+
set$(ctx, "anchoredEndSpaceSize", nextSize);
|
|
4661
|
+
(_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
|
|
4662
|
+
}
|
|
4663
|
+
if (didSizeChange && (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset)) {
|
|
4664
|
+
updateScroll(ctx, state.scroll, true);
|
|
4665
|
+
}
|
|
4666
|
+
(_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
|
|
4667
|
+
}
|
|
4668
|
+
return nextSize;
|
|
4669
|
+
}
|
|
4670
|
+
var PixelRatio = ReactNative.PixelRatio;
|
|
4671
|
+
|
|
4672
|
+
// src/utils/layoutMeasurement.ts
|
|
4673
|
+
var FLOATING_POINT_SLACK = 0.01;
|
|
4674
|
+
var NATIVE_LAYOUT_MEASUREMENT_EPSILON = 1 / PixelRatio.get() + FLOATING_POINT_SLACK;
|
|
4675
|
+
function isWithinEpsilon(delta) {
|
|
4676
|
+
return Math.abs(delta) <= NATIVE_LAYOUT_MEASUREMENT_EPSILON;
|
|
4677
|
+
}
|
|
4678
|
+
function isNativeLayoutNoise(delta) {
|
|
4679
|
+
return isWithinEpsilon(delta);
|
|
4680
|
+
}
|
|
4681
|
+
|
|
4682
|
+
// src/core/updateItemSizes.ts
|
|
4683
|
+
function runOrScheduleMVCPRecalculate(ctx) {
|
|
4684
|
+
var _a3;
|
|
4685
|
+
const state = ctx.state;
|
|
4686
|
+
if (state.userScrollAnchorReset !== void 0) {
|
|
4687
|
+
calculateItemsInView(ctx);
|
|
4688
|
+
if (((_a3 = state.userScrollAnchorReset) == null ? void 0 : _a3.keys.size) === 0) {
|
|
4689
|
+
state.userScrollAnchorReset = void 0;
|
|
4690
|
+
}
|
|
4691
|
+
} else if (Platform.OS === "web") {
|
|
4692
|
+
if (!state.mvcpAnchorLock) {
|
|
4693
|
+
if (state.queuedMVCPRecalculate !== void 0) {
|
|
4694
|
+
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
4695
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4696
|
+
}
|
|
4697
|
+
calculateItemsInView(ctx, { doMVCP: true });
|
|
4698
|
+
} else if (state.queuedMVCPRecalculate === void 0) {
|
|
4699
|
+
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
4700
|
+
state.queuedMVCPRecalculate = void 0;
|
|
4701
|
+
calculateItemsInView(ctx, { doMVCP: true });
|
|
4702
|
+
});
|
|
4703
|
+
}
|
|
4704
|
+
} else {
|
|
4705
|
+
calculateItemsInView(ctx, { doMVCP: true });
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4708
|
+
function updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal) {
|
|
4709
|
+
const state = ctx.state;
|
|
4710
|
+
if (state.needsOtherAxisSize) {
|
|
4711
|
+
const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
|
|
4712
|
+
const currentOtherAxisSize = peek$(ctx, "otherAxisSize");
|
|
4713
|
+
if (!currentOtherAxisSize || otherAxisSize > currentOtherAxisSize) {
|
|
4714
|
+
set$(ctx, "otherAxisSize", otherAxisSize);
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
function mergeItemSizeUpdateResult(result, next) {
|
|
4719
|
+
result.didChange || (result.didChange = next.didChange);
|
|
4720
|
+
result.didMeasureUserScrollAnchorResetItem || (result.didMeasureUserScrollAnchorResetItem = next.didMeasureUserScrollAnchorResetItem);
|
|
4721
|
+
result.needsRecalculate || (result.needsRecalculate = next.needsRecalculate);
|
|
4722
|
+
result.shouldMaintainScrollAtEnd || (result.shouldMaintainScrollAtEnd = next.shouldMaintainScrollAtEnd);
|
|
4723
|
+
}
|
|
4724
|
+
function flushItemSizeUpdates(ctx, result) {
|
|
4725
|
+
var _a3;
|
|
4726
|
+
const state = ctx.state;
|
|
4727
|
+
if (result.needsRecalculate) {
|
|
4728
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
4729
|
+
runOrScheduleMVCPRecalculate(ctx);
|
|
4730
|
+
} else if (result.didMeasureUserScrollAnchorResetItem && ((_a3 = state.userScrollAnchorReset) == null ? void 0 : _a3.keys.size) === 0) {
|
|
4731
|
+
state.userScrollAnchorReset = void 0;
|
|
4732
|
+
}
|
|
4733
|
+
if (result.didChange && result.shouldMaintainScrollAtEnd) {
|
|
4734
|
+
doMaintainScrollAtEnd(ctx);
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
function updateItemSizes(ctx, measurement) {
|
|
4738
|
+
var _a3, _b, _c, _d;
|
|
4739
|
+
const state = ctx.state;
|
|
4740
|
+
const pendingKeys = (_a3 = state.userScrollAnchorReset) == null ? void 0 : _a3.keys;
|
|
4741
|
+
const shouldBatchPendingMeasurements = IsNewArchitecture && measurement.fromLayoutEffect && !!(pendingKeys == null ? void 0 : pendingKeys.size);
|
|
4742
|
+
if (!shouldBatchPendingMeasurements) {
|
|
4743
|
+
flushItemSizeUpdates(ctx, applyItemSize(ctx, measurement.itemKey, measurement.size));
|
|
4744
|
+
} else {
|
|
4745
|
+
const result = {};
|
|
4746
|
+
const updateContainerItemSize = (itemKey, containerId, size) => {
|
|
4747
|
+
if (containerId !== void 0 && peek$(ctx, `containerItemKey${containerId}`) === itemKey) {
|
|
4748
|
+
mergeItemSizeUpdateResult(result, applyItemSize(ctx, itemKey, size));
|
|
4749
|
+
}
|
|
4750
|
+
};
|
|
4751
|
+
updateContainerItemSize(measurement.itemKey, measurement.containerId, measurement.size);
|
|
4752
|
+
const keys = Array.from(pendingKeys);
|
|
4753
|
+
for (const itemKey of keys) {
|
|
4754
|
+
const containerId = state.containerItemKeys.get(itemKey);
|
|
4755
|
+
if (containerId !== void 0) {
|
|
4756
|
+
(_d = (_c = (_b = ctx.viewRefs.get(containerId)) == null ? void 0 : _b.current) == null ? void 0 : _c.measure) == null ? void 0 : _d.call(_c, (_x, _y, width, height) => {
|
|
4757
|
+
if (pendingKeys.has(itemKey)) {
|
|
4758
|
+
updateContainerItemSize(itemKey, containerId, { height, width });
|
|
4759
|
+
}
|
|
4760
|
+
});
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
flushItemSizeUpdates(ctx, result);
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4766
|
+
function applyItemSize(ctx, itemKey, sizeObj) {
|
|
4767
|
+
var _a3;
|
|
4768
|
+
const state = ctx.state;
|
|
4769
|
+
const userScrollAnchorReset = state.userScrollAnchorReset;
|
|
4770
|
+
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorReset == null ? void 0 : userScrollAnchorReset.keys.delete(itemKey));
|
|
4771
|
+
const {
|
|
4772
|
+
didContainersLayout,
|
|
4773
|
+
sizesKnown,
|
|
4774
|
+
props: { getFixedItemSize, getItemType, horizontal, onItemSizeChanged, data, maintainScrollAtEnd }
|
|
4775
|
+
} = state;
|
|
4776
|
+
if (!data) return { didMeasureUserScrollAnchorResetItem };
|
|
4777
|
+
const index = state.indexByKey.get(itemKey);
|
|
4778
|
+
let resolvedMeasurementItem;
|
|
4779
|
+
if (getFixedItemSize) {
|
|
4780
|
+
if (index === void 0) {
|
|
4781
|
+
return { didMeasureUserScrollAnchorResetItem };
|
|
4782
|
+
}
|
|
4783
|
+
const itemData = state.props.data[index];
|
|
4784
|
+
if (itemData === void 0) {
|
|
4785
|
+
return { didMeasureUserScrollAnchorResetItem };
|
|
4786
|
+
}
|
|
4787
|
+
const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
|
|
4788
|
+
const size2 = getFixedItemSize(itemData, index, type);
|
|
4789
|
+
resolvedMeasurementItem = {
|
|
4790
|
+
didResolveFixedItemSize: true,
|
|
4791
|
+
fixedItemSize: size2,
|
|
4792
|
+
itemData,
|
|
4793
|
+
itemType: type
|
|
4794
|
+
};
|
|
4795
|
+
if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
|
|
4796
|
+
updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
|
|
4797
|
+
return { didMeasureUserScrollAnchorResetItem };
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4800
|
+
let needsRecalculate = !didContainersLayout;
|
|
4801
|
+
let shouldMaintainScrollAtEnd = false;
|
|
4802
|
+
let minIndexSizeChanged;
|
|
4803
|
+
const prevSizeKnown = state.sizesKnown.get(itemKey);
|
|
4804
|
+
const diff = updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem);
|
|
4805
|
+
const size = roundSize(horizontal ? sizeObj.width : sizeObj.height);
|
|
4806
|
+
if (diff !== 0) {
|
|
4807
|
+
minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
|
|
4808
|
+
const { startBuffered, endBuffered } = state;
|
|
4809
|
+
needsRecalculate || (needsRecalculate = index >= startBuffered && index <= endBuffered);
|
|
4810
|
+
if (!needsRecalculate && state.containerItemKeys.has(itemKey)) {
|
|
4811
|
+
needsRecalculate = true;
|
|
4812
|
+
}
|
|
4813
|
+
if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
|
|
4814
|
+
shouldMaintainScrollAtEnd = true;
|
|
4815
|
+
}
|
|
4816
|
+
onItemSizeChanged == null ? void 0 : onItemSizeChanged({
|
|
4817
|
+
index,
|
|
4818
|
+
itemData: state.props.data[index],
|
|
4819
|
+
itemKey,
|
|
4820
|
+
previous: size - diff,
|
|
4821
|
+
size
|
|
4822
|
+
});
|
|
4823
|
+
maybeUpdateAnchoredEndSpace(ctx);
|
|
4824
|
+
}
|
|
4825
|
+
if (minIndexSizeChanged !== void 0) {
|
|
4826
|
+
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
|
|
4827
|
+
}
|
|
4828
|
+
updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
|
|
4829
|
+
if (didContainersLayout || checkAllSizesKnown(state, state.startBuffered, state.endBuffered)) {
|
|
4830
|
+
const canMaintainScrollAtEnd = shouldMaintainScrollAtEnd && !!(maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout);
|
|
4831
|
+
return {
|
|
4832
|
+
didChange: diff !== 0,
|
|
4833
|
+
didMeasureUserScrollAnchorResetItem,
|
|
4834
|
+
needsRecalculate,
|
|
4835
|
+
shouldMaintainScrollAtEnd: canMaintainScrollAtEnd
|
|
4836
|
+
};
|
|
4837
|
+
}
|
|
4838
|
+
return {
|
|
4839
|
+
didChange: diff !== 0,
|
|
4840
|
+
didMeasureUserScrollAnchorResetItem
|
|
4841
|
+
};
|
|
4842
|
+
}
|
|
4843
|
+
function updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem) {
|
|
4844
|
+
var _a3, _b, _c;
|
|
4845
|
+
const state = ctx.state;
|
|
4846
|
+
const {
|
|
4847
|
+
indexByKey,
|
|
4848
|
+
sizesKnown,
|
|
4849
|
+
averageSizes,
|
|
4850
|
+
props: { data, horizontal, getItemType, getFixedItemSize }
|
|
4851
|
+
} = state;
|
|
4852
|
+
if (!data) return 0;
|
|
4853
|
+
const index = indexByKey.get(itemKey);
|
|
4854
|
+
const itemData = (_a3 = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.itemData) != null ? _a3 : data[index];
|
|
4855
|
+
let itemType = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.itemType;
|
|
4856
|
+
let fixedItemSize = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.fixedItemSize;
|
|
4857
|
+
if (getFixedItemSize && !(resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize)) {
|
|
4858
|
+
itemType = getItemType ? (_b = getItemType(itemData, index)) != null ? _b : "" : "";
|
|
4859
|
+
fixedItemSize = getFixedItemSize(itemData, index, itemType);
|
|
4860
|
+
}
|
|
4861
|
+
const resolvedItemSize = (resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize) || itemType !== void 0 || fixedItemSize !== void 0 ? {
|
|
4862
|
+
didResolveFixedItemSize: resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize,
|
|
4863
|
+
fixedItemSize,
|
|
4864
|
+
itemType
|
|
4865
|
+
} : void 0;
|
|
4866
|
+
const prevSize = getItemSize(ctx, itemKey, index, itemData, void 0, void 0, void 0, resolvedItemSize);
|
|
4867
|
+
const rawSize = horizontal ? sizeObj.width : sizeObj.height;
|
|
4868
|
+
const prevSizeKnown = sizesKnown.get(itemKey);
|
|
4869
|
+
if (Platform.OS !== "web" && prevSizeKnown !== void 0 && isNativeLayoutNoise(rawSize - prevSizeKnown)) {
|
|
4870
|
+
return 0;
|
|
4871
|
+
}
|
|
4872
|
+
const size = Platform.OS === "web" ? Math.round(rawSize) : roundSize(rawSize);
|
|
4873
|
+
sizesKnown.set(itemKey, size);
|
|
4874
|
+
if (fixedItemSize === void 0 && size > 0) {
|
|
4875
|
+
itemType != null ? itemType : itemType = getItemType ? (_c = getItemType(itemData, index)) != null ? _c : "" : "";
|
|
4876
|
+
let averages = averageSizes[itemType];
|
|
4877
|
+
if (!averages) {
|
|
4878
|
+
averages = averageSizes[itemType] = { avg: 0, num: 0 };
|
|
4879
|
+
}
|
|
4880
|
+
if (averages.num === 0) {
|
|
4881
|
+
averages.avg = size;
|
|
4882
|
+
averages.num++;
|
|
4883
|
+
} else if (prevSizeKnown !== void 0 && prevSizeKnown > 0) {
|
|
4884
|
+
averages.avg += (size - prevSizeKnown) / averages.num;
|
|
4885
|
+
} else {
|
|
4886
|
+
averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
|
|
4887
|
+
averages.num++;
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
if (!prevSize || Math.abs(prevSize - size) > 0.1) {
|
|
4891
|
+
setSize(ctx, itemKey, size);
|
|
4892
|
+
return size - prevSize;
|
|
4893
|
+
}
|
|
4894
|
+
return 0;
|
|
4895
|
+
}
|
|
4896
|
+
function useOnLayoutSync({
|
|
4897
|
+
ref,
|
|
4898
|
+
onLayoutProp,
|
|
4899
|
+
onLayoutChange
|
|
4900
|
+
}, deps = []) {
|
|
4901
|
+
const onLayout = React2.useCallback(
|
|
4902
|
+
(event) => {
|
|
4903
|
+
const { layout } = event.nativeEvent;
|
|
4904
|
+
onLayoutChange(layout, false);
|
|
4905
|
+
onLayoutProp == null ? void 0 : onLayoutProp(event);
|
|
4906
|
+
},
|
|
4907
|
+
[onLayoutChange, onLayoutProp]
|
|
4908
|
+
);
|
|
4909
|
+
if (IsNewArchitecture) {
|
|
4910
|
+
React2.useLayoutEffect(() => {
|
|
4911
|
+
if (ref.current) {
|
|
4912
|
+
ref.current.measure((x, y, width, height) => {
|
|
4913
|
+
onLayoutChange({ height, width, x, y }, true);
|
|
4914
|
+
});
|
|
4915
|
+
}
|
|
4916
|
+
}, deps);
|
|
4917
|
+
}
|
|
4918
|
+
return { onLayout };
|
|
4919
|
+
}
|
|
4920
|
+
|
|
4921
|
+
// src/components/Container.tsx
|
|
4922
|
+
function getContainerPositionStyle({
|
|
4923
|
+
columnWrapperStyle,
|
|
4924
|
+
contentContainerAlignItems,
|
|
4925
|
+
horizontal,
|
|
4926
|
+
hasItemSeparator,
|
|
4927
|
+
isHorizontalRTLList,
|
|
4928
|
+
numColumns,
|
|
4929
|
+
otherAxisPos,
|
|
4930
|
+
otherAxisSize
|
|
4931
|
+
}) {
|
|
4932
|
+
let paddingStyles;
|
|
4933
|
+
if (columnWrapperStyle) {
|
|
4934
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
4935
|
+
if (horizontal) {
|
|
4936
|
+
paddingStyles = {
|
|
4937
|
+
paddingBottom: numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0,
|
|
4938
|
+
paddingRight: columnGap || gap || void 0,
|
|
4939
|
+
paddingTop: numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0
|
|
4940
|
+
};
|
|
4941
|
+
} else {
|
|
4942
|
+
paddingStyles = {
|
|
4943
|
+
paddingBottom: rowGap || gap || void 0,
|
|
4944
|
+
paddingLeft: numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0,
|
|
4945
|
+
paddingRight: numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0
|
|
4946
|
+
};
|
|
4947
|
+
}
|
|
4948
|
+
}
|
|
4949
|
+
return horizontal ? {
|
|
4950
|
+
bottom: contentContainerAlignItems === "flex-end" && numColumns === 1 ? 0 : void 0,
|
|
4951
|
+
boxSizing: paddingStyles ? "border-box" : void 0,
|
|
4952
|
+
direction: isHorizontalRTLList && Platform.OS === "web" ? "ltr" : void 0,
|
|
4953
|
+
flexDirection: hasItemSeparator ? "row" : void 0,
|
|
4954
|
+
height: otherAxisSize,
|
|
4955
|
+
left: 0,
|
|
4956
|
+
position: "absolute",
|
|
4957
|
+
top: contentContainerAlignItems === "flex-end" && numColumns === 1 ? void 0 : otherAxisPos,
|
|
4958
|
+
...paddingStyles || {}
|
|
4959
|
+
} : {
|
|
4960
|
+
boxSizing: paddingStyles ? "border-box" : void 0,
|
|
4961
|
+
left: otherAxisPos,
|
|
4962
|
+
position: "absolute",
|
|
4963
|
+
right: numColumns > 1 ? null : 0,
|
|
4964
|
+
top: 0,
|
|
4965
|
+
width: otherAxisSize,
|
|
4966
|
+
...paddingStyles || {}
|
|
4967
|
+
};
|
|
4968
|
+
}
|
|
4969
|
+
var Container = typedMemo(function Container2({
|
|
4970
|
+
id,
|
|
4971
|
+
itemKey,
|
|
4972
|
+
recycleItems,
|
|
4973
|
+
horizontal,
|
|
4974
|
+
getRenderedItem: getRenderedItem2,
|
|
4975
|
+
ItemSeparatorComponent,
|
|
4976
|
+
stickyHeaderConfig
|
|
4977
|
+
}) {
|
|
4978
|
+
const ctx = useStateContext();
|
|
4979
|
+
const { columnWrapperStyle, animatedScrollY } = ctx;
|
|
4980
|
+
const isHorizontalRTLList = isHorizontalRTL(ctx.state);
|
|
4981
|
+
const positionComponentInternal = ctx.state.props.positionComponentInternal;
|
|
4982
|
+
const stickyPositionComponentInternal = ctx.state.props.stickyPositionComponentInternal;
|
|
4983
|
+
const [column = 0, span = 1, data, numColumns = 1, extraData, isSticky] = useArr$([
|
|
4984
|
+
`containerColumn${id}`,
|
|
4985
|
+
`containerSpan${id}`,
|
|
4986
|
+
`containerItemData${id}`,
|
|
4987
|
+
"numColumns",
|
|
4988
|
+
"extraData",
|
|
4989
|
+
`containerSticky${id}`
|
|
4990
|
+
]);
|
|
4991
|
+
const itemLayoutRef = React2.useRef({
|
|
4992
|
+
didLayout: false,
|
|
4993
|
+
horizontal,
|
|
4994
|
+
itemKey,
|
|
4995
|
+
pendingShrinkToken: 0
|
|
4996
|
+
});
|
|
4997
|
+
itemLayoutRef.current.horizontal = horizontal;
|
|
4998
|
+
itemLayoutRef.current.itemKey = itemKey;
|
|
4999
|
+
const ref = React2.useRef(null);
|
|
5000
|
+
const [layoutRenderCount, forceLayoutRender] = React2.useState(0);
|
|
5001
|
+
const resolvedColumn = column > 0 ? column : 1;
|
|
5002
|
+
const resolvedSpan = Math.min(Math.max(span || 1, 1), numColumns);
|
|
5003
|
+
const otherAxisPos = numColumns > 1 ? `${(resolvedColumn - 1) / numColumns * 100}%` : 0;
|
|
5004
|
+
const otherAxisSize = numColumns > 1 ? `${resolvedSpan / numColumns * 100}%` : void 0;
|
|
5005
|
+
const style = React2.useMemo(
|
|
5006
|
+
() => getContainerPositionStyle({
|
|
5007
|
+
columnWrapperStyle,
|
|
5008
|
+
contentContainerAlignItems: ctx.state.props.contentContainerAlignItems,
|
|
5009
|
+
hasItemSeparator: !!ItemSeparatorComponent,
|
|
5010
|
+
horizontal,
|
|
5011
|
+
isHorizontalRTLList,
|
|
5012
|
+
numColumns,
|
|
5013
|
+
otherAxisPos,
|
|
5014
|
+
otherAxisSize
|
|
5015
|
+
}),
|
|
5016
|
+
[
|
|
5017
|
+
horizontal,
|
|
5018
|
+
isHorizontalRTLList,
|
|
5019
|
+
otherAxisPos,
|
|
5020
|
+
otherAxisSize,
|
|
5021
|
+
columnWrapperStyle,
|
|
5022
|
+
ctx.state.props.contentContainerAlignItems,
|
|
5023
|
+
numColumns,
|
|
5024
|
+
ItemSeparatorComponent
|
|
5025
|
+
]
|
|
5026
|
+
);
|
|
5027
|
+
const renderedItemInfo = React2.useMemo(
|
|
5028
|
+
() => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
|
|
5029
|
+
[itemKey, data, extraData]
|
|
5030
|
+
);
|
|
5031
|
+
const { index, renderedItem } = renderedItemInfo || {};
|
|
5032
|
+
const onLayoutChange = React2.useCallback((rectangle, fromLayoutEffect) => {
|
|
5033
|
+
var _a3, _b;
|
|
5034
|
+
const {
|
|
5035
|
+
horizontal: currentHorizontal,
|
|
5036
|
+
itemKey: currentItemKey,
|
|
5037
|
+
lastSize,
|
|
5038
|
+
pendingShrinkToken
|
|
5039
|
+
} = itemLayoutRef.current;
|
|
5040
|
+
if (isNullOrUndefined(currentItemKey)) {
|
|
5041
|
+
return;
|
|
5042
|
+
}
|
|
5043
|
+
itemLayoutRef.current.didLayout = true;
|
|
5044
|
+
let layout = rectangle;
|
|
5045
|
+
const axis = currentHorizontal ? "width" : "height";
|
|
5046
|
+
const size = roundSize(rectangle[axis]);
|
|
5047
|
+
const prevSize = lastSize ? roundSize(lastSize[axis]) : void 0;
|
|
5048
|
+
const doUpdate = () => {
|
|
5049
|
+
itemLayoutRef.current.lastSize = layout;
|
|
5050
|
+
updateItemSizes(ctx, {
|
|
5051
|
+
containerId: id,
|
|
5052
|
+
fromLayoutEffect,
|
|
5053
|
+
itemKey: currentItemKey,
|
|
5054
|
+
size: layout
|
|
5055
|
+
});
|
|
5056
|
+
itemLayoutRef.current.didLayout = true;
|
|
5057
|
+
};
|
|
5058
|
+
const shouldDeferWebShrinkLayoutUpdate = Platform.OS === "web" && !isInMVCPActiveMode(ctx.state) && prevSize !== void 0 && size + 1 < prevSize;
|
|
5059
|
+
if (shouldDeferWebShrinkLayoutUpdate) {
|
|
5060
|
+
const token = pendingShrinkToken + 1;
|
|
5061
|
+
itemLayoutRef.current.pendingShrinkToken = token;
|
|
5062
|
+
requestAnimationFrame(() => {
|
|
5063
|
+
var _a4;
|
|
5064
|
+
if (itemLayoutRef.current.pendingShrinkToken !== token) {
|
|
5065
|
+
return;
|
|
5066
|
+
}
|
|
5067
|
+
const element = ref.current;
|
|
5068
|
+
const rect = (_a4 = element == null ? void 0 : element.getBoundingClientRect) == null ? void 0 : _a4.call(element);
|
|
5069
|
+
if (rect) {
|
|
5070
|
+
layout = { height: rect.height, width: rect.width };
|
|
5071
|
+
}
|
|
5072
|
+
doUpdate();
|
|
5073
|
+
});
|
|
5074
|
+
return;
|
|
5075
|
+
}
|
|
5076
|
+
if (IsNewArchitecture || size > 0) {
|
|
5077
|
+
doUpdate();
|
|
5078
|
+
} else {
|
|
5079
|
+
(_b = (_a3 = ref.current) == null ? void 0 : _a3.measure) == null ? void 0 : _b.call(_a3, (_x, _y, width, height) => {
|
|
5080
|
+
layout = { height, width };
|
|
5081
|
+
doUpdate();
|
|
5082
|
+
});
|
|
5083
|
+
}
|
|
5084
|
+
}, []);
|
|
5085
|
+
const triggerLayout = React2.useCallback(() => {
|
|
5086
|
+
forceLayoutRender((v) => v + 1);
|
|
5087
|
+
}, []);
|
|
5088
|
+
const contextValue = React2.useMemo(() => {
|
|
5089
|
+
ctx.viewRefs.set(id, ref);
|
|
5090
|
+
return {
|
|
5091
|
+
containerId: id,
|
|
5092
|
+
index,
|
|
5093
|
+
itemKey,
|
|
5094
|
+
triggerLayout,
|
|
5095
|
+
value: data
|
|
5096
|
+
};
|
|
5097
|
+
}, [id, itemKey, index, data, triggerLayout]);
|
|
5098
|
+
React2.useLayoutEffect(() => {
|
|
5099
|
+
ctx.containerLayoutTriggers.set(id, triggerLayout);
|
|
5100
|
+
return () => {
|
|
5101
|
+
if (ctx.containerLayoutTriggers.get(id) === triggerLayout) {
|
|
5102
|
+
ctx.containerLayoutTriggers.delete(id);
|
|
5103
|
+
}
|
|
5104
|
+
};
|
|
5105
|
+
}, [ctx, id, triggerLayout]);
|
|
5106
|
+
const { onLayout } = useOnLayoutSync(
|
|
5107
|
+
{
|
|
5108
|
+
onLayoutChange,
|
|
5109
|
+
ref},
|
|
5110
|
+
[itemKey, layoutRenderCount]
|
|
5111
|
+
);
|
|
5112
|
+
if (!IsNewArchitecture) {
|
|
5113
|
+
React2.useEffect(() => {
|
|
5114
|
+
if (!isNullOrUndefined(itemKey)) {
|
|
5115
|
+
itemLayoutRef.current.didLayout = false;
|
|
5116
|
+
const timeout = setTimeout(() => {
|
|
5117
|
+
if (!itemLayoutRef.current.didLayout) {
|
|
5118
|
+
const { itemKey: currentItemKey, lastSize } = itemLayoutRef.current;
|
|
5119
|
+
if (lastSize && !isNullOrUndefined(currentItemKey)) {
|
|
5120
|
+
updateItemSizes(ctx, {
|
|
5121
|
+
containerId: id,
|
|
5122
|
+
fromLayoutEffect: false,
|
|
5123
|
+
itemKey: currentItemKey,
|
|
5124
|
+
size: lastSize
|
|
5125
|
+
});
|
|
5126
|
+
itemLayoutRef.current.didLayout = true;
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
}, 16);
|
|
5130
|
+
return () => {
|
|
5131
|
+
clearTimeout(timeout);
|
|
5132
|
+
};
|
|
5133
|
+
}
|
|
5134
|
+
}, [itemKey]);
|
|
5135
|
+
}
|
|
5136
|
+
const PositionComponent = isSticky ? stickyPositionComponentInternal ? stickyPositionComponentInternal : PositionViewSticky : positionComponentInternal ? positionComponentInternal : PositionView;
|
|
5137
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
5138
|
+
PositionComponent,
|
|
5139
|
+
{
|
|
5140
|
+
animatedScrollY: isSticky ? animatedScrollY : void 0,
|
|
5141
|
+
horizontal,
|
|
5142
|
+
id,
|
|
5143
|
+
index,
|
|
5144
|
+
key: recycleItems ? void 0 : itemKey,
|
|
5145
|
+
onLayout,
|
|
5146
|
+
refView: ref,
|
|
5147
|
+
stickyHeaderConfig,
|
|
5148
|
+
style
|
|
5149
|
+
},
|
|
5150
|
+
/* @__PURE__ */ React2__namespace.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React2__namespace.createElement(Separator, { ItemSeparatorComponent, leadingItem: renderedItemInfo.item }))
|
|
5151
|
+
);
|
|
5152
|
+
});
|
|
5153
|
+
|
|
5154
|
+
// src/components/ContainerSlot.tsx
|
|
5155
|
+
function ContainerSlotBase({
|
|
5156
|
+
id,
|
|
5157
|
+
horizontal,
|
|
5158
|
+
recycleItems,
|
|
5159
|
+
ItemSeparatorComponent,
|
|
5160
|
+
getRenderedItem: getRenderedItem2,
|
|
5161
|
+
stickyHeaderConfig,
|
|
5162
|
+
ContainerComponent = Container
|
|
5163
|
+
}) {
|
|
5164
|
+
const [itemKey] = useArr$([`containerItemKey${id}`]);
|
|
5165
|
+
if (itemKey === void 0) {
|
|
5166
|
+
return null;
|
|
5167
|
+
}
|
|
5168
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
5169
|
+
ContainerComponent,
|
|
5170
|
+
{
|
|
5171
|
+
getRenderedItem: getRenderedItem2,
|
|
5172
|
+
horizontal,
|
|
5173
|
+
ItemSeparatorComponent,
|
|
5174
|
+
id,
|
|
5175
|
+
itemKey,
|
|
5176
|
+
recycleItems,
|
|
5177
|
+
stickyHeaderConfig
|
|
5178
|
+
}
|
|
5179
|
+
);
|
|
5180
|
+
}
|
|
5181
|
+
var ContainerSlot = typedMemo(function ContainerSlot2(props) {
|
|
5182
|
+
return /* @__PURE__ */ React2__namespace.createElement(ContainerSlotBase, { ...props });
|
|
5183
|
+
});
|
|
5184
|
+
|
|
5185
|
+
// src/components/Containers.native.tsx
|
|
5186
|
+
var ContainersLayer = typedMemo(function ContainersLayer2({ children, horizontal }) {
|
|
5187
|
+
const ctx = useStateContext();
|
|
5188
|
+
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
5189
|
+
const animSize = useValue$("totalSize");
|
|
5190
|
+
const [readyToRender, numColumns, otherAxisSize = 0] = useArr$(["readyToRender", "numColumns", "otherAxisSize"]);
|
|
5191
|
+
const style = horizontal ? {
|
|
5192
|
+
height: otherAxisSize || "100%",
|
|
5193
|
+
minHeight: otherAxisSize,
|
|
5194
|
+
opacity: readyToRender ? 1 : 0,
|
|
5195
|
+
width: animSize
|
|
5196
|
+
} : { height: animSize, minWidth: otherAxisSize, opacity: readyToRender ? 1 : 0 };
|
|
5197
|
+
if (columnWrapperStyle) {
|
|
5198
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
5199
|
+
const gapX = columnGap || gap || 0;
|
|
5200
|
+
const gapY = rowGap || gap || 0;
|
|
5201
|
+
if (horizontal) {
|
|
5202
|
+
if (gapY && numColumns > 1) {
|
|
5203
|
+
style.marginVertical = -gapY / 2;
|
|
5204
|
+
}
|
|
5205
|
+
if (gapX) {
|
|
5206
|
+
style.marginRight = -gapX;
|
|
5207
|
+
}
|
|
5208
|
+
} else {
|
|
5209
|
+
if (gapX && numColumns > 1) {
|
|
5210
|
+
style.marginHorizontal = -gapX;
|
|
5211
|
+
}
|
|
5212
|
+
if (gapY) {
|
|
5213
|
+
style.marginBottom = -gapY;
|
|
5214
|
+
}
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
return /* @__PURE__ */ React2__namespace.createElement(ReactNative.Animated.View, { style }, children);
|
|
5218
|
+
});
|
|
5219
|
+
var Containers = typedMemo(function Containers2({
|
|
5220
|
+
horizontal,
|
|
5221
|
+
recycleItems,
|
|
5222
|
+
ItemSeparatorComponent,
|
|
5223
|
+
stickyHeaderConfig,
|
|
5224
|
+
getRenderedItem: getRenderedItem2
|
|
5225
|
+
}) {
|
|
5226
|
+
const [numContainersPooled] = useArr$(["numContainersPooled"]);
|
|
5227
|
+
const containers = [];
|
|
5228
|
+
for (let i = 0; i < numContainersPooled; i++) {
|
|
5229
|
+
containers.push(
|
|
5230
|
+
/* @__PURE__ */ React2__namespace.createElement(
|
|
5231
|
+
ContainerSlot,
|
|
5232
|
+
{
|
|
5233
|
+
getRenderedItem: getRenderedItem2,
|
|
5234
|
+
horizontal,
|
|
5235
|
+
ItemSeparatorComponent,
|
|
5236
|
+
id: i,
|
|
5237
|
+
key: i,
|
|
5238
|
+
recycleItems,
|
|
5239
|
+
stickyHeaderConfig
|
|
5240
|
+
}
|
|
5241
|
+
)
|
|
5242
|
+
);
|
|
5243
|
+
}
|
|
5244
|
+
return /* @__PURE__ */ React2__namespace.createElement(ContainersLayer, { horizontal }, containers);
|
|
5245
|
+
});
|
|
5246
|
+
var ListComponentScrollView = ReactNative.Animated.ScrollView;
|
|
5247
|
+
|
|
5248
|
+
// src/components/listComponentStyles.ts
|
|
5249
|
+
function getAutoOtherAxisStyle({
|
|
5250
|
+
horizontal,
|
|
5251
|
+
needsOtherAxisSize,
|
|
5252
|
+
otherAxisSize
|
|
5253
|
+
}) {
|
|
5254
|
+
if (!needsOtherAxisSize || !otherAxisSize || otherAxisSize <= 0) {
|
|
5255
|
+
return void 0;
|
|
5256
|
+
}
|
|
5257
|
+
return horizontal ? { height: otherAxisSize } : { width: otherAxisSize };
|
|
5258
|
+
}
|
|
5259
|
+
function ScrollAdjust() {
|
|
5260
|
+
var _a3;
|
|
5261
|
+
const ctx = useStateContext();
|
|
5262
|
+
const bias = 1e7;
|
|
5263
|
+
const [scrollAdjust, scrollAdjustUserOffset] = useArr$(["scrollAdjust", "scrollAdjustUserOffset"]);
|
|
5264
|
+
const scrollOffset = (scrollAdjust || 0) + (scrollAdjustUserOffset || 0) + bias;
|
|
5265
|
+
const horizontal = !!((_a3 = ctx.state) == null ? void 0 : _a3.props.horizontal);
|
|
5266
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
5267
|
+
ReactNative.View,
|
|
5268
|
+
{
|
|
5269
|
+
style: {
|
|
5270
|
+
height: 0,
|
|
5271
|
+
left: horizontal ? scrollOffset : 0,
|
|
5272
|
+
position: "absolute",
|
|
5273
|
+
top: horizontal ? 0 : scrollOffset,
|
|
5274
|
+
width: 0
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5277
|
+
);
|
|
5278
|
+
}
|
|
5279
|
+
var SnapWrapper = React2__namespace.forwardRef(function SnapWrapperInner({ ScrollComponent, ...props }, ref) {
|
|
5280
|
+
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
5281
|
+
return /* @__PURE__ */ React2__namespace.createElement(ScrollComponent, { ...props, ref, snapToOffsets });
|
|
5282
|
+
});
|
|
5283
|
+
function WebAnchoredEndSpace({ horizontal }) {
|
|
5284
|
+
const ctx = useStateContext();
|
|
5285
|
+
const [anchoredEndSpaceSize] = useArr$(["anchoredEndSpaceSize"]);
|
|
5286
|
+
const shouldRenderAnchoredEndSpace = !!ctx.state.props.anchoredEndSpace && (anchoredEndSpaceSize || 0) > 0;
|
|
5287
|
+
if (!shouldRenderAnchoredEndSpace) {
|
|
5288
|
+
return null;
|
|
5289
|
+
}
|
|
5290
|
+
const style = horizontal ? { height: "100%", width: anchoredEndSpaceSize || 0 } : { height: anchoredEndSpaceSize || 0 };
|
|
5291
|
+
return /* @__PURE__ */ React2__namespace.createElement("div", { style }, null);
|
|
5292
|
+
}
|
|
5293
|
+
|
|
5294
|
+
// src/core/updateContentMetrics.ts
|
|
5295
|
+
var SCROLL_ADJUST_EPSILON = 0.1;
|
|
5296
|
+
function setContentLengthSignal(ctx, signalName, size) {
|
|
5297
|
+
const didChange = peek$(ctx, signalName) !== size;
|
|
5298
|
+
if (didChange) {
|
|
5299
|
+
set$(ctx, signalName, size);
|
|
5300
|
+
updateContentMetricsState(ctx);
|
|
5301
|
+
}
|
|
5302
|
+
return didChange;
|
|
5303
|
+
}
|
|
5304
|
+
function shouldAdjustForHeaderSizeChange(ctx, previousHeaderSize, nextHeaderSize) {
|
|
5305
|
+
const { didContainersLayout, didFinishInitialScroll, props, scroll, scrollingTo } = ctx.state;
|
|
5306
|
+
const sizeDiff = nextHeaderSize - previousHeaderSize;
|
|
5307
|
+
const leadingPadding = props.horizontal ? props.stylePaddingLeft : props.stylePaddingTop;
|
|
5308
|
+
const previousHeaderEnd = (leadingPadding || 0) + previousHeaderSize;
|
|
5309
|
+
return Platform.OS === "web" && props.maintainVisibleContentPosition.size && didContainersLayout && didFinishInitialScroll && !scrollingTo && scroll >= previousHeaderEnd - SCROLL_ADJUST_EPSILON && Math.abs(sizeDiff) > SCROLL_ADJUST_EPSILON;
|
|
5310
|
+
}
|
|
5311
|
+
function setHeaderSize(ctx, size) {
|
|
5312
|
+
const { state } = ctx;
|
|
5313
|
+
const previousHeaderSize = peek$(ctx, "headerSize") || 0;
|
|
5314
|
+
const didChange = previousHeaderSize !== size;
|
|
5315
|
+
const hasMeasuredOrEstimatedHeaderBaseline = state.didMeasureHeader || previousHeaderSize > SCROLL_ADJUST_EPSILON;
|
|
5316
|
+
if (didChange) {
|
|
5317
|
+
set$(ctx, "headerSize", size);
|
|
5318
|
+
updateContentMetricsState(ctx);
|
|
5319
|
+
if (hasMeasuredOrEstimatedHeaderBaseline && shouldAdjustForHeaderSizeChange(ctx, previousHeaderSize, size)) {
|
|
5320
|
+
requestAdjust(ctx, size - previousHeaderSize);
|
|
5321
|
+
}
|
|
5322
|
+
}
|
|
5323
|
+
state.didMeasureHeader = true;
|
|
5324
|
+
}
|
|
5325
|
+
function setFooterSize(ctx, size) {
|
|
5326
|
+
return setContentLengthSignal(ctx, "footerSize", size);
|
|
5327
|
+
}
|
|
5328
|
+
function areInsetsEqual(left, right) {
|
|
5329
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h;
|
|
5330
|
+
return ((_a3 = left == null ? void 0 : left.top) != null ? _a3 : 0) === ((_b = right == null ? void 0 : right.top) != null ? _b : 0) && ((_c = left == null ? void 0 : left.bottom) != null ? _c : 0) === ((_d = right == null ? void 0 : right.bottom) != null ? _d : 0) && ((_e = left == null ? void 0 : left.left) != null ? _e : 0) === ((_f = right == null ? void 0 : right.left) != null ? _f : 0) && ((_g = left == null ? void 0 : left.right) != null ? _g : 0) === ((_h = right == null ? void 0 : right.right) != null ? _h : 0);
|
|
5331
|
+
}
|
|
5332
|
+
function setContentInsetOverride(ctx, inset) {
|
|
5333
|
+
const { state } = ctx;
|
|
5334
|
+
const previousInset = state.contentInsetOverride;
|
|
5335
|
+
const nextInset = inset != null ? inset : void 0;
|
|
5336
|
+
const didChange = !areInsetsEqual(previousInset, nextInset);
|
|
5337
|
+
state.contentInsetOverride = nextInset;
|
|
5338
|
+
if (didChange) {
|
|
5339
|
+
updateContentMetricsState(ctx);
|
|
5340
|
+
}
|
|
5341
|
+
return didChange;
|
|
5342
|
+
}
|
|
5343
|
+
function useLatestRef(value) {
|
|
5344
|
+
const ref = React2__namespace.useRef(value);
|
|
5345
|
+
ref.current = value;
|
|
5346
|
+
return ref;
|
|
5347
|
+
}
|
|
5348
|
+
|
|
5349
|
+
// src/hooks/useStableRenderComponent.tsx
|
|
5350
|
+
function useStableRenderComponent(renderComponent, mapProps) {
|
|
5351
|
+
const renderComponentRef = useLatestRef(renderComponent);
|
|
5352
|
+
const mapPropsRef = useLatestRef(mapProps);
|
|
5353
|
+
return React2__namespace.useMemo(
|
|
5354
|
+
() => React2__namespace.forwardRef(
|
|
5355
|
+
(props, ref) => {
|
|
5356
|
+
var _a3, _b;
|
|
5357
|
+
return (_b = (_a3 = renderComponentRef.current) == null ? void 0 : _a3.call(renderComponentRef, mapPropsRef.current(props, ref))) != null ? _b : null;
|
|
5358
|
+
}
|
|
5359
|
+
),
|
|
5360
|
+
[mapPropsRef, renderComponentRef]
|
|
5361
|
+
);
|
|
5362
|
+
}
|
|
5363
|
+
var LayoutView = ({ onLayoutChange, refView, ...rest }) => {
|
|
5364
|
+
const localRef = React2.useRef(null);
|
|
5365
|
+
const ref = refView != null ? refView : localRef;
|
|
5366
|
+
const { onLayout } = useOnLayoutSync({ onLayoutChange, ref });
|
|
5367
|
+
return /* @__PURE__ */ React2__namespace.createElement(ReactNative.View, { ...rest, onLayout, ref });
|
|
5368
|
+
};
|
|
5369
|
+
|
|
5370
|
+
// src/components/ListComponent.tsx
|
|
5371
|
+
var AlignItemsAtEndSpacer = typedMemo(function AlignItemsAtEndSpacer2({ horizontal }) {
|
|
5372
|
+
const [alignItemsAtEndPadding = 0] = useArr$(["alignItemsAtEndPadding"]);
|
|
5373
|
+
if (alignItemsAtEndPadding <= 0) {
|
|
5374
|
+
return null;
|
|
5375
|
+
}
|
|
5376
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
5377
|
+
View,
|
|
5378
|
+
{
|
|
5379
|
+
style: horizontal ? { flexShrink: 0, width: alignItemsAtEndPadding } : { flexShrink: 0, height: alignItemsAtEndPadding }
|
|
5380
|
+
},
|
|
5381
|
+
null
|
|
5382
|
+
);
|
|
5383
|
+
});
|
|
5384
|
+
var ListComponent = typedMemo(function ListComponent2({
|
|
5385
|
+
canRender,
|
|
5386
|
+
style,
|
|
5387
|
+
contentContainerStyle,
|
|
5388
|
+
horizontal,
|
|
5389
|
+
initialContentOffset,
|
|
5390
|
+
recycleItems,
|
|
5391
|
+
ItemSeparatorComponent,
|
|
5392
|
+
alignItemsAtEnd: _alignItemsAtEnd,
|
|
5393
|
+
onScroll: onScroll2,
|
|
5394
|
+
onLayout,
|
|
5395
|
+
ListHeaderComponent,
|
|
5396
|
+
ListHeaderComponentStyle,
|
|
5397
|
+
ListFooterComponent,
|
|
5398
|
+
ListFooterComponentStyle,
|
|
5399
|
+
ListEmptyComponent,
|
|
5400
|
+
getRenderedItem: getRenderedItem2,
|
|
5401
|
+
refScrollView,
|
|
5402
|
+
renderScrollComponent,
|
|
5403
|
+
onLayoutFooter,
|
|
5404
|
+
scrollAdjustHandler,
|
|
5405
|
+
snapToIndices,
|
|
5406
|
+
stickyHeaderConfig,
|
|
5407
|
+
stickyHeaderIndices,
|
|
5408
|
+
useWindowScroll = false,
|
|
5409
|
+
...rest
|
|
5410
|
+
}) {
|
|
5411
|
+
const ctx = useStateContext();
|
|
5412
|
+
const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
|
|
5413
|
+
const [otherAxisSize = 0] = useArr$(["otherAxisSize"]);
|
|
5414
|
+
const shouldRenderAlignItemsAtEndSpacer = ctx.state.props.alignItemsAtEndPaddingEnabled;
|
|
5415
|
+
const autoOtherAxisStyle = getAutoOtherAxisStyle({
|
|
5416
|
+
horizontal,
|
|
5417
|
+
needsOtherAxisSize: ctx.state.needsOtherAxisSize,
|
|
5418
|
+
otherAxisSize
|
|
5419
|
+
});
|
|
5420
|
+
const CustomScrollComponent = useStableRenderComponent(
|
|
5421
|
+
renderScrollComponent,
|
|
5422
|
+
(props, ref) => ({ ...props, ref })
|
|
5423
|
+
);
|
|
5424
|
+
const ScrollComponent = renderScrollComponent ? CustomScrollComponent : ListComponentScrollView;
|
|
5425
|
+
const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
|
|
5426
|
+
const updateFooterSize = React2.useCallback(
|
|
5427
|
+
(size, afterSizeUpdate) => {
|
|
5428
|
+
var _a3;
|
|
5429
|
+
const didFooterSizeChange = setFooterSize(ctx, size);
|
|
5430
|
+
afterSizeUpdate == null ? void 0 : afterSizeUpdate();
|
|
5431
|
+
if (didFooterSizeChange && ((_a3 = ctx.state.props.maintainScrollAtEnd) == null ? void 0 : _a3.onFooterLayout)) {
|
|
5432
|
+
doMaintainScrollAtEnd(ctx);
|
|
5184
5433
|
}
|
|
5434
|
+
},
|
|
5435
|
+
[ctx]
|
|
5436
|
+
);
|
|
5437
|
+
React2.useLayoutEffect(() => {
|
|
5438
|
+
if (!ListHeaderComponent) {
|
|
5439
|
+
setHeaderSize(ctx, 0);
|
|
5185
5440
|
}
|
|
5186
|
-
if (
|
|
5187
|
-
|
|
5188
|
-
ctx,
|
|
5189
|
-
stickyHeaderIndicesArr,
|
|
5190
|
-
scroll,
|
|
5191
|
-
drawDistance,
|
|
5192
|
-
(_s = stickyState == null ? void 0 : stickyState.currentStickyIdx) != null ? _s : -1,
|
|
5193
|
-
pendingRemoval,
|
|
5194
|
-
alwaysRenderSet
|
|
5195
|
-
);
|
|
5441
|
+
if (!ListFooterComponent) {
|
|
5442
|
+
updateFooterSize(0);
|
|
5196
5443
|
}
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
const
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
}
|
|
5444
|
+
}, [ListHeaderComponent, ListFooterComponent, ctx, updateFooterSize]);
|
|
5445
|
+
const onLayoutHeader = React2.useCallback(
|
|
5446
|
+
(rect) => {
|
|
5447
|
+
const size = rect[horizontal ? "width" : "height"];
|
|
5448
|
+
setHeaderSize(ctx, size);
|
|
5449
|
+
},
|
|
5450
|
+
[ctx, horizontal]
|
|
5451
|
+
);
|
|
5452
|
+
const onLayoutFooterInternal = React2.useCallback(
|
|
5453
|
+
(rect, fromLayoutEffect) => {
|
|
5454
|
+
const size = rect[horizontal ? "width" : "height"];
|
|
5455
|
+
updateFooterSize(size, () => {
|
|
5456
|
+
onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
|
|
5457
|
+
});
|
|
5458
|
+
},
|
|
5459
|
+
[horizontal, onLayoutFooter, updateFooterSize]
|
|
5460
|
+
);
|
|
5461
|
+
return /* @__PURE__ */ React2__namespace.createElement(
|
|
5462
|
+
SnapOrScroll,
|
|
5463
|
+
{
|
|
5464
|
+
...rest,
|
|
5465
|
+
...ScrollComponent === ListComponentScrollView ? { useWindowScroll } : {},
|
|
5466
|
+
contentContainerStyle: [
|
|
5467
|
+
horizontal ? {
|
|
5468
|
+
height: "100%"
|
|
5469
|
+
} : {},
|
|
5470
|
+
contentContainerStyle
|
|
5471
|
+
],
|
|
5472
|
+
contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
5473
|
+
horizontal,
|
|
5474
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition.size || maintainVisibleContentPosition.data ? { minIndexForVisible: 0 } : void 0,
|
|
5475
|
+
onLayout,
|
|
5476
|
+
onScroll: onScroll2,
|
|
5477
|
+
ref: refScrollView,
|
|
5478
|
+
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
5479
|
+
style: autoOtherAxisStyle ? [autoOtherAxisStyle, style] : style
|
|
5480
|
+
},
|
|
5481
|
+
/* @__PURE__ */ React2__namespace.createElement(ScrollAdjust, null),
|
|
5482
|
+
ListHeaderComponent && /* @__PURE__ */ React2__namespace.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
5483
|
+
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
5484
|
+
shouldRenderAlignItemsAtEndSpacer && /* @__PURE__ */ React2__namespace.createElement(AlignItemsAtEndSpacer, { horizontal }),
|
|
5485
|
+
canRender && !ListEmptyComponent && /* @__PURE__ */ React2__namespace.createElement(
|
|
5486
|
+
Containers,
|
|
5487
|
+
{
|
|
5488
|
+
getRenderedItem: getRenderedItem2,
|
|
5489
|
+
horizontal,
|
|
5490
|
+
ItemSeparatorComponent,
|
|
5491
|
+
recycleItems,
|
|
5492
|
+
stickyHeaderConfig
|
|
5223
5493
|
}
|
|
5494
|
+
),
|
|
5495
|
+
ListFooterComponent && /* @__PURE__ */ React2__namespace.createElement(LayoutView, { onLayoutChange: onLayoutFooterInternal, style: ListFooterComponentStyle }, getComponent(ListFooterComponent)),
|
|
5496
|
+
Platform.OS === "web" && /* @__PURE__ */ React2__namespace.createElement(WebAnchoredEndSpace, { horizontal }),
|
|
5497
|
+
IS_DEV && ENABLE_DEVMODE
|
|
5498
|
+
);
|
|
5499
|
+
});
|
|
5500
|
+
var WEB_UNBOUNDED_HEIGHT_MIN_DATA_LENGTH = 100;
|
|
5501
|
+
var WEB_UNBOUNDED_HEIGHT_CONTAINER_RATIO = 0.9;
|
|
5502
|
+
var WEB_UNBOUNDED_HEIGHT_VIEWPORT_RATIO = 0.9;
|
|
5503
|
+
function useDevChecksImpl(props) {
|
|
5504
|
+
const ctx = useStateContext();
|
|
5505
|
+
const { childrenMode, keyExtractor, renderScrollComponent, useWindowScroll } = props;
|
|
5506
|
+
React2.useEffect(() => {
|
|
5507
|
+
if (useWindowScroll && renderScrollComponent) {
|
|
5508
|
+
warnDevOnce(
|
|
5509
|
+
"useWindowScrollRenderScrollComponent",
|
|
5510
|
+
"useWindowScroll is not supported when renderScrollComponent is provided."
|
|
5511
|
+
);
|
|
5224
5512
|
}
|
|
5225
|
-
|
|
5226
|
-
|
|
5513
|
+
}, [renderScrollComponent, useWindowScroll]);
|
|
5514
|
+
React2.useEffect(() => {
|
|
5515
|
+
if (!keyExtractor && !ctx.state.isFirst && ctx.state.didDataChange && !childrenMode) {
|
|
5516
|
+
warnDevOnce(
|
|
5517
|
+
"keyExtractor",
|
|
5518
|
+
"Changing data without a keyExtractor can cause slow performance and resetting scroll. If your list data can change you should use a keyExtractor with a unique id for best performance and behavior."
|
|
5519
|
+
);
|
|
5227
5520
|
}
|
|
5228
|
-
|
|
5229
|
-
|
|
5521
|
+
}, [childrenMode, ctx, keyExtractor]);
|
|
5522
|
+
React2.useEffect(() => {
|
|
5523
|
+
const state = ctx.state;
|
|
5524
|
+
const dataLength = state.props.data.length;
|
|
5525
|
+
const useWindowScrollResolved = state.props.useWindowScroll;
|
|
5526
|
+
if (Platform.OS !== "web" || useWindowScrollResolved || dataLength < WEB_UNBOUNDED_HEIGHT_MIN_DATA_LENGTH) {
|
|
5230
5527
|
return;
|
|
5231
5528
|
}
|
|
5232
|
-
|
|
5233
|
-
const
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5529
|
+
const warnIfUnboundedOuterSize = () => {
|
|
5530
|
+
const readyToRender = peek$(ctx, "readyToRender");
|
|
5531
|
+
const numContainers = peek$(ctx, "numContainers") || 0;
|
|
5532
|
+
const totalSize = peek$(ctx, "totalSize") || 0;
|
|
5533
|
+
const scrollLength = ctx.state.scrollLength || 0;
|
|
5534
|
+
if (!readyToRender || totalSize <= 0 || scrollLength <= 0) {
|
|
5535
|
+
return;
|
|
5237
5536
|
}
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
if (
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
viewabilityConfigCallbackPairs,
|
|
5245
|
-
scrollLength,
|
|
5246
|
-
visibleRange.startNoBuffer,
|
|
5247
|
-
visibleRange.endNoBuffer,
|
|
5248
|
-
startBuffered != null ? startBuffered : visibleRange.startNoBuffer,
|
|
5249
|
-
endBuffered != null ? endBuffered : visibleRange.endNoBuffer
|
|
5537
|
+
const rendersAlmostEverything = numContainers >= Math.ceil(dataLength * WEB_UNBOUNDED_HEIGHT_CONTAINER_RATIO);
|
|
5538
|
+
const viewportMatchesContent = scrollLength >= totalSize * WEB_UNBOUNDED_HEIGHT_VIEWPORT_RATIO;
|
|
5539
|
+
if (rendersAlmostEverything && viewportMatchesContent) {
|
|
5540
|
+
warnDevOnce(
|
|
5541
|
+
"webUnboundedOuterSize",
|
|
5542
|
+
"LegendList appears to have an unbounded outer height on web, so virtualization is effectively disabled. Set a bounded height or flex: 1 on the list container, or use useWindowScroll."
|
|
5250
5543
|
);
|
|
5251
5544
|
}
|
|
5252
|
-
}
|
|
5253
|
-
(
|
|
5254
|
-
|
|
5545
|
+
};
|
|
5546
|
+
warnIfUnboundedOuterSize();
|
|
5547
|
+
const unsubscribe = [
|
|
5548
|
+
listen$(ctx, "numContainers", warnIfUnboundedOuterSize),
|
|
5549
|
+
listen$(ctx, "readyToRender", warnIfUnboundedOuterSize),
|
|
5550
|
+
listen$(ctx, "totalSize", warnIfUnboundedOuterSize)
|
|
5551
|
+
];
|
|
5552
|
+
return () => {
|
|
5553
|
+
for (const unsub of unsubscribe) {
|
|
5554
|
+
unsub();
|
|
5555
|
+
}
|
|
5556
|
+
};
|
|
5557
|
+
}, [ctx]);
|
|
5558
|
+
}
|
|
5559
|
+
function useDevChecksNoop(_props) {
|
|
5255
5560
|
}
|
|
5561
|
+
var useDevChecks = IS_DEV ? useDevChecksImpl : useDevChecksNoop;
|
|
5256
5562
|
|
|
5257
5563
|
// src/core/checkResetContainers.ts
|
|
5258
5564
|
function checkResetContainers(ctx, dataProp, { didColumnsChange = false } = {}) {
|
|
@@ -5574,61 +5880,6 @@ var ScrollAdjustHandler = class {
|
|
|
5574
5880
|
}
|
|
5575
5881
|
};
|
|
5576
5882
|
|
|
5577
|
-
// src/core/updateAnchoredEndSpace.ts
|
|
5578
|
-
function maybeUpdateAnchoredEndSpace(ctx) {
|
|
5579
|
-
var _a3, _b;
|
|
5580
|
-
const state = ctx.state;
|
|
5581
|
-
const anchoredEndSpace = state.props.anchoredEndSpace;
|
|
5582
|
-
const previousSize = peek$(ctx, "anchoredEndSpaceSize");
|
|
5583
|
-
const previousReadyAnchorIndex = state.anchoredEndSpaceReadyAnchorIndex;
|
|
5584
|
-
const previousReadyAnchorKey = state.anchoredEndSpaceReadyAnchorKey;
|
|
5585
|
-
const nextAnchorIndex = anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex;
|
|
5586
|
-
let nextAnchorKey;
|
|
5587
|
-
let isReady = true;
|
|
5588
|
-
let nextSize = 0;
|
|
5589
|
-
if (anchoredEndSpace) {
|
|
5590
|
-
const { anchorIndex, anchorMaxSize, anchorOffset = 0 } = anchoredEndSpace;
|
|
5591
|
-
const { data } = state.props;
|
|
5592
|
-
if (anchorIndex >= 0 && anchorIndex < data.length && state.scrollLength > 0) {
|
|
5593
|
-
nextAnchorKey = getId(state, anchorIndex);
|
|
5594
|
-
let contentBelowAnchor = 0;
|
|
5595
|
-
const footerSize = ctx.values.get("footerSize") || 0;
|
|
5596
|
-
const stylePaddingBottom = state.props.stylePaddingBottom || 0;
|
|
5597
|
-
let hasUnknownTailSize = false;
|
|
5598
|
-
for (let index = anchorIndex; index < data.length; index++) {
|
|
5599
|
-
const size = getKnownOrFixedItemSize(ctx, index);
|
|
5600
|
-
const effectiveSize = index === anchorIndex && anchorMaxSize !== void 0 ? Math.min(size || 0, Math.max(0, anchorMaxSize)) : size;
|
|
5601
|
-
if (size === void 0) {
|
|
5602
|
-
hasUnknownTailSize = true;
|
|
5603
|
-
}
|
|
5604
|
-
if (effectiveSize !== null && effectiveSize !== void 0 && effectiveSize > 0) {
|
|
5605
|
-
contentBelowAnchor += effectiveSize;
|
|
5606
|
-
}
|
|
5607
|
-
}
|
|
5608
|
-
contentBelowAnchor += footerSize + stylePaddingBottom;
|
|
5609
|
-
isReady = !hasUnknownTailSize;
|
|
5610
|
-
nextSize = hasUnknownTailSize ? previousSize || 0 : Math.max(0, state.scrollLength - contentBelowAnchor - anchorOffset);
|
|
5611
|
-
} else if (anchorIndex >= 0) {
|
|
5612
|
-
isReady = false;
|
|
5613
|
-
}
|
|
5614
|
-
}
|
|
5615
|
-
const didSizeChange = previousSize !== nextSize;
|
|
5616
|
-
const didReadyAnchorChange = previousReadyAnchorIndex !== nextAnchorIndex || previousReadyAnchorKey !== nextAnchorKey;
|
|
5617
|
-
if (isReady && (didSizeChange || didReadyAnchorChange)) {
|
|
5618
|
-
state.anchoredEndSpaceReadyAnchorIndex = nextAnchorIndex;
|
|
5619
|
-
state.anchoredEndSpaceReadyAnchorKey = nextAnchorKey;
|
|
5620
|
-
if (didSizeChange) {
|
|
5621
|
-
set$(ctx, "anchoredEndSpaceSize", nextSize);
|
|
5622
|
-
(_a3 = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onSizeChanged) == null ? void 0 : _a3.call(anchoredEndSpace, nextSize);
|
|
5623
|
-
}
|
|
5624
|
-
if (didSizeChange && (anchoredEndSpace == null ? void 0 : anchoredEndSpace.includeInEndInset)) {
|
|
5625
|
-
updateScroll(ctx, state.scroll, true);
|
|
5626
|
-
}
|
|
5627
|
-
(_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
|
|
5628
|
-
}
|
|
5629
|
-
return nextSize;
|
|
5630
|
-
}
|
|
5631
|
-
|
|
5632
5883
|
// src/core/updateContentInsetEndAdjustment.ts
|
|
5633
5884
|
function updateContentInsetEndAdjustment(ctx, previousContentInsetEndAdjustment) {
|
|
5634
5885
|
const state = ctx.state;
|
|
@@ -5644,173 +5895,6 @@ function updateContentInsetEndAdjustment(ctx, previousContentInsetEndAdjustment)
|
|
|
5644
5895
|
}
|
|
5645
5896
|
}
|
|
5646
5897
|
}
|
|
5647
|
-
|
|
5648
|
-
// src/core/updateItemSize.ts
|
|
5649
|
-
function runOrScheduleMVCPRecalculate(ctx) {
|
|
5650
|
-
var _a3;
|
|
5651
|
-
const state = ctx.state;
|
|
5652
|
-
if (state.userScrollAnchorReset !== void 0) {
|
|
5653
|
-
calculateItemsInView(ctx);
|
|
5654
|
-
if (((_a3 = state.userScrollAnchorReset) == null ? void 0 : _a3.keys.size) === 0) {
|
|
5655
|
-
state.userScrollAnchorReset = void 0;
|
|
5656
|
-
}
|
|
5657
|
-
} else if (Platform.OS === "web") {
|
|
5658
|
-
if (!state.mvcpAnchorLock) {
|
|
5659
|
-
if (state.queuedMVCPRecalculate !== void 0) {
|
|
5660
|
-
cancelAnimationFrame(state.queuedMVCPRecalculate);
|
|
5661
|
-
state.queuedMVCPRecalculate = void 0;
|
|
5662
|
-
}
|
|
5663
|
-
calculateItemsInView(ctx, { doMVCP: true });
|
|
5664
|
-
} else if (state.queuedMVCPRecalculate === void 0) {
|
|
5665
|
-
state.queuedMVCPRecalculate = requestAnimationFrame(() => {
|
|
5666
|
-
state.queuedMVCPRecalculate = void 0;
|
|
5667
|
-
calculateItemsInView(ctx, { doMVCP: true });
|
|
5668
|
-
});
|
|
5669
|
-
}
|
|
5670
|
-
} else {
|
|
5671
|
-
calculateItemsInView(ctx, { doMVCP: true });
|
|
5672
|
-
}
|
|
5673
|
-
}
|
|
5674
|
-
function updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal) {
|
|
5675
|
-
const state = ctx.state;
|
|
5676
|
-
if (state.needsOtherAxisSize) {
|
|
5677
|
-
const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
|
|
5678
|
-
const currentOtherAxisSize = peek$(ctx, "otherAxisSize");
|
|
5679
|
-
if (!currentOtherAxisSize || otherAxisSize > currentOtherAxisSize) {
|
|
5680
|
-
set$(ctx, "otherAxisSize", otherAxisSize);
|
|
5681
|
-
}
|
|
5682
|
-
}
|
|
5683
|
-
}
|
|
5684
|
-
function updateItemSize(ctx, itemKey, sizeObj) {
|
|
5685
|
-
var _a3;
|
|
5686
|
-
const state = ctx.state;
|
|
5687
|
-
const userScrollAnchorReset = state.userScrollAnchorReset;
|
|
5688
|
-
const didMeasureUserScrollAnchorResetItem = !!(userScrollAnchorReset == null ? void 0 : userScrollAnchorReset.keys.delete(itemKey));
|
|
5689
|
-
const {
|
|
5690
|
-
didContainersLayout,
|
|
5691
|
-
sizesKnown,
|
|
5692
|
-
props: { getFixedItemSize, getItemType, horizontal, onItemSizeChanged, data, maintainScrollAtEnd }
|
|
5693
|
-
} = state;
|
|
5694
|
-
if (!data) return;
|
|
5695
|
-
const index = state.indexByKey.get(itemKey);
|
|
5696
|
-
let resolvedMeasurementItem;
|
|
5697
|
-
if (getFixedItemSize) {
|
|
5698
|
-
if (index === void 0) {
|
|
5699
|
-
return;
|
|
5700
|
-
}
|
|
5701
|
-
const itemData = state.props.data[index];
|
|
5702
|
-
if (itemData === void 0) {
|
|
5703
|
-
return;
|
|
5704
|
-
}
|
|
5705
|
-
const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
|
|
5706
|
-
const size2 = getFixedItemSize(itemData, index, type);
|
|
5707
|
-
resolvedMeasurementItem = {
|
|
5708
|
-
didResolveFixedItemSize: true,
|
|
5709
|
-
fixedItemSize: size2,
|
|
5710
|
-
itemData,
|
|
5711
|
-
itemType: type
|
|
5712
|
-
};
|
|
5713
|
-
if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
|
|
5714
|
-
updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
|
|
5715
|
-
return;
|
|
5716
|
-
}
|
|
5717
|
-
}
|
|
5718
|
-
let needsRecalculate = !didContainersLayout;
|
|
5719
|
-
let shouldMaintainScrollAtEnd = false;
|
|
5720
|
-
let minIndexSizeChanged;
|
|
5721
|
-
const prevSizeKnown = state.sizesKnown.get(itemKey);
|
|
5722
|
-
const diff = updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem);
|
|
5723
|
-
const size = roundSize(horizontal ? sizeObj.width : sizeObj.height);
|
|
5724
|
-
if (diff !== 0) {
|
|
5725
|
-
minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
|
|
5726
|
-
const { startBuffered, endBuffered } = state;
|
|
5727
|
-
needsRecalculate || (needsRecalculate = index >= startBuffered && index <= endBuffered);
|
|
5728
|
-
if (!needsRecalculate && state.containerItemKeys.has(itemKey)) {
|
|
5729
|
-
needsRecalculate = true;
|
|
5730
|
-
}
|
|
5731
|
-
if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
|
|
5732
|
-
shouldMaintainScrollAtEnd = true;
|
|
5733
|
-
}
|
|
5734
|
-
onItemSizeChanged == null ? void 0 : onItemSizeChanged({
|
|
5735
|
-
index,
|
|
5736
|
-
itemData: state.props.data[index],
|
|
5737
|
-
itemKey,
|
|
5738
|
-
previous: size - diff,
|
|
5739
|
-
size
|
|
5740
|
-
});
|
|
5741
|
-
maybeUpdateAnchoredEndSpace(ctx);
|
|
5742
|
-
}
|
|
5743
|
-
if (minIndexSizeChanged !== void 0) {
|
|
5744
|
-
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
|
|
5745
|
-
}
|
|
5746
|
-
updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
|
|
5747
|
-
if (didContainersLayout || checkAllSizesKnown(state, state.startBuffered, state.endBuffered)) {
|
|
5748
|
-
if (needsRecalculate) {
|
|
5749
|
-
state.scrollForNextCalculateItemsInView = void 0;
|
|
5750
|
-
runOrScheduleMVCPRecalculate(ctx);
|
|
5751
|
-
} else if (didMeasureUserScrollAnchorResetItem && (userScrollAnchorReset == null ? void 0 : userScrollAnchorReset.keys.size) === 0) {
|
|
5752
|
-
state.userScrollAnchorReset = void 0;
|
|
5753
|
-
}
|
|
5754
|
-
if (shouldMaintainScrollAtEnd) {
|
|
5755
|
-
if (maintainScrollAtEnd == null ? void 0 : maintainScrollAtEnd.onItemLayout) {
|
|
5756
|
-
doMaintainScrollAtEnd(ctx);
|
|
5757
|
-
}
|
|
5758
|
-
}
|
|
5759
|
-
}
|
|
5760
|
-
}
|
|
5761
|
-
function updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem) {
|
|
5762
|
-
var _a3, _b, _c;
|
|
5763
|
-
const state = ctx.state;
|
|
5764
|
-
const {
|
|
5765
|
-
indexByKey,
|
|
5766
|
-
sizesKnown,
|
|
5767
|
-
averageSizes,
|
|
5768
|
-
props: { data, horizontal, getItemType, getFixedItemSize }
|
|
5769
|
-
} = state;
|
|
5770
|
-
if (!data) return 0;
|
|
5771
|
-
const index = indexByKey.get(itemKey);
|
|
5772
|
-
const itemData = (_a3 = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.itemData) != null ? _a3 : data[index];
|
|
5773
|
-
let itemType = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.itemType;
|
|
5774
|
-
let fixedItemSize = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.fixedItemSize;
|
|
5775
|
-
if (getFixedItemSize && !(resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize)) {
|
|
5776
|
-
itemType = getItemType ? (_b = getItemType(itemData, index)) != null ? _b : "" : "";
|
|
5777
|
-
fixedItemSize = getFixedItemSize(itemData, index, itemType);
|
|
5778
|
-
}
|
|
5779
|
-
const resolvedItemSize = (resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize) || itemType !== void 0 || fixedItemSize !== void 0 ? {
|
|
5780
|
-
didResolveFixedItemSize: resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize,
|
|
5781
|
-
fixedItemSize,
|
|
5782
|
-
itemType
|
|
5783
|
-
} : void 0;
|
|
5784
|
-
const prevSize = getItemSize(ctx, itemKey, index, itemData, void 0, void 0, void 0, resolvedItemSize);
|
|
5785
|
-
const rawSize = horizontal ? sizeObj.width : sizeObj.height;
|
|
5786
|
-
const prevSizeKnown = sizesKnown.get(itemKey);
|
|
5787
|
-
if (Platform.OS !== "web" && prevSizeKnown !== void 0 && isNativeLayoutNoise(rawSize - prevSizeKnown)) {
|
|
5788
|
-
return 0;
|
|
5789
|
-
}
|
|
5790
|
-
const size = Platform.OS === "web" ? Math.round(rawSize) : roundSize(rawSize);
|
|
5791
|
-
sizesKnown.set(itemKey, size);
|
|
5792
|
-
if (fixedItemSize === void 0 && size > 0) {
|
|
5793
|
-
itemType != null ? itemType : itemType = getItemType ? (_c = getItemType(itemData, index)) != null ? _c : "" : "";
|
|
5794
|
-
let averages = averageSizes[itemType];
|
|
5795
|
-
if (!averages) {
|
|
5796
|
-
averages = averageSizes[itemType] = { avg: 0, num: 0 };
|
|
5797
|
-
}
|
|
5798
|
-
if (averages.num === 0) {
|
|
5799
|
-
averages.avg = size;
|
|
5800
|
-
averages.num++;
|
|
5801
|
-
} else if (prevSizeKnown !== void 0 && prevSizeKnown > 0) {
|
|
5802
|
-
averages.avg += (size - prevSizeKnown) / averages.num;
|
|
5803
|
-
} else {
|
|
5804
|
-
averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
|
|
5805
|
-
averages.num++;
|
|
5806
|
-
}
|
|
5807
|
-
}
|
|
5808
|
-
if (!prevSize || Math.abs(prevSize - size) > 0.1) {
|
|
5809
|
-
setSize(ctx, itemKey, size);
|
|
5810
|
-
return size - prevSize;
|
|
5811
|
-
}
|
|
5812
|
-
return 0;
|
|
5813
|
-
}
|
|
5814
5898
|
function useWrapIfItem(fn) {
|
|
5815
5899
|
return React2.useMemo(
|
|
5816
5900
|
() => fn ? (arg1, arg2, arg3) => arg1 !== void 0 && arg2 !== void 0 ? fn(arg1, arg2, arg3) : void 0 : void 0,
|
|
@@ -6131,7 +6215,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
|
|
|
6131
6215
|
return true;
|
|
6132
6216
|
}),
|
|
6133
6217
|
setItemSize: (itemKey, size) => {
|
|
6134
|
-
|
|
6218
|
+
updateItemSizes(ctx, { itemKey, size });
|
|
6135
6219
|
},
|
|
6136
6220
|
setScrollProcessingEnabled: (enabled) => {
|
|
6137
6221
|
state.scrollProcessingEnabled = enabled;
|
|
@@ -6358,7 +6442,7 @@ var LegendList = typedMemo(
|
|
|
6358
6442
|
})
|
|
6359
6443
|
);
|
|
6360
6444
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
6361
|
-
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
6445
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
6362
6446
|
const noopOnScroll = React2.useCallback((_event) => {
|
|
6363
6447
|
}, []);
|
|
6364
6448
|
if (props.recycleItems === void 0) {
|
|
@@ -6413,6 +6497,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6413
6497
|
onStartReached,
|
|
6414
6498
|
onStartReachedThreshold = 0.5,
|
|
6415
6499
|
onStickyHeaderChange,
|
|
6500
|
+
onFirstVisibleItemChanged,
|
|
6416
6501
|
onViewableItemsChanged,
|
|
6417
6502
|
progressViewOffset,
|
|
6418
6503
|
recycleItems = false,
|
|
@@ -6514,6 +6599,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6514
6599
|
if (!refState.current) {
|
|
6515
6600
|
if (!ctx.state) {
|
|
6516
6601
|
const initialScrollLength = (estimatedListSize != null ? estimatedListSize : IsNewArchitecture ? { height: 0, width: 0 } : getWindowSize())[horizontal ? "width" : "height"];
|
|
6602
|
+
ctx.values.set("adaptiveRender", (_l = experimental_adaptiveRender == null ? void 0 : experimental_adaptiveRender.initialMode) != null ? _l : "normal");
|
|
6517
6603
|
ctx.state = {
|
|
6518
6604
|
averageSizes: {},
|
|
6519
6605
|
columnSpans: [],
|
|
@@ -6591,6 +6677,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6591
6677
|
}
|
|
6592
6678
|
const state = refState.current;
|
|
6593
6679
|
const isFirstLocal = state.isFirst;
|
|
6680
|
+
const previousAdaptiveRender = state.props.adaptiveRender;
|
|
6594
6681
|
const previousNumColumnsProp = state.props.numColumns;
|
|
6595
6682
|
const didScrollAxisGapChange = !isFirstLocal && ctx.scrollAxisGap !== nextScrollAxisGap;
|
|
6596
6683
|
ctx.scrollAxisGap = nextScrollAxisGap;
|
|
@@ -6598,7 +6685,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6598
6685
|
const didDataReferenceChangeLocal = state.props.data !== dataProp;
|
|
6599
6686
|
const didDataVersionChangeLocal = state.props.dataVersion !== dataVersion;
|
|
6600
6687
|
const didDataChangeLocal = didDataVersionChangeLocal || didDataReferenceChangeLocal && checkStructuralDataChange(state, dataProp, state.props.data);
|
|
6601
|
-
if (didDataChangeLocal && !initialScrollAtEnd && state.didFinishInitialScroll && ((
|
|
6688
|
+
if (didDataChangeLocal && !initialScrollAtEnd && state.didFinishInitialScroll && ((_m = state.initialScroll) == null ? void 0 : _m.viewPosition) === 1 && state.props.data.length > 0) {
|
|
6602
6689
|
clearPreservedInitialScrollTarget(state);
|
|
6603
6690
|
}
|
|
6604
6691
|
if (didDataChangeLocal) {
|
|
@@ -6610,7 +6697,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6610
6697
|
const throttledOnScroll = useThrottledOnScroll(onScrollProp != null ? onScrollProp : noopOnScroll, scrollEventThrottle != null ? scrollEventThrottle : 0);
|
|
6611
6698
|
const throttleScrollFn = scrollEventThrottle && onScrollProp ? throttledOnScroll : onScrollProp;
|
|
6612
6699
|
const anchoredEndSpaceResolved = Platform.OS === "web" && anchoredEndSpace ? { ...anchoredEndSpace, includeInEndInset: true } : anchoredEndSpace;
|
|
6613
|
-
const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((
|
|
6700
|
+
const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_n = state.props.anchoredEndSpace) == null ? void 0 : _n.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
|
|
6614
6701
|
state.props = {
|
|
6615
6702
|
adaptiveRender: experimental_adaptiveRender,
|
|
6616
6703
|
alignItemsAtEnd,
|
|
@@ -6638,6 +6725,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6638
6725
|
numColumns: numColumnsProp,
|
|
6639
6726
|
onEndReached,
|
|
6640
6727
|
onEndReachedThreshold,
|
|
6728
|
+
onFirstVisibleItemChanged,
|
|
6641
6729
|
onItemSizeChanged,
|
|
6642
6730
|
onLoad,
|
|
6643
6731
|
onScroll: throttleScrollFn,
|
|
@@ -6660,6 +6748,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6660
6748
|
useWindowScroll: useWindowScrollResolved
|
|
6661
6749
|
};
|
|
6662
6750
|
state.refScroller = refScroller;
|
|
6751
|
+
if (!isFirstLocal && previousAdaptiveRender && !experimental_adaptiveRender) {
|
|
6752
|
+
resetAdaptiveRender(ctx);
|
|
6753
|
+
}
|
|
6663
6754
|
const memoizedLastItemKeys = React2.useMemo(() => {
|
|
6664
6755
|
if (!dataProp.length) return [];
|
|
6665
6756
|
return Array.from(
|
|
@@ -6904,8 +6995,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6904
6995
|
onMomentumScrollEnd(event);
|
|
6905
6996
|
}
|
|
6906
6997
|
},
|
|
6907
|
-
onScroll: (event) => onScroll(ctx, event)
|
|
6908
|
-
updateItemSize: (itemKey, sizeObj) => updateItemSize(ctx, itemKey, sizeObj)
|
|
6998
|
+
onScroll: (event) => onScroll(ctx, event)
|
|
6909
6999
|
}),
|
|
6910
7000
|
[]
|
|
6911
7001
|
);
|
|
@@ -6932,7 +7022,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6932
7022
|
onScroll: onScrollHandler,
|
|
6933
7023
|
recycleItems,
|
|
6934
7024
|
refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2__namespace.cloneElement(refreshControlElement, {
|
|
6935
|
-
progressViewOffset: ((
|
|
7025
|
+
progressViewOffset: ((_o = refreshControlElement.props.progressViewOffset) != null ? _o : 0) + stylePaddingTopState
|
|
6936
7026
|
}) : refreshControlElement : onRefresh && /* @__PURE__ */ React2__namespace.createElement(
|
|
6937
7027
|
ReactNative.RefreshControl,
|
|
6938
7028
|
{
|
|
@@ -6943,12 +7033,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
6943
7033
|
),
|
|
6944
7034
|
refScrollView: combinedRef,
|
|
6945
7035
|
renderScrollComponent,
|
|
6946
|
-
scrollAdjustHandler: (
|
|
7036
|
+
scrollAdjustHandler: (_p = refState.current) == null ? void 0 : _p.scrollAdjustHandler,
|
|
6947
7037
|
scrollEventThrottle: 0,
|
|
6948
7038
|
snapToIndices,
|
|
6949
7039
|
stickyHeaderIndices,
|
|
6950
7040
|
style,
|
|
6951
|
-
updateItemSize: fns.updateItemSize,
|
|
6952
7041
|
useWindowScroll: useWindowScrollResolved
|
|
6953
7042
|
}
|
|
6954
7043
|
), IS_DEV && ENABLE_DEBUG_VIEW);
|