Fix featured image toggle

This commit is contained in:
Track3 2019-01-03 18:25:14 +08:00
parent f601584822
commit 334d05e5a1
9 changed files with 24 additions and 31 deletions

View file

@ -65,8 +65,12 @@ const toggleMobileMenu = () => {
// Featured Image Toggle
//
const toggleImg = () => {
document.querySelector('.bg-img').classList.toggle('show-bg-img');
const showImg = () => {
document.querySelector('.bg-img').classList.add('show-bg-img');
}
const hideImg = () => {
document.querySelector('.bg-img').classList.remove('show-bg-img');
}
// ToC Toggle
@ -79,8 +83,8 @@ const toggleToc = () => {
if (header !== null) {
listen('#menu-btn', "click", toggleMobileMenu);
listen('#toc-btn', "click", toggleToc);
listen('#img-btn', "click", toggleImg);
listen('.bg-img', "click", toggleImg);
listen('#img-btn', "click", showImg);
listen('.bg-img', "click", hideImg);
window.addEventListener('scroll', throttle(() => {
autoHideHeader();

View file

@ -447,7 +447,6 @@ p.img-404 {
z-index: -1;
position: fixed;
top: 0;
cursor: pointer;
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
@ -458,6 +457,7 @@ p.img-404 {
.show-bg-img {
z-index: 100;
opacity: 1;
cursor: pointer;
}
.post-header {