Skip to content

Commit

Permalink
💄 编辑后表头不固定
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 12, 2023
1 parent c5206f7 commit 21d1a05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/src/protyle/render/av/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void) =
return;
}
const left = e.querySelector(".av__scroll")?.scrollLeft || 0;
const headerTransform = (e.querySelector(".av__row--header") as HTMLElement)?.style.transform;
const footerTransform = (e.querySelector(".av__row--footer") as HTMLElement)?.style.transform;
fetchPost("/api/av/renderAttributeView", {
id: e.getAttribute("data-av-id"),
}, (response) => {
Expand Down Expand Up @@ -182,7 +184,15 @@ ${cell.color ? `color:${cell.color};` : ""}">${text}</div>`;
</div>
</div>`;
e.setAttribute("data-render", "true");
e.querySelector(".av__scroll").scrollLeft = left;
if (left) {
e.querySelector(".av__scroll").scrollLeft = left;
}
if (headerTransform) {
(e.querySelector(".av__row--header") as HTMLElement).style.transform = headerTransform;
}
if (footerTransform) {
(e.querySelector(".av__row--footer") as HTMLElement).style.transform = footerTransform;
}
if (cb) {
cb();
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/protyle/scroll/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
const footerElement = item.querySelector(".av__row--footer") as HTMLElement;
if (footerElement) {
const footerBottom = headerTop + footerElement.parentElement.clientHeight;
const scrollBottom = element.scrollTop + element.clientHeight;
const scrollBottom = element.scrollTop + element.clientHeight + 5;
if (headerTop + 42 + 36 * 2 < scrollBottom && footerBottom > scrollBottom) {
footerElement.style.transform = `translateY(${scrollBottom - footerBottom}px)`;
} else {
Expand Down

0 comments on commit 21d1a05

Please sign in to comment.