UMD Web Utilities Library
    Preparing search index...

    Function shrinkThenRemove

    • Animates an element shrinking to zero height, then hides it

      Uses requestAnimationFrame to create a smooth height and padding collapse animation. After animation completes, sets display:none and adds a 'closed' attribute. Useful for accordion panels, dropdown menus, and dismissible notifications.

      Parameters

      • container: { container: HTMLElement }

        The element to animate and hide

      Returns void

      const panel = document.querySelector('.accordion-panel');
      shrinkThenRemove({ container: panel });
      // Panel smoothly collapses over 30 frames, then is hidden