@domql/router 2.3.3 → 2.3.5

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.
Files changed (2) hide show
  1. package/index.js +7 -4
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -11,7 +11,9 @@ export let lastLevel = 0
11
11
  const defaultOptions = {
12
12
  level: lastLevel,
13
13
  pushState: true,
14
- scrollTo: true
14
+ scrollToTop: true,
15
+ scrollToNode: false,
16
+ useFragment: false
15
17
  }
16
18
 
17
19
  export const router = (
@@ -31,16 +33,17 @@ export const router = (
31
33
  if (content) {
32
34
  if (options.pushState) window.history.pushState(state, null, pathname + (hash ? `#${hash}` : ''))
33
35
 
34
- element.set({ extend: content })
36
+ element.set({ tag: options.useFragment && 'fragment', extend: content })
35
37
  element.state.update({ route, hash })
36
38
 
37
39
  const rootNode = element.node
38
- if (options.scrollTo) rootNode.scrollTo({ behavior: 'smooth', top: 0, left: 0 })
40
+ if (options.scrollToTop) rootNode.scrollTo({ behavior: 'smooth', top: 0, left: 0 })
41
+ if (options.scrollToNode) content.content.node.scrollTo({ behavior: 'smooth', top: 0, left: 0 })
39
42
 
40
43
  if (hash) {
41
44
  const activeNode = document.getElementById(hash)
42
45
  if (activeNode) {
43
- const top = activeNode.getBoundingClientRect().top + rootNode.scrollTop - 140
46
+ const top = activeNode.getBoundingClientRect().top + rootNode.scrollToTopp - 140
44
47
  rootNode.scrollTo({ behavior: 'smooth', top, left: 0 })
45
48
  }
46
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/router",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
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": "1f87a922baa3f51543923135ecff36d6f699e9a6",
12
+ "gitHead": "9f1a47a59fa1512a593714401583b8286e6f2bff",
13
13
  "source": "index.js"
14
14
  }