cogsbox-state 0.5.370 → 0.5.372
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/dist/CogsState.jsx +395 -395
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +25 -16
package/package.json
CHANGED
package/src/CogsState.tsx
CHANGED
|
@@ -1817,6 +1817,7 @@ function createProxyHandler<T>(
|
|
|
1817
1817
|
| "LOCKED_AT_BOTTOM"
|
|
1818
1818
|
| "IDLE_NOT_AT_BOTTOM";
|
|
1819
1819
|
|
|
1820
|
+
const shouldNotScroll = useRef(false);
|
|
1820
1821
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
1821
1822
|
const [range, setRange] = useState({
|
|
1822
1823
|
startIndex: 0,
|
|
@@ -1948,10 +1949,13 @@ function createProxyHandler<T>(
|
|
|
1948
1949
|
|
|
1949
1950
|
if (lastItemHeight > 0) {
|
|
1950
1951
|
clearInterval(intervalId);
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1952
|
+
if (!shouldNotScroll.current) {
|
|
1953
|
+
console.log(
|
|
1954
|
+
"ACTION (GETTING_HEIGHTS): Measurement success -> SCROLLING_TO_BOTTOM"
|
|
1955
|
+
);
|
|
1956
|
+
|
|
1957
|
+
setStatus("SCROLLING_TO_BOTTOM");
|
|
1958
|
+
}
|
|
1955
1959
|
}
|
|
1956
1960
|
}, 100);
|
|
1957
1961
|
} else if (status === "SCROLLING_TO_BOTTOM") {
|
|
@@ -1972,6 +1976,7 @@ function createProxyHandler<T>(
|
|
|
1972
1976
|
console.log(
|
|
1973
1977
|
"ACTION (SCROLLING_TO_BOTTOM): Scroll finished -> LOCKED_AT_BOTTOM"
|
|
1974
1978
|
);
|
|
1979
|
+
shouldNotScroll.current = false;
|
|
1975
1980
|
setStatus("LOCKED_AT_BOTTOM");
|
|
1976
1981
|
},
|
|
1977
1982
|
scrollBehavior === "smooth" ? 500 : 50
|
|
@@ -1995,19 +2000,23 @@ function createProxyHandler<T>(
|
|
|
1995
2000
|
|
|
1996
2001
|
const handleUserScroll = () => {
|
|
1997
2002
|
// This is the core logic you wanted.
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2003
|
+
|
|
2004
|
+
const isAtBottom =
|
|
2005
|
+
container.scrollHeight -
|
|
2006
|
+
container.scrollTop -
|
|
2007
|
+
container.clientHeight <
|
|
2008
|
+
1;
|
|
2009
|
+
|
|
2010
|
+
if (!isAtBottom) {
|
|
2011
|
+
console.log(
|
|
2012
|
+
"USER ACTION: Scrolled up -> IDLE_NOT_AT_BOTTOM"
|
|
2013
|
+
);
|
|
2014
|
+
|
|
2015
|
+
setStatus("IDLE_NOT_AT_BOTTOM");
|
|
2016
|
+
} else {
|
|
2017
|
+
shouldNotScroll.current = false;
|
|
2010
2018
|
}
|
|
2019
|
+
|
|
2011
2020
|
// We always update the range, regardless of state.
|
|
2012
2021
|
// This is the full, non-placeholder function.
|
|
2013
2022
|
const { scrollTop, clientHeight } = container;
|