src/DialogModalityMixin.js
function disableDocumentScrolling(element) {
  if (!document.documentElement) {
    return;
  }
  const documentWidth = document.documentElement.clientWidth;
  const scrollBarWidth = window.innerWidth - documentWidth;
  element[previousBodyOverflowKey] = document.body.style.overflow;
  element[previousDocumentMarginRightKey] = scrollBarWidth > 0 ?
    document.documentElement.style.marginRight :
    null;
  document.body.style.overflow = 'hidden';
  if (scrollBarWidth > 0) {
    document.documentElement.style.marginRight = `${scrollBarWidth}px`;
  }
}
function disableDocumentScrolling(element) {
  if (!document.documentElement) {
    return;
  }
  const documentWidth = document.documentElement.clientWidth;
  const scrollBarWidth = window.innerWidth - documentWidth;
  element[previousBodyOverflowKey] = document.body.style.overflow;
  element[previousDocumentMarginRightKey] = scrollBarWidth > 0 ?
    document.documentElement.style.marginRight :
    null;
  document.body.style.overflow = 'hidden';
  if (scrollBarWidth > 0) {
    document.documentElement.style.marginRight = `${scrollBarWidth}px`;
  }
}
function disableDocumentScrolling ( element ) { if ( ! document . documentElement ) { return ; } const documentWidth = document . documentElement . clientWidth ; const scrollBarWidth = window . innerWidth - documentWidth ; element [ previousBodyOverflowKey ] = document . body . style . overflow ; element [ previousDocumentMarginRightKey ] = scrollBarWidth > 0 ? document . documentElement . style . marginRight : null ; document . body . style . overflow = 'hidden' ; if ( scrollBarWidth > 0 ) { document . documentElement . style . marginRight = ` ${ scrollBarWidth } ` ; } }
Mark body as non-scrollable, to absorb space bar keypresses and other means of scrolling the top-level document.
Mark body as non - scrollable to absorb space bar keypresses and other means of scrolling the top - level document .