diff --git a/pages/post/_id.vue b/pages/post/_id.vue index 56eaff2..a9b5140 100644 --- a/pages/post/_id.vue +++ b/pages/post/_id.vue @@ -1327,7 +1327,7 @@ modal background-color #000 padding 10px box-shadow 0 0 8px #000 - z-index 999 + z-index 99999 padding-bottom 20px min-width 240px max-width 300px diff --git a/plugins/browser.js b/plugins/browser.js index 4a37ceb..8e9ab97 100644 --- a/plugins/browser.js +++ b/plugins/browser.js @@ -2,11 +2,11 @@ import '~/layouts/common.styl' import vditor from 'vditor' import 'vditor/dist/index.css' -// const $tags = document.getElementById('tags') -// let floatTop = null -// if ($tags) { -// floatTop = $tags.offsetTop + $tags.scrollHeight + 30 -// } +const $tags = document.getElementById('tags') +let floatTop = null +if ($tags) { + floatTop = $tags.offsetTop + $tags.scrollHeight + 30 +} function addEvent (obj, type, fn) { if (obj.attachEvent) { @@ -25,35 +25,35 @@ window.onload = function () { alert('您的浏览器版本过低,继续访问将会出现问题,请升级浏览器版本!') // eslint-disable-line } - // // 底部返回顶部按钮 - // const top = document.getElementById('gotop') - // if (top) { - // // 滚动一屏幕时显示回到顶部 - // addEvent(window, 'scroll', function () { - // const currentPosition = document.documentElement.scrollTop || document.body.scrollTop - // currentPosition > window.screen.availHeight ? top.style.display = 'block' : top.style.display = 'none' + // 底部返回顶部按钮 + const top = document.getElementById('gotop') + if (top) { + // 滚动一屏幕时显示回到顶部 + addEvent(window, 'scroll', function () { + const currentPosition = document.documentElement.scrollTop || document.body.scrollTop + currentPosition > window.screen.availHeight ? top.style.display = 'block' : top.style.display = 'none' - // // 左部导航自动浮动 - // if (currentPosition > floatTop && document.body.clientWidth > 768) { - // document.getElementById('navication').style.position = 'fixed' - // } else { - // document.getElementById('navication').style.position = 'static' - // } - // }) + // 左部导航自动浮动 + if (currentPosition > floatTop && document.body.clientWidth > 768) { + document.getElementById('navication').style.position = 'fixed' + } else { + document.getElementById('navication').style.position = 'static' + } + }) - // top.onclick = function () { - // var timer = setInterval(function () { // eslint-disable-line - // let currentPosition = document.documentElement.scrollTop || document.body.scrollTop - // currentPosition -= 100 - // if (currentPosition > 0) { - // window.scrollTo(0, currentPosition) - // } else { - // window.scrollTo(0, 0) - // clearInterval(timer) - // } - // }, 10) - // } - // } + top.onclick = function () { + var timer = setInterval(function () { // eslint-disable-line + let currentPosition = document.documentElement.scrollTop || document.body.scrollTop + currentPosition -= 100 + if (currentPosition > 0) { + window.scrollTo(0, currentPosition) + } else { + window.scrollTo(0, 0) + clearInterval(timer) + } + }, 10) + } + } let _hmt = _hmt || [] // eslint-disable-line const hm = document.createElement('script')