Skip to content

Commit

Permalink
fix: fix frameHeight change
Browse files Browse the repository at this point in the history
  • Loading branch information
Tidyzq committed Oct 21, 2022
1 parent 7a491cb commit 0e26311
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/component/recycleScroller/recycleScroller.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// sort by key
let visible: { key: number; index: number; show: boolean }[] = [];
const updateVisible = createRecycleManager()
const updateVisible = createRecycleManager();
const getScrollExtent = () =>
Math.max(0, frameHeight + footerHeight - viewportHeight);
Expand Down Expand Up @@ -137,11 +137,7 @@
refreshScrollbar();
}
function refresh(
items: any[],
scrollTop: number,
viewportHeight: number,
) {
function refresh(items: any[], scrollTop: number, viewportHeight: number) {
let i = 0;
let y = 0;
Expand Down Expand Up @@ -207,6 +203,13 @@
// (window as any)._vcOrigConsole.log("viewport height resize", height);
viewportHeight = height;
let y = 0
for (let i = 0; i < items.length; i += 1) {
y += heightMap[i];
}
frameHeight = Math.max(y, viewportHeight - footerHeight);
frame.style.height = `${frameHeight}px`;
// setTimeout to avoid ResizeObserver loop limit exceeded error
await new Promise((resolve) => setTimeout(resolve, 0));
Expand All @@ -223,6 +226,14 @@
// ;(window as any)._vcOrigConsole.log('footer height resize', height);
// no need to fresh
footerHeight = height;
let y = 0
for (let i = 0; i < items.length; i += 1) {
y += heightMap[i];
}
frameHeight = Math.max(y, viewportHeight - footerHeight);
frame.style.height = `${frameHeight}px`;
if (viewportHeight !== 0) scrollToBottom(isOnBottom && stickToBottom);
refreshScrollbar();
}
Expand Down
1 change: 1 addition & 0 deletions src/core/style/view.less
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
.vc-plugin-box {
display: none;
position: relative;
min-height: 100%;
}
.vc-plugin-box.vc-fixed-height {
height: 100%;
Expand Down

0 comments on commit 0e26311

Please sign in to comment.