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:
reco_luan 2020-04-05 22:51:17 +08:00 committed by GitHub
commit 46756fb526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,7 +53,32 @@ export default {
}
},
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,