function preserveScrollDuring(view, fn) {
  const scrollData = [];
  let element = view.dom;
  while (element) {
    const top = element.scrollTop;
    const left = element.scrollLeft;
    if (top !== 0 || left !== 0) {
      scrollData.push({ element, top, left });
    }
    element = element.parentElement;
  }
  const scrollingElement = document.scrollingElement;
  if (scrollingElement) {
    const top = scrollingElement.scrollTop;
    const left = scrollingElement.scrollLeft;
    if (top !== 0 || left !== 0) {
      scrollData.push({ element: scrollingElement, top, left });
    }
  }
  fn();
  for (const { element: el, top, left } of scrollData) {
    if (el.scrollTop !== top) {
      el.scrollTop = top;
    }
    if (el.scrollLeft !== left) {
      el.scrollLeft = left;
    }
  }
}
export {
  preserveScrollDuring
};
//# sourceMappingURL=preserve-scroll.js.map
