element-vir - v26.14.0
    Preparing search index...

    Variable onResizeConst

    onResize: (
        ...values: [callback: OnResizeCallback],
    ) => DirectiveResult<typeof __class> = ...

    A directive that fires its listener any time the element that it's attached to is resized. This uses the built-in ResizeObserver API, so it is very efficient.

    Type Declaration

      • (...values: [callback: OnResizeCallback]): DirectiveResult<typeof __class>
      • Parameters

        Returns DirectiveResult<typeof __class>

    import {html, defineElement, onResize} from 'element-vir';

    const MyElement = defineElement()({
    tagName: 'my-element',
    render() {
    return html`
    <div
    ${onResize((size, element) => {
    console.log('resized!', element, size);
    })}
    >
    Some div
    </div>
    `;
    },
    });