@lexriver/dome 1.5.7 → 1.5.10

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/README.md CHANGED
@@ -1506,7 +1506,11 @@ Parameters:
1506
1506
 
1507
1507
  Where `RouteAction` type is:
1508
1508
  ```typescript
1509
- export type RouteAction = (params:{[key:string]:string}, url:string) => void|Promise<void>
1509
+ export type RouteAction = (
1510
+ params:{[key:string]:string}, // parameters from url
1511
+ url:string,
1512
+ scrollToPreviousPositionAsync:()=>Promise<void> // this function can be called to scroll to previous page position
1513
+ ) => void|Promise<void>
1510
1514
  ```
1511
1515
 
1512
1516
  example:
@@ -1,6 +1,6 @@
1
1
  export declare type RouteAction = (params: {
2
2
  [key: string]: string;
3
- }, url: string, scrollToPreviousPositionFunctionAsync: () => Promise<void>) => void | Promise<void>;
3
+ }, url: string, scrollToPreviousPositionAsync: () => Promise<void>) => void | Promise<void>;
4
4
  export declare module DomeRouter {
5
5
  let maxHistoryUrlsCount: number;
6
6
  function navigate(url: string): void;
@@ -13,7 +13,7 @@ export declare module DomeRouter {
13
13
  * @param previousPageIndex 0=previousPage, 1=previousPage-1, etc
14
14
  */
15
15
  function getPreviousPageUrl(previousPageIndex?: number): string | undefined;
16
- function resolveUrl(url?: string): void;
16
+ function resolveUrl(url?: string, addToHistory?: boolean): void;
17
17
  function onRoute(route: string, exactMatch: boolean, action: RouteAction): void;
18
18
  function onNotFound(action: () => void): void;
19
19
  /**
package/out/DomeRouter.js CHANGED
@@ -83,9 +83,10 @@ export var DomeRouter;
83
83
  // if(addToHistory) addUrlToHistory(url)
84
84
  // executeAsync(url, getScrollPositionForUrl(url)) // TODO: check
85
85
  // }
86
- function resolveUrl(url = window.location.pathname) {
87
- // if(addToHistory) addUrlToHistory(window.location.pathname)
88
- executeAsync(url, getScrollPositionForUrl(url)); // TODO: check
86
+ function resolveUrl(url = window.location.pathname, addToHistory = true) {
87
+ if (addToHistory)
88
+ addUrlToHistory(window.location.pathname);
89
+ executeAsync(url, getScrollPositionForUrl(url));
89
90
  }
90
91
  DomeRouter.resolveUrl = resolveUrl;
91
92
  function onRoute(route, exactMatch, action) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "sideEffects": false,
4
4
  "name": "@lexriver/dome",
5
- "version": "1.5.7",
5
+ "version": "1.5.10",
6
6
  "description": "",
7
7
  "main": "out/index.js",
8
8
  "types": "out/index.d.ts",
package/src/DomeRouter.ts CHANGED
@@ -5,7 +5,7 @@ const filename = '[DomeRouter]'
5
5
  export type RouteAction = (
6
6
  params:{[key:string]:string},
7
7
  url:string,
8
- scrollToPreviousPositionFunctionAsync:()=>Promise<void>
8
+ scrollToPreviousPositionAsync:()=>Promise<void>
9
9
  ) => void|Promise<void>
10
10
 
11
11
  interface Route{
@@ -84,8 +84,8 @@ export module DomeRouter {
84
84
  historyUrls[historyUrls.length-2].scroll = DomeManipulator.getCurrentScrollPosition()
85
85
  }
86
86
 
87
- console.log('adding url to history', url)
88
- console.log('historyUrls=', historyUrls)
87
+ // console.log('adding url to history', url)
88
+ // console.log('historyUrls=', historyUrls)
89
89
  }
90
90
 
91
91
 
@@ -112,9 +112,9 @@ export module DomeRouter {
112
112
  // executeAsync(url, getScrollPositionForUrl(url)) // TODO: check
113
113
  // }
114
114
 
115
- export function resolveUrl(url:string = window.location.pathname){
116
- // if(addToHistory) addUrlToHistory(window.location.pathname)
117
- executeAsync(url, getScrollPositionForUrl(url)) // TODO: check
115
+ export function resolveUrl(url:string = window.location.pathname, addToHistory = true){
116
+ if(addToHistory) addUrlToHistory(window.location.pathname)
117
+ executeAsync(url, getScrollPositionForUrl(url))
118
118
  }
119
119
 
120
120
  export function onRoute(route:string, exactMatch:boolean, action:RouteAction){