diff --git a/src/components/App.tsx b/src/components/App.tsx index 2411c8c45..aed901743 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -189,7 +189,7 @@ import { isArrowKey, KEYS, } from "../keys"; -import { isVisibleElement } from "../element/sizeHelpers"; +import { isElementInViewport } from "../element/sizeHelpers"; import { distance2d, getCornerRadius, @@ -800,7 +800,7 @@ class App extends React.Component { this.state, ); const embedLink = getEmbedLink(toValidURL(el.link || "")); - const isVisible = isVisibleElement( + const isVisible = isElementInViewport( el, normalizedWidth, normalizedHeight, @@ -963,7 +963,7 @@ class App extends React.Component { return this.scene.getNonDeletedFrames().map((f, index) => { if ( !this.canvas || - !isVisibleElement( + !isElementInViewport( f, this.canvas.width / window.devicePixelRatio, this.canvas.height / window.devicePixelRatio, diff --git a/src/element/sizeHelpers.ts b/src/element/sizeHelpers.ts index abc51dc68..1b69ca0bc 100644 --- a/src/element/sizeHelpers.ts +++ b/src/element/sizeHelpers.ts @@ -15,7 +15,7 @@ export const isInvisiblySmallElement = ( return element.width === 0 && element.height === 0; }; -export const isVisibleElement = ( +export const isElementInViewport = ( element: ExcalidrawElement, width: number, height: number, diff --git a/src/scene/Renderer.ts b/src/scene/Renderer.ts index 05c2375bb..42e8c5bbe 100644 --- a/src/scene/Renderer.ts +++ b/src/scene/Renderer.ts @@ -1,4 +1,4 @@ -import { isVisibleElement } from "../element/sizeHelpers"; +import { isElementInViewport } from "../element/sizeHelpers"; import { isImageElement } from "../element/typeChecks"; import { NonDeletedExcalidrawElement } from "../element/types"; import { AppState } from "../types"; @@ -33,7 +33,7 @@ export class Renderer { width: AppState["width"]; }): readonly NonDeletedExcalidrawElement[] => { return elements.filter((element) => - isVisibleElement(element, width, height, { + isElementInViewport(element, width, height, { zoom, offsetLeft, offsetTop,