Skip to content

Commit 04696fa

Browse files
author
reco_luan
committed
fix(vuepress-theme-reco): fix eslint errors
1 parent c45563d commit 04696fa

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

packages/vuepress-theme-reco/components/SidebarLinks.vue

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,60 +53,62 @@ export default {
5353
}
5454
},
5555
56-
mounted() {
56+
mounted () {
5757
this.activationLink()
5858
this.isInViewPortOfOne()
5959
},
60-
60+
6161
updated: function () {
6262
this.isInViewPortOfOne()
6363
},
6464
6565
methods: {
6666
activationLink () {
67-
let subtitleName = decodeURIComponent(this.$route.fullPath)
68-
if (!subtitleName || subtitleName=='') return
67+
const subtitleName = decodeURIComponent(this.$route.fullPath)
68+
if (!subtitleName || subtitleName == '') return
69+
// eslint-disable-next-line no-undef
6970
const subtitles = [].slice.call(document.querySelectorAll(AHL_SIDEBAR_LINK_SELECTOR))
70-
for(let i = 0; i < subtitles.length; i++) {
71-
if(decodeURIComponent(subtitles[i].getAttribute('href')).indexOf(subtitleName) != -1){
71+
for (let i = 0; i < subtitles.length; i++) {
72+
if (decodeURIComponent(subtitles[i].getAttribute('href')).indexOf(subtitleName) != -1) {
7273
subtitles[i].click()
7374
this.activationAnchor()
7475
return
7576
}
7677
}
7778
},
78-
79-
activationAnchor() {
80-
let anchors = [].slice.call(document.querySelectorAll(AHL_HEADER_ANCHOR_SELECTOR))
81-
.filter(anchor => decodeURIComponent(this.$route.fullPath).indexOf(decodeURIComponent(anchor.hash)) != -1)
82-
if(anchors == null || anchors.length<1 || anchors[0].offsetTop == undefined) return
83-
setTimeout(function(){
79+
80+
activationAnchor () {
81+
// eslint-disable-next-line no-undef
82+
const anchors = [].slice.call(document.querySelectorAll(AHL_HEADER_ANCHOR_SELECTOR))
83+
.filter(anchor => decodeURIComponent(this.$route.fullPath).indexOf(decodeURIComponent(anchor.hash)) != -1)
84+
if (anchors == null || anchors.length < 1 || anchors[0].offsetTop == undefined) return
85+
setTimeout(function () {
8486
window.scrollTo(0, anchors[0].offsetTop + 160)
85-
},100)
87+
}, 100)
8688
},
87-
89+
8890
isInViewPortOfOne () {
89-
let siderbarScroll = document.getElementsByClassName("sidebar")[0]
90-
let el = document.getElementsByClassName("active sidebar-link")[1]
91-
if (el ==null || el == undefined || el.offsetTop == undefined) {
92-
el = document.getElementsByClassName("active sidebar-link")[0]
91+
const siderbarScroll = document.getElementsByClassName('sidebar')[0]
92+
let el = document.getElementsByClassName('active sidebar-link')[1]
93+
if (el == null || el == undefined || el.offsetTop == undefined) {
94+
el = document.getElementsByClassName('active sidebar-link')[0]
9395
}
94-
if (el ==null || el == undefined || el.offsetTop == undefined) return
95-
96+
if (el == null || el == undefined || el.offsetTop == undefined) return
97+
9698
const viewPortHeight = siderbarScroll.clientHeight || window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
97-
let offsetTop = el.offsetTop
98-
let offsetBottom = el.offsetTop + el.offsetHeight
99-
let scrollTop = siderbarScroll.scrollTop
100-
let bottomVisible = (offsetBottom <= viewPortHeight + scrollTop)
99+
const offsetTop = el.offsetTop
100+
const offsetBottom = el.offsetTop + el.offsetHeight
101+
const scrollTop = siderbarScroll.scrollTop
102+
const bottomVisible = (offsetBottom <= viewPortHeight + scrollTop)
101103
if (!bottomVisible) {
102104
siderbarScroll.scrollTop = (offsetBottom + 5 - viewPortHeight)
103105
}
104-
let topVisible = (offsetTop >= scrollTop)
106+
const topVisible = (offsetTop >= scrollTop)
105107
if (!topVisible) {
106108
siderbarScroll.scrollTop = (offsetTop - 5)
107109
}
108110
},
109-
111+
110112
refreshIndex () {
111113
const index = resolveOpenGroupIndex(
112114
this.$route,

0 commit comments

Comments
 (0)