fix: 恢复主题 JS 文件
This commit is contained in:
120
argontheme.js
120
argontheme.js
@@ -587,10 +587,18 @@ $(document).on("change" , ".search-filter" , function(e){
|
||||
part1OuterHeight = $leftbarPart1.outerHeight();
|
||||
changeLeftbarStickyStatus();
|
||||
});
|
||||
|
||||
// 防抖处理 MutationObserver
|
||||
let leftbarMutationTimer = null;
|
||||
new MutationObserver(function(){
|
||||
if (leftbarMutationTimer) {
|
||||
clearTimeout(leftbarMutationTimer);
|
||||
}
|
||||
leftbarMutationTimer = setTimeout(function() {
|
||||
part1OffsetTop = $leftbarPart1.offset().top;
|
||||
part1OuterHeight = $leftbarPart1.outerHeight();
|
||||
changeLeftbarStickyStatus();
|
||||
}, 150);
|
||||
}).observe(leftbarPart1, {attributes: true, childList: true, subtree: true});
|
||||
}();
|
||||
|
||||
@@ -616,15 +624,56 @@ if (argonConfig.headroom == "true"){
|
||||
}
|
||||
|
||||
/*瀑布流布局*/
|
||||
let waterflowTimer = null;
|
||||
let waterflowImagesLoaded = false;
|
||||
|
||||
function waterflowInit() {
|
||||
if (argonConfig.waterflow_columns == "1") {
|
||||
return;
|
||||
}
|
||||
$("#main.article-list img").each(function(index, ele){
|
||||
|
||||
// 防抖处理,避免频繁重新计算
|
||||
if (waterflowTimer) {
|
||||
clearTimeout(waterflowTimer);
|
||||
}
|
||||
|
||||
waterflowTimer = setTimeout(function() {
|
||||
waterflowRender();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function waterflowRender() {
|
||||
// 检查图片是否已加载
|
||||
if (!waterflowImagesLoaded) {
|
||||
let images = $("#main.article-list img");
|
||||
let loadedCount = 0;
|
||||
let totalImages = images.length;
|
||||
|
||||
if (totalImages > 0) {
|
||||
images.each(function(index, ele){
|
||||
if (ele.complete) {
|
||||
loadedCount++;
|
||||
} else {
|
||||
ele.onload = function(){
|
||||
waterflowInit();
|
||||
loadedCount++;
|
||||
if (loadedCount === totalImages) {
|
||||
waterflowImagesLoaded = true;
|
||||
waterflowRender();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// 如果所有图片已加载
|
||||
if (loadedCount === totalImages) {
|
||||
waterflowImagesLoaded = true;
|
||||
} else {
|
||||
// 等待图片加载
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let columns;
|
||||
if (argonConfig.waterflow_columns == "2and3") {
|
||||
if ($("#main").outerWidth() > 1000) {
|
||||
@@ -659,14 +708,19 @@ function waterflowInit() {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
$("#primary").css("transition", "none")
|
||||
.addClass("waterflow");
|
||||
|
||||
let $container = $("#main.article-list");
|
||||
if (!$container.length){
|
||||
return;
|
||||
}
|
||||
|
||||
let $items = $container.find("article.post:not(.no-results), .shuoshuo-preview-container");
|
||||
columns = Math.max(Math.min(columns, $items.length), 1);
|
||||
|
||||
// 使用 requestAnimationFrame 优化性能
|
||||
requestAnimationFrame(function() {
|
||||
$("#primary").css("transition", "none").addClass("waterflow");
|
||||
|
||||
if (columns == 1) {
|
||||
$container.removeClass("waterflow");
|
||||
$items.css("transition", "").css("position", "").css("width", "").css("top", "").css("left", "").css("margin", "");
|
||||
@@ -685,19 +739,31 @@ function waterflowInit() {
|
||||
heights[pos] += itemHeight;
|
||||
});
|
||||
}
|
||||
|
||||
if ($(".waterflow-placeholder").length) {
|
||||
$(".waterflow-placeholder").css("height", getMaxHeight() + "px");
|
||||
}else{
|
||||
$container.prepend("<div class='waterflow-placeholder' style='height: " + getMaxHeight() +"px;'></div>");
|
||||
}
|
||||
});
|
||||
}
|
||||
waterflowInit();
|
||||
if (argonConfig.waterflow_columns != "1") {
|
||||
$(window).resize(function(){
|
||||
waterflowInit();
|
||||
});
|
||||
|
||||
// 防抖处理 MutationObserver
|
||||
let waterflowMutationTimer = null;
|
||||
new MutationObserver(function(mutations, observer){
|
||||
if (waterflowMutationTimer) {
|
||||
clearTimeout(waterflowMutationTimer);
|
||||
}
|
||||
waterflowMutationTimer = setTimeout(function() {
|
||||
// 重置图片加载状态,以便重新检查
|
||||
waterflowImagesLoaded = false;
|
||||
waterflowInit();
|
||||
}, 150);
|
||||
}).observe(document.querySelector("#primary"), {
|
||||
'childList': true
|
||||
});
|
||||
@@ -924,8 +990,18 @@ if (argonConfig.waterflow_columns != "1") {
|
||||
}
|
||||
}
|
||||
changefabtnDisplayStatus();
|
||||
|
||||
// 节流处理滚动事件
|
||||
let fabtnScrollTimer = null;
|
||||
let fabtnScrollTicking = false;
|
||||
$(window).scroll(function(){
|
||||
if (!fabtnScrollTicking) {
|
||||
window.requestAnimationFrame(function() {
|
||||
changefabtnDisplayStatus();
|
||||
fabtnScrollTicking = false;
|
||||
});
|
||||
fabtnScrollTicking = true;
|
||||
}
|
||||
});
|
||||
$(window).resize(function(){
|
||||
changefabtnDisplayStatus();
|
||||
@@ -2331,13 +2407,14 @@ function loadImage(img, effect) {
|
||||
// 移除所有 lazyload-style-* 类
|
||||
img.className = img.className.replace(/\blazyload-style-\d+\b/g, '').trim();
|
||||
|
||||
// 应用加载效果
|
||||
// 应用加载效果(使用 requestAnimationFrame 优化性能)
|
||||
requestAnimationFrame(function() {
|
||||
if (effect === 'fadeIn') {
|
||||
img.style.opacity = '0';
|
||||
img.style.transition = 'opacity 0.3s ease';
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(function() {
|
||||
img.style.opacity = '1';
|
||||
}, 10);
|
||||
});
|
||||
setTimeout(function() {
|
||||
img.style.transition = '';
|
||||
}, 310);
|
||||
@@ -2345,15 +2422,16 @@ function loadImage(img, effect) {
|
||||
img.style.opacity = '0';
|
||||
img.style.transform = 'translateY(-20px)';
|
||||
img.style.transition = 'opacity 0.3s ease, transform 0.3s ease';
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(function() {
|
||||
img.style.opacity = '1';
|
||||
img.style.transform = 'translateY(0)';
|
||||
}, 10);
|
||||
});
|
||||
setTimeout(function() {
|
||||
img.style.transition = '';
|
||||
img.style.transform = '';
|
||||
}, 310);
|
||||
}
|
||||
});
|
||||
};
|
||||
tempImg.onerror = function() {
|
||||
// 加载失败时使用原始 src
|
||||
@@ -2417,8 +2495,16 @@ if ($("html").hasClass("banner-as-cover")){
|
||||
}
|
||||
}
|
||||
classInit();
|
||||
|
||||
// 防抖处理 MutationObserver
|
||||
let classInitTimer = null;
|
||||
new MutationObserver(function(mutations, observer){
|
||||
if (classInitTimer) {
|
||||
clearTimeout(classInitTimer);
|
||||
}
|
||||
classInitTimer = setTimeout(function() {
|
||||
classInit();
|
||||
}, 150);
|
||||
}).observe(document.querySelector("#primary"), {
|
||||
'childList': true
|
||||
});
|
||||
@@ -2442,8 +2528,17 @@ if ($("html").hasClass("banner-as-cover")){
|
||||
}
|
||||
}
|
||||
changeWidgetsDisplayStatus();
|
||||
|
||||
// 节流处理滚动事件
|
||||
let widgetsScrollTicking = false;
|
||||
$(window).scroll(function(){
|
||||
if (!widgetsScrollTicking) {
|
||||
window.requestAnimationFrame(function() {
|
||||
changeWidgetsDisplayStatus();
|
||||
widgetsScrollTicking = false;
|
||||
});
|
||||
widgetsScrollTicking = true;
|
||||
}
|
||||
});
|
||||
$(window).resize(function(){
|
||||
changeWidgetsDisplayStatus();
|
||||
@@ -3791,8 +3886,15 @@ void 0;
|
||||
ripple.className = 'touch-ripple';
|
||||
var oldRipple = element.querySelector('.touch-ripple');
|
||||
if (oldRipple) oldRipple.remove();
|
||||
// 只在元素没有 position 样式时才设置,避免布局突变
|
||||
var computedStyle = window.getComputedStyle(element);
|
||||
if (computedStyle.position === 'static') {
|
||||
element.style.position = 'relative';
|
||||
}
|
||||
// 只在元素没有 overflow 样式时才设置,避免内容换行
|
||||
if (computedStyle.overflow === 'visible') {
|
||||
element.style.overflow = 'hidden';
|
||||
}
|
||||
element.appendChild(ripple);
|
||||
setTimeout(function() { ripple.remove(); }, 600);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user