Zum Hauptinhalt springen Seitenleiste
Zum Inhaltsverzeichnis springen

    Resize Observer

    <pc-resize-observer> 0.1.0 experimental

    Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

    The Resize Observer component offers a thin, declarative interface to the ResizeObserver API.

    The resize observer will report changes to the dimensions of the elements it wraps through the pc-resize event. When emitted, a collection of ResizeObserverEntry objects will be attached to event.detail that contains the target element and information about its dimensions.

    <div class="resize-observer-overview">
        <pc-resize-observer>
            <span>Resize this box and watch the console ➡️</span>
        </pc-resize-observer>
    </div>
    
    <script>
        const container = document.querySelector(
            ".resize-observer-overview",
        );
        const resizeObserver =
            container.querySelector("pc-resize-observer");
    
        resizeObserver.addEventListener("pc-resize", (event) => {
            console.log(event.detail);
        });
    </script>
    
    <style>
        .resize-observer-overview {
            display: flex;
            align-items: center;
            justify-content: center;
            padding-block: var(--pc-spacing-xxxl);
            padding-inline: var(--pc-spacing-xxl);
            border: var(--pc-border-width-m) dashed
                var(--pc-color-neutral-border-normal);
            border-radius: var(--pc-border-radius-l);
            overflow: auto;
        }
    </style>
    Code Edit

    Properties#

    NameDescriptionReflectsDefault
    disabledDisables the resize observer.
    Type: boolean
    false
    updateComplete A read‐only promise that resolves when the component has finished updating.

    Learn more about attributes and properties.

    Slots#

    NameDescription
    (default)One or more elements to watch for resizing.

    Learn more about using slots.

    Events#

    NameDescriptionEvent detail
    pc-resizeEmitted when the element is resized.{ entries: ResizeObserverEntry[] }

    Learn more about events.

    Importing#

    If you’re using the autoloader or the standard loader, you can skip this section. But if you’re cherry picking, you can use any of the following snippets to import this component.

    CDN (script tag) CDN (import) npm (import)

    To manually import this component from the CDN, copy this code snippet and paste it in your HTML.

    <script type="module" src="https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.3/cdn/components/resize-observer/resize-observer.js"></script>

    To manually import this component from the CDN, copy this code snippet and paste it in your JavaScript file.

    import "https://cdn.jsdelivr.net/npm/placer-toolkit@1.0.0-alpha.3/cdn/components/resize-observer/resize-observer.js";

    To manually import this component from npm, copy this code snippet and paste it in your JavaScript file.

    import "placer-toolkit/dist/components/resize-observer/resize-observer.js";

    Wir würden uns freuen, von dir zu hören. Bitte kontaktiere uns bei Fragen oder Anliegen, die du hast.

    Du kannst uns per E‐Mail unter placer.coc.reports+contact@gmail.com erreichen.

    Wir freuen uns darauf, von dir zu hören!

    Alles klar!
    Gefährliche Lande

    Ui! Du bist in die gefährlichen Lande von Placer Toolkit geraten. Version 0 ist veraltet und entspricht nicht den EU‐Datenschutzstandards, einschließlich DSGVO.

    Willst du die neuesten Kräfte, Sicherheit und Compliance? Bleib bei der aktuellen Version von Placer Toolkit!

    Ups! Aufladen!