diff --git a/src/utils/element.ts b/src/utils/element.ts index 5bd42248..c797101e 100644 --- a/src/utils/element.ts +++ b/src/utils/element.ts @@ -225,4 +225,19 @@ export const getLineElementPath = (element: PPTLineElement) => { return `M${start} C${p1} ${p2} ${end}` } return `M${start} L${end}` +} + +/** + * 判断一个元素是否在可视范围内 + * @param element 元素 + * @param parent 父元素 + */ +export const isElementInViewport = (element: HTMLElement, parent: HTMLElement): boolean => { + const elementRect = element.getBoundingClientRect() + const parentRect = parent.getBoundingClientRect() + + return ( + elementRect.top >= parentRect.top && + elementRect.bottom <= parentRect.bottom + ) } \ No newline at end of file diff --git a/src/views/Editor/Thumbnails/index.vue b/src/views/Editor/Thumbnails/index.vue index 48f1ea33..baae51a9 100644 --- a/src/views/Editor/Thumbnails/index.vue +++ b/src/views/Editor/Thumbnails/index.vue @@ -17,6 +17,7 @@