Merge pull request #162 from zpj80231/patch-1
fix the sidebar title of beyond the current window that it follows th…
This commit is contained in:
commit
46756fb526
@ -52,8 +52,33 @@ export default {
|
||||
this.refreshIndex()
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.isInViewPortOfOne()
|
||||
},
|
||||
|
||||
updated: function () {
|
||||
this.isInViewPortOfOne()
|
||||
},
|
||||
|
||||
methods: {
|
||||
isInViewPortOfOne () {
|
||||
let siderbarScroll = document.getElementsByClassName("sidebar")[0]
|
||||
let el = document.getElementsByClassName("active sidebar-link")[1]
|
||||
if (el ==null || el.offsetTop == undefined) {
|
||||
el = document.getElementsByClassName("active sidebar-link")[0]
|
||||
}
|
||||
if (el ==null || el.offsetTop == undefined) return
|
||||
|
||||
const viewPortHeight = siderbarScroll.clientHeight || window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
|
||||
let offsetBottom = el.offsetTop + el.offsetHeight
|
||||
let scrollTop = siderbarScroll.scrollTop
|
||||
let isView = (offsetBottom <= viewPortHeight + scrollTop)
|
||||
if (!isView) {
|
||||
siderbarScroll.scrollTop = (offsetBottom+5 - viewPortHeight)
|
||||
}
|
||||
},
|
||||
|
||||
refreshIndex () {
|
||||
const index = resolveOpenGroupIndex(
|
||||
this.$route,
|
||||
|
Loading…
Reference in New Issue
Block a user