Skip to content

Commit

Permalink
fix(web): pass after scroll callback
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Oct 3, 2024
1 parent 3c4e6c3 commit 70c8e2b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
16 changes: 10 additions & 6 deletions patches/@remix-run__react.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ index fbfe1d149da86ecb95341e9a00443b395b875d05..826cabf5a217db7f2d75b72142194217
+ afterScroll?: (x: number, y: number) => void;
}): React.JSX.Element | null;
diff --git a/dist/scroll-restoration.js b/dist/scroll-restoration.js
index b7aa82aeabc7de43007c66c2a15e23c1026ace7e..005593ae155709c1679cae844851cc8c340778d9 100644
index b7aa82aeabc7de43007c66c2a15e23c1026ace7e..e8b68ab4b009233bf16432cfdb7655eebf680ef4 100644
--- a/dist/scroll-restoration.js
+++ b/dist/scroll-restoration.js
@@ -47,6 +47,7 @@ let STORAGE_KEY = "positions";
Expand All @@ -20,17 +20,21 @@ index b7aa82aeabc7de43007c66c2a15e23c1026ace7e..005593ae155709c1679cae844851cc8c
...props
}) {
let {
@@ -79,6 +80,9 @@ function ScrollRestoration({
@@ -79,6 +80,13 @@ function ScrollRestoration({
if (isSpaMode) {
return null;
}
+ if (!import.meta.env.SSR) {
+ window.__afterScroll__ = afterScroll;
+ }
+
+ React__namespace.useEffect(() => {
+ if (window) {
+ window.__afterScroll__ = afterScroll;
+ }
+ });
+
let restoreScroll = ((STORAGE_KEY, restoreKey) => {
if (!window.history.state || !window.history.state.key) {
let key = Math.random().toString(32).slice(2);
@@ -91,6 +95,7 @@ function ScrollRestoration({
@@ -91,6 +99,7 @@ function ScrollRestoration({
let storedY = positions[restoreKey || window.history.state.key];
if (typeof storedY === "number") {
window.scrollTo(0, storedY);
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70c8e2b

Please sign in to comment.