eddev 0.1.37 → 0.1.38
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/components/BrowserRouter.js +19 -3
- package/package.json +1 -1
- package/routing/routing.js +10 -0
|
@@ -45,9 +45,12 @@ function BrowserRouter(props) {
|
|
|
45
45
|
hasPopulatedCache = true;
|
|
46
46
|
(0, remoteProps_1.setInitialProps)(url, data);
|
|
47
47
|
}
|
|
48
|
+
(0, react_1.useEffect)(function () {
|
|
49
|
+
history.scrollRestoration = "manual";
|
|
50
|
+
}, []);
|
|
48
51
|
(0, react_1.useEffect)(function () {
|
|
49
52
|
var handle = function (e) {
|
|
50
|
-
setPendingUrl({ popped: true, url: document.location.href });
|
|
53
|
+
setPendingUrl({ popped: true, url: document.location.href, scrollPosition: e.state.scrollPosition });
|
|
51
54
|
};
|
|
52
55
|
window.addEventListener("popstate", handle);
|
|
53
56
|
return function () {
|
|
@@ -64,7 +67,7 @@ function BrowserRouter(props) {
|
|
|
64
67
|
(0, remoteProps_1.fetchProps)(pending.url).then(function (data) {
|
|
65
68
|
var view = views_1.default[data.view];
|
|
66
69
|
var finish = function () {
|
|
67
|
-
var _a;
|
|
70
|
+
var _a, _b;
|
|
68
71
|
setUrl(pending.url);
|
|
69
72
|
setData(data);
|
|
70
73
|
if (data.appData) {
|
|
@@ -76,7 +79,18 @@ function BrowserRouter(props) {
|
|
|
76
79
|
(0, updateHeadTags_1.updateHeadTags)(data.meta.head);
|
|
77
80
|
setIsLoading(false);
|
|
78
81
|
if (!pending.popped) {
|
|
82
|
+
history.replaceState({ scrollPosition: (_b = document.scrollingElement) === null || _b === void 0 ? void 0 : _b.scrollTop }, "", document.location.href);
|
|
79
83
|
history.pushState({}, "", pending.url);
|
|
84
|
+
// if (document.scrollingElement) {
|
|
85
|
+
// console.log("Scroll to top")
|
|
86
|
+
// document.scrollingElement.scrollTop = 0
|
|
87
|
+
// }
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// if (document.scrollingElement) {
|
|
91
|
+
// console.log("Scroll to", pending.scrollPosition)
|
|
92
|
+
// document.scrollingElement.scrollTop = pending.scrollPosition || 0
|
|
93
|
+
// }
|
|
80
94
|
}
|
|
81
95
|
};
|
|
82
96
|
if (view && view.preload) {
|
|
@@ -98,6 +112,8 @@ function BrowserRouter(props) {
|
|
|
98
112
|
if ((0, remoteProps_1.isSameOrigin)(url)) {
|
|
99
113
|
(0, remoteProps_1.fetchProps)(url);
|
|
100
114
|
}
|
|
101
|
-
}, onNavigated: function () {
|
|
115
|
+
}, onNavigated: function () {
|
|
116
|
+
console.log("Navigated");
|
|
117
|
+
} }, { children: props.children }), void 0));
|
|
102
118
|
}
|
|
103
119
|
exports.BrowserRouter = BrowserRouter;
|
package/package.json
CHANGED
package/routing/routing.js
CHANGED
|
@@ -301,6 +301,7 @@ function RouterRoot(props) {
|
|
|
301
301
|
ctx.propagateCandidate(item, ctx.item).then(function () {
|
|
302
302
|
if (!cancelled) {
|
|
303
303
|
ctx.propagateChange(item, true);
|
|
304
|
+
console.log("Really finished");
|
|
304
305
|
}
|
|
305
306
|
});
|
|
306
307
|
return function () {
|
|
@@ -308,6 +309,15 @@ function RouterRoot(props) {
|
|
|
308
309
|
};
|
|
309
310
|
}
|
|
310
311
|
}, [props.url, props.data]);
|
|
312
|
+
// useEffect(() => {
|
|
313
|
+
// return ctx.subscribe((route, status) => {
|
|
314
|
+
// if (status === "active") {
|
|
315
|
+
// if (props.onNavigated) {
|
|
316
|
+
// props.onNavigated(route.pathname)
|
|
317
|
+
// }
|
|
318
|
+
// }
|
|
319
|
+
// })
|
|
320
|
+
// }, [props.onNavigated])
|
|
311
321
|
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: props.children }), void 0);
|
|
312
322
|
}
|
|
313
323
|
exports.RouterRoot = RouterRoot;
|