mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
5ae6f7c93f
commit
7579d3e2b3
1 changed files with 27 additions and 19 deletions
|
|
@ -5,6 +5,16 @@ import {onGet} from "../util/onGet";
|
|||
import {isMobile} from "../../util/functions";
|
||||
import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";
|
||||
|
||||
const getOffsetTop = (element: HTMLElement, topElement: HTMLElement) => {
|
||||
let tempElement = element
|
||||
let top = 0
|
||||
while (topElement.contains(tempElement)) {
|
||||
top += tempElement.offsetTop
|
||||
tempElement = tempElement.offsetParent as HTMLElement
|
||||
}
|
||||
return top;
|
||||
}
|
||||
|
||||
let getIndexTimeout: number;
|
||||
export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
||||
let elementRect = element.getBoundingClientRect();
|
||||
|
|
@ -25,8 +35,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 + 43;
|
||||
const headerTop = getOffsetTop(item, element) + 43;
|
||||
const headerElement = item.querySelector(".av__row--header") as HTMLElement;
|
||||
if (headerElement) {
|
||||
if (headerTop < element.scrollTop && headerTop + headerElement.parentElement.clientHeight > element.scrollTop) {
|
||||
|
|
@ -45,7 +54,6 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {
|
|||
footerElement.style.transform = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!protyle.element.classList.contains("block__edit") && !isMobile()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue