fix: gxnlpt 收起分类时自动滚动到该分类标题
收起后内容高度骤减,用户视野可能停留在下方空白区。 现在收起后 smooth scroll 到当前分类 header (留80px顶栏余量)。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
6967c8adb6
commit
a071be1f41
@ -1155,16 +1155,27 @@ export default {
|
||||
toggleViewMore(category) {
|
||||
const total = category.cardList.length;
|
||||
if (category.visibleCount >= total) {
|
||||
// 已展开到底,收起回到初始预览数
|
||||
// 收起:回到初始预览数,并滚动到当前分类标题
|
||||
category.visibleCount = category.previewSize;
|
||||
this.refreshDisplayList(category);
|
||||
this.$nextTick(() => {
|
||||
const el = document.getElementById(category.id);
|
||||
if (!el) return;
|
||||
const scrollRoot = this.getScrollRoot();
|
||||
if (!scrollRoot) return;
|
||||
const rootRect = scrollRoot.getBoundingClientRect();
|
||||
const elRect = el.getBoundingClientRect();
|
||||
const target = scrollRoot.scrollTop + (elRect.top - rootRect.top) - 80;
|
||||
scrollRoot.scrollTo({ top: Math.max(0, target), behavior: 'smooth' });
|
||||
});
|
||||
} else {
|
||||
// 每次展开 previewSize 个,不超过 total
|
||||
category.visibleCount = Math.min(
|
||||
category.visibleCount + category.previewSize,
|
||||
total,
|
||||
);
|
||||
this.refreshDisplayList(category);
|
||||
}
|
||||
this.refreshDisplayList(category);
|
||||
},
|
||||
async loadAllSections() {
|
||||
this.pageLoading = true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user