cogsbox-state 0.5.372 → 0.5.374
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 +375 -373
- package/dist/CogsState.jsx.map +1 -1
- package/package.json +1 -1
- package/src/CogsState.tsx +7 -3
package/package.json
CHANGED
package/src/CogsState.tsx
CHANGED
|
@@ -1824,7 +1824,7 @@ function createProxyHandler<T>(
|
|
|
1824
1824
|
endIndex: 10,
|
|
1825
1825
|
});
|
|
1826
1826
|
const [status, setStatus] = useState<Status>("IDLE_AT_TOP");
|
|
1827
|
-
|
|
1827
|
+
const isProgrammaticScroll = useRef(false);
|
|
1828
1828
|
const prevTotalCountRef = useRef(0);
|
|
1829
1829
|
const prevDepsRef = useRef(dependencies);
|
|
1830
1830
|
|
|
@@ -1962,6 +1962,7 @@ function createProxyHandler<T>(
|
|
|
1962
1962
|
console.log(
|
|
1963
1963
|
"ACTION (SCROLLING_TO_BOTTOM): Executing scroll."
|
|
1964
1964
|
);
|
|
1965
|
+
isProgrammaticScroll.current = true;
|
|
1965
1966
|
// Use 'auto' for initial load, 'smooth' for new messages.
|
|
1966
1967
|
const scrollBehavior =
|
|
1967
1968
|
prevTotalCountRef.current === 0 ? "auto" : "smooth";
|
|
@@ -1976,6 +1977,7 @@ function createProxyHandler<T>(
|
|
|
1976
1977
|
console.log(
|
|
1977
1978
|
"ACTION (SCROLLING_TO_BOTTOM): Scroll finished -> LOCKED_AT_BOTTOM"
|
|
1978
1979
|
);
|
|
1980
|
+
isProgrammaticScroll.current = false;
|
|
1979
1981
|
shouldNotScroll.current = false;
|
|
1980
1982
|
setStatus("LOCKED_AT_BOTTOM");
|
|
1981
1983
|
},
|
|
@@ -2000,7 +2002,9 @@ function createProxyHandler<T>(
|
|
|
2000
2002
|
|
|
2001
2003
|
const handleUserScroll = () => {
|
|
2002
2004
|
// This is the core logic you wanted.
|
|
2003
|
-
|
|
2005
|
+
if (isProgrammaticScroll.current) {
|
|
2006
|
+
return;
|
|
2007
|
+
}
|
|
2004
2008
|
const isAtBottom =
|
|
2005
2009
|
container.scrollHeight -
|
|
2006
2010
|
container.scrollTop -
|
|
@@ -2011,7 +2015,7 @@ function createProxyHandler<T>(
|
|
|
2011
2015
|
console.log(
|
|
2012
2016
|
"USER ACTION: Scrolled up -> IDLE_NOT_AT_BOTTOM"
|
|
2013
2017
|
);
|
|
2014
|
-
|
|
2018
|
+
shouldNotScroll.current = true;
|
|
2015
2019
|
setStatus("IDLE_NOT_AT_BOTTOM");
|
|
2016
2020
|
} else {
|
|
2017
2021
|
shouldNotScroll.current = false;
|