File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
docs/.vuepress/theme/components Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 2
2
<script >
3
3
export default {
4
4
methods: {
5
- scrollTop : function () {
5
+ scrollTop : function () {
6
6
// FireFox has a problem setting the correct scroll postion on route change this patch will fix it for now
7
7
if (navigator .userAgent .toLowerCase ().indexOf (' firefox' ) > - 1 ) {
8
8
window .scrollTo (0 , 0 )
@@ -13,8 +13,24 @@ export default {
13
13
}
14
14
},
15
15
watch: {
16
- ' $route.path ' : function (path ) {
16
+ ' $route.path ' : function (path ) {
17
17
this .scrollTop ()
18
+ },
19
+ $route : function () {
20
+ // activates on every route change
21
+ const items = document .querySelectorAll (' .sidebar-links .active' )
22
+ if (items .length && document .documentElement .scrollIntoView ) {
23
+ const lastItem = items .item (items .length - 1 )
24
+ try {
25
+ lastItem .scrollIntoView ({
26
+ behavior: ' smooth' ,
27
+ block: ' center' ,
28
+ inline: ' nearest'
29
+ })
30
+ } catch (e) {
31
+ lastItem .scrollIntoView (false )
32
+ }
33
+ }
18
34
}
19
35
}
20
36
}
You can’t perform that action at this time.
0 commit comments