@legendapp/list 2.0.0-next.23 → 2.0.0-next.24

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.
Files changed (3) hide show
  1. package/index.js +21 -14
  2. package/index.mjs +21 -14
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -931,14 +931,16 @@ var finishScrollTo = (state) => {
931
931
  // src/core/scrollTo.ts
932
932
  function scrollTo(state, params = {}) {
933
933
  var _a;
934
- const { animated } = params;
934
+ const { animated, noScrollingTo } = params;
935
935
  const {
936
936
  refScroller,
937
937
  props: { horizontal }
938
938
  } = state;
939
939
  const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
940
940
  state.scrollHistory.length = 0;
941
- state.scrollingTo = params;
941
+ if (!noScrollingTo) {
942
+ state.scrollingTo = params;
943
+ }
942
944
  state.scrollPending = offset;
943
945
  (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
944
946
  animated: !!animated,
@@ -952,10 +954,18 @@ function scrollTo(state, params = {}) {
952
954
  }
953
955
 
954
956
  // src/utils/requestAdjust.ts
955
- function requestAdjust(ctx, state, positionDiff) {
957
+ function requestAdjust(ctx, state, positionDiff, dataChanged) {
956
958
  if (Math.abs(positionDiff) > 0.1) {
959
+ const needsScrollWorkaround = reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
957
960
  const doit = () => {
958
- state.scrollAdjustHandler.requestAdjust(positionDiff);
961
+ if (needsScrollWorkaround) {
962
+ scrollTo(state, {
963
+ noScrollingTo: true,
964
+ offset: state.scroll
965
+ });
966
+ } else {
967
+ state.scrollAdjustHandler.requestAdjust(positionDiff);
968
+ }
959
969
  };
960
970
  state.scroll += positionDiff;
961
971
  state.scrollForNextCalculateItemsInView = void 0;
@@ -974,9 +984,12 @@ function requestAdjust(ctx, state, positionDiff) {
974
984
  if (state.ignoreScrollFromMVCPTimeout) {
975
985
  clearTimeout(state.ignoreScrollFromMVCPTimeout);
976
986
  }
977
- state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
978
- state.ignoreScrollFromMVCP = void 0;
979
- }, 100);
987
+ state.ignoreScrollFromMVCPTimeout = setTimeout(
988
+ () => {
989
+ state.ignoreScrollFromMVCP = void 0;
990
+ },
991
+ needsScrollWorkaround ? 250 : 100
992
+ );
980
993
  } else {
981
994
  requestAnimationFrame(doit);
982
995
  }
@@ -1035,13 +1048,7 @@ function prepareMVCP(ctx, state, dataChanged) {
1035
1048
  }
1036
1049
  }
1037
1050
  if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1038
- if (reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
1039
- scrollTo(state, {
1040
- offset: state.scroll + positionDiff
1041
- });
1042
- } else {
1043
- requestAdjust(ctx, state, positionDiff);
1044
- }
1051
+ requestAdjust(ctx, state, positionDiff, dataChanged);
1045
1052
  }
1046
1053
  };
1047
1054
  }
package/index.mjs CHANGED
@@ -910,14 +910,16 @@ var finishScrollTo = (state) => {
910
910
  // src/core/scrollTo.ts
911
911
  function scrollTo(state, params = {}) {
912
912
  var _a;
913
- const { animated } = params;
913
+ const { animated, noScrollingTo } = params;
914
914
  const {
915
915
  refScroller,
916
916
  props: { horizontal }
917
917
  } = state;
918
918
  const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
919
919
  state.scrollHistory.length = 0;
920
- state.scrollingTo = params;
920
+ if (!noScrollingTo) {
921
+ state.scrollingTo = params;
922
+ }
921
923
  state.scrollPending = offset;
922
924
  (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
923
925
  animated: !!animated,
@@ -931,10 +933,18 @@ function scrollTo(state, params = {}) {
931
933
  }
932
934
 
933
935
  // src/utils/requestAdjust.ts
934
- function requestAdjust(ctx, state, positionDiff) {
936
+ function requestAdjust(ctx, state, positionDiff, dataChanged) {
935
937
  if (Math.abs(positionDiff) > 0.1) {
938
+ const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
936
939
  const doit = () => {
937
- state.scrollAdjustHandler.requestAdjust(positionDiff);
940
+ if (needsScrollWorkaround) {
941
+ scrollTo(state, {
942
+ noScrollingTo: true,
943
+ offset: state.scroll
944
+ });
945
+ } else {
946
+ state.scrollAdjustHandler.requestAdjust(positionDiff);
947
+ }
938
948
  };
939
949
  state.scroll += positionDiff;
940
950
  state.scrollForNextCalculateItemsInView = void 0;
@@ -953,9 +963,12 @@ function requestAdjust(ctx, state, positionDiff) {
953
963
  if (state.ignoreScrollFromMVCPTimeout) {
954
964
  clearTimeout(state.ignoreScrollFromMVCPTimeout);
955
965
  }
956
- state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
957
- state.ignoreScrollFromMVCP = void 0;
958
- }, 100);
966
+ state.ignoreScrollFromMVCPTimeout = setTimeout(
967
+ () => {
968
+ state.ignoreScrollFromMVCP = void 0;
969
+ },
970
+ needsScrollWorkaround ? 250 : 100
971
+ );
959
972
  } else {
960
973
  requestAnimationFrame(doit);
961
974
  }
@@ -1014,13 +1027,7 @@ function prepareMVCP(ctx, state, dataChanged) {
1014
1027
  }
1015
1028
  }
1016
1029
  if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1017
- if (Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
1018
- scrollTo(state, {
1019
- offset: state.scroll + positionDiff
1020
- });
1021
- } else {
1022
- requestAdjust(ctx, state, positionDiff);
1023
- }
1030
+ requestAdjust(ctx, state, positionDiff, dataChanged);
1024
1031
  }
1025
1032
  };
1026
1033
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.0.0-next.23",
3
+ "version": "2.0.0-next.24",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,