@twinfinity/core
    Preparing search index...

    Class BoundingClientRectCache

    Cache for bounding client rectangles. This is useful when cost of HTMLElement.getBoundingClientRect() becomes a problem (it causes browser reflow which in some situations can be very costly). By caching the information from the DOMRect, this cost can be avoided.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Get or add a DOMRectCached instance for a specified element.

      Parameters

      • element: HTMLElement

        HTMLElement to get a DOMRectCached instance for.

      • timeInMsToNextRefresh: number = 300

        Optional. Defaults to 300. If the instance, returned by this method, already exists in the cache. Then DOMRectCached.refresh method on the instance is called automatically if

        1. timeInMsToNextRefresh = 0. Useful when DOMRectCached should be refreshed immediatly.
        2. timeInMsToNextRefresh > 0 && performance.now() - instance.lastRefreshInMs > timeInMsToNextRefresh

        This means that if timeInMsToNextRefresh < 0 then DOMRectCached.refresh will never be called. This can be useful when we never want to refresh the DOMRectCached instance.

      Returns DOMRectCached

      A DOMRectCached element.