aberdeen 1.1.0 → 1.3.0

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/src/route.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import {clean, getParentElement, $, proxy, runQueue, unproxy, copy, merge, clone, leakScope} from "./aberdeen.js";
2
2
 
3
- type NavType = "load" | "back" | "forward" | "go";
3
+ type NavType = "load" | "back" | "forward" | "go" | "push";
4
4
 
5
5
  /**
6
6
  * The class for the global `route` object.
@@ -22,6 +22,7 @@ export interface Route {
22
22
  - `"load"`: An initial page load.
23
23
  - `"back"` or `"forward"`: When we navigated backwards or forwards in the stack.
24
24
  - `"go"`: When we added a new page on top of the stack.
25
+ - `"push"`: When we added a new page on top of the stack, merging with the current page.
25
26
  Mostly useful for page transition animations. Writing to this property has no effect.
26
27
  */
27
28
  nav: NavType;
@@ -147,15 +148,15 @@ function targetToPartial(target: RouteTarget) {
147
148
  * route.go({p: ["users", 123], search: {tab: "feed"}, hash: "top"});
148
149
  * ```
149
150
  */
150
- export function go(target: RouteTarget): void {
151
+ export function go(target: RouteTarget, nav: NavType = "go"): void {
151
152
  const stack: string[] = history.state?.stack || [];
152
153
 
153
154
  prevStack = stack.concat(JSON.stringify(unproxy(current)));
154
155
 
155
- const newRoute: Route = toCanonRoute(targetToPartial(target), "go", prevStack.length + 1);
156
+ const newRoute: Route = toCanonRoute(targetToPartial(target), nav, prevStack.length + 1);
156
157
  copy(current, newRoute);
157
158
 
158
- log('go', newRoute);
159
+ log(nav, newRoute);
159
160
  history.pushState({state: newRoute.state, stack: prevStack}, "", getUrl(newRoute));
160
161
 
161
162
  runQueue();