This commit is contained in:
Vanessa 2023-06-08 22:56:52 +08:00
parent c5d6f41805
commit d332328726
4 changed files with 39 additions and 39 deletions

View file

@ -27,7 +27,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
protyle.wysiwyg.element.querySelectorAll(".av").forEach((item: HTMLElement) => {
if (item.parentElement.classList.contains("protyle-wysiwyg")) {
const headerTop = item.offsetTop - 30 + 56; // 30 - 面包屑, 56 - tab+title
const headerElement = item.querySelector(".av__row--header") as HTMLElement
const headerElement = item.querySelector(".av__row--header") as HTMLElement;
if (headerElement) {
if (headerTop < element.scrollTop && headerTop + headerElement.parentElement.clientHeight > element.scrollTop) {
headerElement.style.transform = `translateY(${element.scrollTop - headerTop}px)`;
@ -35,9 +35,9 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
headerElement.style.transform = "";
}
}
const footerElement = item.querySelector(".av__row--footer") as HTMLElement
const footerElement = item.querySelector(".av__row--footer") as HTMLElement;
if (footerElement) {
const footerBottom = headerTop + footerElement.parentElement.clientHeight
const footerBottom = headerTop + footerElement.parentElement.clientHeight;
const scrollBottom = element.scrollTop + element.clientHeight;
if (headerTop + 42 + 36 * 2 < scrollBottom && footerBottom > scrollBottom) {
footerElement.style.transform = `translateY(${scrollBottom - footerBottom}px)`;