Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

621 B
Raw Blame
"use client";

import { useEffect } from "react";

export function SupportChatDynamicHeightMessenger() {
  useEffect(() => {
    document.body.style.overflow = "hidden";
    const update = () => {
      const height = document.body.scrollHeight;
      window.parent.postMessage(
        {
          originator: "Dub",
          event: "PAGE_HEIGHT",
          data: { height },
        },
        "*",
      );
    };
    update();

    const resizeObserver = new ResizeObserver(update);
    resizeObserver.observe(document.body);

    return () => {
      resizeObserver.disconnect();
    };
  }, []);

  return null;
}