This commit is contained in:
Van
2019-03-22 17:10:56 +08:00
parent 53f713a45d
commit 32b7923774
15 changed files with 167 additions and 166 deletions

View File

@@ -35,7 +35,7 @@ var Skin = {
$goTop.hide()
}
if ($('.side .b3-solo-list').length > 0) {
if ($('.side .article__toc').length > 0 && $(window).width() > 768) {
if ($(window).scrollTop() > 50) {
$('.side').css('position', 'fixed')
} else {
@@ -80,9 +80,6 @@ var Skin = {
init: function () {
Util.initPjax(function () {
Skin._initAnimation()
if ($('#articlePage').length === 0) {
$('.b3-solo-list').closest('.module').remove()
}
})
Skin._initAnimation()
@@ -105,8 +102,7 @@ var Skin = {
},
_initArticleCommon: function () {
if ($(window).width() > 768) {
if ($('#articlePage .b3-solo-list li').length === 0) {
$('.side .b3-solo-list').closest('.module').remove()
if ($('.article__toc li').length === 0) {
$('.side').css({
height: 'auto',
position: 'initial',
@@ -115,29 +111,15 @@ var Skin = {
}
$('#articlePage').width($('.main').width() - 310)
if ($('.side .b3-solo-list').length === 0) {
$('.side').
prepend('<div class="module"><div class="module__list"></div></div>').
css({
right: ($(window).width() - $('.main').width()) / 2,
position: 'fixed',
overflow: 'auto',
height: $(window).height() - 30,
top: 30,
})
}
$('.side .module:eq(0) .module__list').html($('.b3-solo-list'))
$('.side').css({
right: ($(window).width() - $('.main').width()) / 2,
position: 'fixed',
overflow: 'auto',
height: $(window).height() - 30,
top: 30,
})
$(window).scroll()
$('.side').scrollTop(0)
} else {
if ($('#articlePage .b3-solo-list li').length === 0) {
$('.header__m .icon__list').hide().next().hide()
return
}
$('.header__m .icon__list').show().next().html($('.b3-solo-list'))
$('.b3-solo-list a').click(function () {
$(this).closest('.module__list').hide()
})
}
},
initArticle: function () {

View File

@@ -1 +1 @@
var Skin={_initCommon:function(e){$(window).scroll(function(){125<$(window).scrollTop()?e.show():e.hide(),0<$(".side .b3-solo-list").length&&(50<$(window).scrollTop()?$(".side").css("position","fixed"):$(".side").css("position","initial"))})},_initAnimation:function(){if(!("IntersectionObserver"in window))return $(".item").addClass("item--active"),!1;window.imageIntersectionObserver?window.imageIntersectionObserver.disconnect():window.imageIntersectionObserver=new IntersectionObserver(function(e){e.forEach(function(e){if(void 0===e.isIntersecting?0!==e.intersectionRatio:e.isIntersecting)$(e.target).addClass("item--active");else{if(1===$(e.target).closest(".side").length||1===$(e.target).closest("#articlePage").length||768<$(e.target).outerHeight())return;$(e.target).removeClass("item--active")}})}),$(".item").each(function(){window.imageIntersectionObserver.observe(this)})},init:function(){Util.initPjax(function(){Skin._initAnimation(),0===$("#articlePage").length&&$(".b3-solo-list").closest(".module").remove()}),Skin._initAnimation(),this._initCommon($(".icon__up")),$(".header__nav a, .header__m a").each(function(){this.href===location.href&&(this.className="current")}).click(function(){$(".header__nav a, .header__m a").removeClass("current"),this.className="current",$(".header__m .module__list").hide()}),$(".header__logo").click(function(){$(".header__nav a, .header__m a").removeClass("current")})},_initArticleCommon:function(){if(768<$(window).width()){if(0===$("#articlePage .b3-solo-list li").length)return $(".side .b3-solo-list").closest(".module").remove(),void $(".side").css({height:"auto",position:"initial"});$("#articlePage").width($(".main").width()-310),0===$(".side .b3-solo-list").length&&$(".side").prepend('<div class="module"><div class="module__list"></div></div>').css({right:($(window).width()-$(".main").width())/2,position:"fixed",overflow:"auto",height:$(window).height()-30,top:30}),$(".side .module:eq(0) .module__list").html($(".b3-solo-list")),$(window).scroll(),$(".side").scrollTop(0)}else{if(0===$("#articlePage .b3-solo-list li").length)return void $(".header__m .icon__list").hide().next().hide();$(".header__m .icon__list").show().next().html($(".b3-solo-list")),$(".b3-solo-list a").click(function(){$(this).closest(".module__list").hide()})}},initArticle:function(){this._initArticleCommon(),setTimeout(function(){0===$("#externalRelevantArticlesWrap li").length&&($("#externalRelevantArticlesWrap").next().remove(),$("#externalRelevantArticlesWrap").remove()),0===$("#relevantArticlesWrap li").length&&($("#relevantArticlesWrap").prev().remove(),$("#relevantArticlesWrap").remove()),0===$("#randomArticlesWrap li").length&&($("#randomArticlesWrap").prev().remove(),$("#randomArticlesWrap").remove())},1e3)}};Skin.init();
var Skin={_initCommon:function(e){$(window).scroll(function(){125<$(window).scrollTop()?e.show():e.hide(),0<$(".side .article__toc").length&&(50<$(window).scrollTop()?$(".side").css("position","fixed"):$(".side").css("position","initial"))})},_initAnimation:function(){if(!("IntersectionObserver"in window))return $(".item").addClass("item--active"),!1;window.imageIntersectionObserver?window.imageIntersectionObserver.disconnect():window.imageIntersectionObserver=new IntersectionObserver(function(e){e.forEach(function(e){if(void 0===e.isIntersecting?0!==e.intersectionRatio:e.isIntersecting)$(e.target).addClass("item--active");else{if(1===$(e.target).closest(".side").length||1===$(e.target).closest("#articlePage").length||768<$(e.target).outerHeight())return;$(e.target).removeClass("item--active")}})}),$(".item").each(function(){window.imageIntersectionObserver.observe(this)})},init:function(){Util.initPjax(function(){Skin._initAnimation(),0===$("#articlePage").length&&$(".article__toc").closest(".module").remove()}),Skin._initAnimation(),this._initCommon($(".icon__up")),$(".header__nav a, .header__m a").each(function(){this.href===location.href&&(this.className="current")}).click(function(){$(".header__nav a, .header__m a").removeClass("current"),this.className="current",$(".header__m .module__list").hide()}),$(".header__logo").click(function(){$(".header__nav a, .header__m a").removeClass("current")})},_initArticleCommon:function(){if(768<$(window).width()){if(0===$("#articlePage .article__toc li").length)return $(".side .article__toc").closest(".module").remove(),void $(".side").css({height:"auto",position:"initial"});$("#articlePage").width($(".main").width()-310),0===$(".side .article__toc").length&&$(".side").prepend('<div class="module"><div class="module__list"></div></div>').css({right:($(window).width()-$(".main").width())/2,position:"fixed",overflow:"auto",height:$(window).height()-30,top:30}),$(".side .module:eq(0) .module__list").html($(".article__toc")),$(window).scroll(),$(".side").scrollTop(0)}else{if(0===$("#articlePage .article__toc li").length)return void $(".header__m .icon__list").hide().next().hide();$(".header__m .icon__list").show().next().html($(".article__toc")),$(".article__toc a").click(function(){$(this).closest(".module__list").hide()})}},initArticle:function(){this._initArticleCommon(),setTimeout(function(){0===$("#externalRelevantArticlesWrap li").length&&($("#externalRelevantArticlesWrap").next().remove(),$("#externalRelevantArticlesWrap").remove()),0===$("#relevantArticlesWrap li").length&&($("#relevantArticlesWrap").prev().remove(),$("#relevantArticlesWrap").remove()),0===$("#randomArticlesWrap li").length&&($("#randomArticlesWrap").prev().remove(),$("#randomArticlesWrap").remove())},1e3)}};Skin.init();