@legendapp/list 0.5.1 → 0.5.3
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/index.js +26 -14
- package/index.mjs +26 -14
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -541,7 +541,7 @@ var LegendListInner = React7.forwardRef(function LegendListInner2(props, forward
|
|
|
541
541
|
pendingAdjust: 0,
|
|
542
542
|
animFrameLayout: null,
|
|
543
543
|
animFrameTotalSize: null,
|
|
544
|
-
isStartReached:
|
|
544
|
+
isStartReached: true,
|
|
545
545
|
isEndReached: false,
|
|
546
546
|
isAtBottom: false,
|
|
547
547
|
isAtTop: false,
|
|
@@ -776,33 +776,45 @@ var LegendListInner = React7.forwardRef(function LegendListInner2(props, forward
|
|
|
776
776
|
}
|
|
777
777
|
};
|
|
778
778
|
const checkAtBottom = () => {
|
|
779
|
-
|
|
779
|
+
if (!refState.current) {
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
780
782
|
const { scrollLength, scroll, contentSize } = refState.current;
|
|
781
783
|
const distanceFromEnd = contentSize[horizontal ? "width" : "height"] - scroll - scrollLength;
|
|
782
784
|
if (refState.current) {
|
|
783
785
|
refState.current.isAtBottom = distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
|
|
784
786
|
}
|
|
785
|
-
if (onEndReached
|
|
786
|
-
if (
|
|
787
|
-
if (
|
|
787
|
+
if (onEndReached) {
|
|
788
|
+
if (!refState.current.isEndReached) {
|
|
789
|
+
if (distanceFromEnd < onEndReachedThreshold * scrollLength) {
|
|
788
790
|
refState.current.isEndReached = true;
|
|
791
|
+
onEndReached({ distanceFromEnd });
|
|
792
|
+
}
|
|
793
|
+
} else {
|
|
794
|
+
if (distanceFromEnd >= onEndReachedThreshold * scrollLength) {
|
|
795
|
+
refState.current.isEndReached = false;
|
|
789
796
|
}
|
|
790
|
-
onEndReached({ distanceFromEnd });
|
|
791
797
|
}
|
|
792
798
|
}
|
|
793
799
|
};
|
|
794
800
|
const checkAtTop = () => {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
if (refState.current) {
|
|
798
|
-
refState.current.isAtTop = scroll === 0;
|
|
801
|
+
if (!refState.current) {
|
|
802
|
+
return;
|
|
799
803
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
804
|
+
const { scrollLength, scroll } = refState.current;
|
|
805
|
+
const scrollAdjust = peek$(ctx, "scrollAdjust") || 0;
|
|
806
|
+
const distanceFromTop = scroll - scrollAdjust;
|
|
807
|
+
refState.current.isAtTop = distanceFromTop < 0;
|
|
808
|
+
if (onStartReached) {
|
|
809
|
+
if (!refState.current.isStartReached) {
|
|
810
|
+
if (distanceFromTop < onStartReachedThreshold * scrollLength) {
|
|
803
811
|
refState.current.isStartReached = true;
|
|
812
|
+
onStartReached({ distanceFromStart: scroll });
|
|
813
|
+
}
|
|
814
|
+
} else {
|
|
815
|
+
if (distanceFromTop >= onStartReachedThreshold * scrollLength) {
|
|
816
|
+
refState.current.isStartReached = false;
|
|
804
817
|
}
|
|
805
|
-
onStartReached({ distanceFromStart: scroll });
|
|
806
818
|
}
|
|
807
819
|
}
|
|
808
820
|
};
|
package/index.mjs
CHANGED
|
@@ -520,7 +520,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
520
520
|
pendingAdjust: 0,
|
|
521
521
|
animFrameLayout: null,
|
|
522
522
|
animFrameTotalSize: null,
|
|
523
|
-
isStartReached:
|
|
523
|
+
isStartReached: true,
|
|
524
524
|
isEndReached: false,
|
|
525
525
|
isAtBottom: false,
|
|
526
526
|
isAtTop: false,
|
|
@@ -755,33 +755,45 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
755
755
|
}
|
|
756
756
|
};
|
|
757
757
|
const checkAtBottom = () => {
|
|
758
|
-
|
|
758
|
+
if (!refState.current) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
759
761
|
const { scrollLength, scroll, contentSize } = refState.current;
|
|
760
762
|
const distanceFromEnd = contentSize[horizontal ? "width" : "height"] - scroll - scrollLength;
|
|
761
763
|
if (refState.current) {
|
|
762
764
|
refState.current.isAtBottom = distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
|
|
763
765
|
}
|
|
764
|
-
if (onEndReached
|
|
765
|
-
if (
|
|
766
|
-
if (
|
|
766
|
+
if (onEndReached) {
|
|
767
|
+
if (!refState.current.isEndReached) {
|
|
768
|
+
if (distanceFromEnd < onEndReachedThreshold * scrollLength) {
|
|
767
769
|
refState.current.isEndReached = true;
|
|
770
|
+
onEndReached({ distanceFromEnd });
|
|
771
|
+
}
|
|
772
|
+
} else {
|
|
773
|
+
if (distanceFromEnd >= onEndReachedThreshold * scrollLength) {
|
|
774
|
+
refState.current.isEndReached = false;
|
|
768
775
|
}
|
|
769
|
-
onEndReached({ distanceFromEnd });
|
|
770
776
|
}
|
|
771
777
|
}
|
|
772
778
|
};
|
|
773
779
|
const checkAtTop = () => {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
if (refState.current) {
|
|
777
|
-
refState.current.isAtTop = scroll === 0;
|
|
780
|
+
if (!refState.current) {
|
|
781
|
+
return;
|
|
778
782
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
783
|
+
const { scrollLength, scroll } = refState.current;
|
|
784
|
+
const scrollAdjust = peek$(ctx, "scrollAdjust") || 0;
|
|
785
|
+
const distanceFromTop = scroll - scrollAdjust;
|
|
786
|
+
refState.current.isAtTop = distanceFromTop < 0;
|
|
787
|
+
if (onStartReached) {
|
|
788
|
+
if (!refState.current.isStartReached) {
|
|
789
|
+
if (distanceFromTop < onStartReachedThreshold * scrollLength) {
|
|
782
790
|
refState.current.isStartReached = true;
|
|
791
|
+
onStartReached({ distanceFromStart: scroll });
|
|
792
|
+
}
|
|
793
|
+
} else {
|
|
794
|
+
if (distanceFromTop >= onStartReachedThreshold * scrollLength) {
|
|
795
|
+
refState.current.isStartReached = false;
|
|
783
796
|
}
|
|
784
|
-
onStartReached({ distanceFromStart: scroll });
|
|
785
797
|
}
|
|
786
798
|
}
|
|
787
799
|
};
|