fix: 通过attr设置style添加important强制隐藏
- 使用attr方法直接修改style属性 - 添加!important确保优先级最高 - 移除调试日志,保持代码简洁 - 这是最终解决方案
This commit is contained in:
@@ -2832,25 +2832,10 @@ $(document).pjax("a[href]:not([no-pjax]):not(.no-pjax):not([target='_blank']):no
|
|||||||
$card.addClass("post-pjax-loading");
|
$card.addClass("post-pjax-loading");
|
||||||
$("#main").addClass("post-list-pjax-loading");
|
$("#main").addClass("post-list-pjax-loading");
|
||||||
|
|
||||||
// 强制隐藏其他卡片
|
// 强制隐藏其他卡片 - 使用attr设置style以添加!important
|
||||||
$(".post-preview").not($card).css("opacity", "0");
|
$(".post-preview").not($card).each(function() {
|
||||||
|
$(this).attr('style', ($(this).attr('style') || '') + ' opacity: 0 !important; pointer-events: none !important;');
|
||||||
// 调试信息
|
|
||||||
console.log("=== 文章加载动画调试 ===");
|
|
||||||
console.log("点击的卡片:", $card[0]);
|
|
||||||
console.log("#main 是否有 post-list-pjax-loading 类:", $("#main").hasClass("post-list-pjax-loading"));
|
|
||||||
console.log("页面中 .post-preview 总数:", $(".post-preview").length);
|
|
||||||
console.log("应该隐藏的 .post-preview 数量:", $("#main.post-list-pjax-loading .post-preview").length);
|
|
||||||
console.log("被点击的卡片是否有 post-pjax-loading 类:", $card.hasClass("post-pjax-loading"));
|
|
||||||
|
|
||||||
// 检查CSS是否生效
|
|
||||||
setTimeout(function() {
|
|
||||||
$(".post-preview").each(function(index) {
|
|
||||||
let opacity = $(this).css("opacity");
|
|
||||||
let hasLoadingClass = $(this).hasClass("post-pjax-loading");
|
|
||||||
console.log(`卡片 ${index}: opacity=${opacity}, hasLoadingClass=${hasLoadingClass}`);
|
|
||||||
});
|
});
|
||||||
}, 100);
|
|
||||||
|
|
||||||
let offsetTop = $($card).offset().top - $("#main").offset().top;
|
let offsetTop = $($card).offset().top - $("#main").offset().top;
|
||||||
if ($("html").hasClass("is-home") && $("html").hasClass("banner-as-cover")){
|
if ($("html").hasClass("is-home") && $("html").hasClass("banner-as-cover")){
|
||||||
|
|||||||
Reference in New Issue
Block a user