@domql/router 2.3.3 → 2.3.4
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/index.js +5 -3
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -11,7 +11,8 @@ export let lastLevel = 0
|
|
|
11
11
|
const defaultOptions = {
|
|
12
12
|
level: lastLevel,
|
|
13
13
|
pushState: true,
|
|
14
|
-
|
|
14
|
+
scrollToTop: true,
|
|
15
|
+
scrollToNode: false
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export const router = (
|
|
@@ -35,12 +36,13 @@ export const router = (
|
|
|
35
36
|
element.state.update({ route, hash })
|
|
36
37
|
|
|
37
38
|
const rootNode = element.node
|
|
38
|
-
if (options.
|
|
39
|
+
if (options.scrollToTop) rootNode.scrollTo({ behavior: 'smooth', top: 0, left: 0 })
|
|
40
|
+
if (options.scrollToNode) content.content.node.scrollTo({ behavior: 'smooth', top: 0, left: 0 })
|
|
39
41
|
|
|
40
42
|
if (hash) {
|
|
41
43
|
const activeNode = document.getElementById(hash)
|
|
42
44
|
if (activeNode) {
|
|
43
|
-
const top = activeNode.getBoundingClientRect().top + rootNode.
|
|
45
|
+
const top = activeNode.getBoundingClientRect().top + rootNode.scrollToTopp - 140
|
|
44
46
|
rootNode.scrollTo({ behavior: 'smooth', top, left: 0 })
|
|
45
47
|
}
|
|
46
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/router",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@domql/utils": "latest"
|
|
11
11
|
},
|
|
12
|
-
"gitHead": "
|
|
12
|
+
"gitHead": "01460bf7ffc27c47ee985dfb593bff8fc9686ede",
|
|
13
13
|
"source": "index.js"
|
|
14
14
|
}
|