@legendapp/list 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +23 -13
- package/index.mjs +23 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -776,33 +776,43 @@ 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
|
+
refState.current.isAtTop = scroll === 0;
|
|
806
|
+
if (onStartReached) {
|
|
807
|
+
if (!refState.current.isStartReached) {
|
|
808
|
+
if (scroll < onStartReachedThreshold * scrollLength) {
|
|
803
809
|
refState.current.isStartReached = true;
|
|
810
|
+
onStartReached({ distanceFromStart: scroll });
|
|
811
|
+
}
|
|
812
|
+
} else {
|
|
813
|
+
if (scroll >= onStartReachedThreshold * scrollLength) {
|
|
814
|
+
refState.current.isStartReached = false;
|
|
804
815
|
}
|
|
805
|
-
onStartReached({ distanceFromStart: scroll });
|
|
806
816
|
}
|
|
807
817
|
}
|
|
808
818
|
};
|
package/index.mjs
CHANGED
|
@@ -755,33 +755,43 @@ 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
|
+
refState.current.isAtTop = scroll === 0;
|
|
785
|
+
if (onStartReached) {
|
|
786
|
+
if (!refState.current.isStartReached) {
|
|
787
|
+
if (scroll < onStartReachedThreshold * scrollLength) {
|
|
782
788
|
refState.current.isStartReached = true;
|
|
789
|
+
onStartReached({ distanceFromStart: scroll });
|
|
790
|
+
}
|
|
791
|
+
} else {
|
|
792
|
+
if (scroll >= onStartReachedThreshold * scrollLength) {
|
|
793
|
+
refState.current.isStartReached = false;
|
|
783
794
|
}
|
|
784
|
-
onStartReached({ distanceFromStart: scroll });
|
|
785
795
|
}
|
|
786
796
|
}
|
|
787
797
|
};
|