import { requestNewFrame } from "@veno-ui/utils";
import { bindScroll } from "./util";
function repositionScrollStrategy(data, _name) {
  let slow = false;
  let raf = -1;
  function update(e) {
    requestNewFrame(() => {
      const start = performance.now();
      data.updatePosition.value?.(e);
      const time = performance.now() - start;
      slow = time / (1e3 / 60) > 2;
    });
  }
  bindScroll(data.activatorEl.value ?? data.contentEl.value, (e) => {
    if (slow) {
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => {
        raf = requestAnimationFrame(() => {
          update(e);
        });
      });
    } else {
      update(e);
    }
  });
}
export {
  repositionScrollStrategy
};
//# sourceMappingURL=reposition.mjs.map
