1. Feature: the sidebar can auto scroll when the toc out of the screen

2. Fix: When the picture is loaded, the picture appears black frame
This commit is contained in:
hwy0127@gmail.com
2019-07-29 21:36:42 +08:00
Unverified
parent 6c59f72ca2
commit 49a9995a3d
6 changed files with 87 additions and 64 deletions

View File

@@ -1,3 +1,4 @@
if site.categories.length
.card_widget.card-categories .card_widget.card-categories
.card-content .card-content
.item_headline .item_headline

View File

@@ -1,3 +1,4 @@
if site.tags.length
.card_widget.card-tags .card_widget.card-tags
.card-content .card-content
.item_headline .item_headline

View File

@@ -351,3 +351,8 @@ table
position: fixed position: fixed
z-index: -1 z-index: -1
pointer-events: none pointer-events: none
//
img[src=""],img:not([src])
opacity: 0

View File

@@ -285,6 +285,7 @@ $(function () {
$(".toggle-menu *").css({ 'background-color': '#3b3a3a', 'text-shadow': 'none' }); $(".toggle-menu *").css({ 'background-color': '#3b3a3a', 'text-shadow': 'none' });
$('body').addClass("is_hidden"); $('body').addClass("is_hidden");
$('.menus').addClass("menu_open"); $('.menus').addClass("menu_open");
fixbg_menu();
} else { } else {
$(".toggle-menu").removeClass("close").addClass("open"); $(".toggle-menu").removeClass("close").addClass("open");
$("#page-header #site-name,#page-header .search").css({ 'color': '', 'text-shadow': '' }); $("#page-header #site-name,#page-header .search").css({ 'color': '', 'text-shadow': '' });
@@ -298,6 +299,7 @@ $(function () {
} }
}) })
function fixbg_menu() {
const fixScroll = (scrollEl) => { const fixScroll = (scrollEl) => {
let startY let startY
scrollEl.addEventListener('touchstart', function (event) { scrollEl.addEventListener('touchstart', function (event) {
@@ -333,6 +335,8 @@ $(function () {
} }
const scrollEl = document.querySelector(".menus"); const scrollEl = document.querySelector(".menus");
fixScroll(scrollEl) fixScroll(scrollEl)
}
$(window).on('resize', function (e) { $(window).on('resize', function (e) {
@@ -515,6 +519,18 @@ $(function () {
// Hide their respective list of subsections // Hide their respective list of subsections
.find('.toc-child').hide() .find('.toc-child').hide()
} }
if ($('.toc-link').hasClass('active')){
var active_position = $(".active").offset().top;
var sidebar_scrolltop = $("#sidebar").scrollTop();
if (active_position > (top + $(window).height() - 50)) {
$("#sidebar").scrollTop(sidebar_scrolltop + 100);
} else if (active_position < top + 50)
{
$("#sidebar").scrollTop(sidebar_scrolltop - 100);
}
}
} }
//代碼框雙擊全屏 //代碼框雙擊全屏