router-dom
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -42,2 +42,3 @@ export default class Router { | ||
formHandler?(res: Response, e: Event): Promise<any> | void; | ||
scrollBehavior?: ScrollBehavior; | ||
} | ||
@@ -44,0 +45,0 @@ interface RoutingProps { |
@@ -155,2 +155,3 @@ import { pathToRegexp, match } from "path-to-regexp"; | ||
finally { | ||
dispatchEvent(new Event("afterRouting")); | ||
// Reload -> restore scroll position | ||
@@ -160,3 +161,3 @@ if (!this.oldRoute && | ||
sessionStorage.getItem(storageKey)) { | ||
const [x, y] = sessionStorage | ||
const [left, top] = sessionStorage | ||
.getItem(storageKey) | ||
@@ -166,5 +167,8 @@ .split(" ") | ||
sessionStorage.removeItem(storageKey); | ||
scroll(x, y); | ||
scrollTo({ | ||
top, | ||
left, | ||
behavior: this.options.scrollBehavior || "auto", | ||
}); | ||
} | ||
dispatchEvent(new Event("afterRouting")); | ||
} | ||
@@ -171,0 +175,0 @@ } |
{ | ||
"name": "router-dom", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "A lightweight router for everyone", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -60,3 +60,3 @@ # router-dom | ||
You can also specifiy one-level of children.<br> One more interesting property is the `restoreScrollOnReload`. | ||
The second argument is the optional object options: it can take a general errorHandler and a formHandler. If there is a formHandler, form submits will handled via attributes on the form element and fetch. | ||
The second argument is the optional object options: it can take a general errorHandler, a formHandler and the scrollBehavior. If there is a formHandler, form submits will handled via attributes on the form element and fetch. | ||
@@ -63,0 +63,0 @@ ```js |
@@ -181,2 +181,4 @@ import type { MatchResult } from "path-to-regexp"; | ||
} finally { | ||
dispatchEvent(new Event("afterRouting")); | ||
// Reload -> restore scroll position | ||
@@ -188,3 +190,3 @@ if ( | ||
) { | ||
const [x, y] = sessionStorage | ||
const [left, top] = sessionStorage | ||
.getItem(storageKey)! | ||
@@ -194,6 +196,8 @@ .split(" ") | ||
sessionStorage.removeItem(storageKey); | ||
scroll(x, y); | ||
scrollTo({ | ||
top, | ||
left, | ||
behavior: this.options.scrollBehavior || "auto", | ||
}); | ||
} | ||
dispatchEvent(new Event("afterRouting")); | ||
} | ||
@@ -370,2 +374,3 @@ } | ||
formHandler?(res: Response, e: Event): Promise<any> | void; | ||
scrollBehavior?: ScrollBehavior; | ||
} | ||
@@ -372,0 +377,0 @@ interface RoutingProps { |
59362
711