import { getBox } from "../../state/modules/box-models";
import deepEqual from "../../utils/deepEqual";
function pollBoxModel({
  element,
  onBoxModelChange
}) {
  let currentBoxModel = null;
  const handleAnimationFrameRequest = () => {
    const measuredBoxModel = element == null ? null : getBox(element);
    if (!deepEqual(currentBoxModel, measuredBoxModel)) {
      currentBoxModel = measuredBoxModel;
      onBoxModelChange(currentBoxModel);
    }
    animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
  };
  let animationFrameHandle = requestAnimationFrame(handleAnimationFrameRequest);
  return () => {
    cancelAnimationFrame(animationFrameHandle);
    onBoxModelChange(null);
  };
}
export {
  pollBoxModel
};
//# sourceMappingURL=poll-box-model.js.map