How to use the body-scroll-lock.clearAllBodyScrollLocks function in body-scroll-lock

To help you get started, we’ve selected a few body-scroll-lock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thorgate / tg-modal / src / components / Modal.js View on Github external
// Add toggle body class and update body padding if there is only one modal open.
            if (numberOfModalsOpen === 1) {
                // Toggle open class.
                toggleClass(body, 'tg-modal-open', state);

                const { bodyScrollLock } = this.props;

                if (state) {
                    if (bodyScrollLock && this.node.current) {
                        disableBodyScroll(this.node.current, {
                            reserveScrollBarGap: true,
                        });
                    }
                } else if (bodyScrollLock && this.node.current) {
                    clearAllBodyScrollLocks();
                }
            }

            // Decrement modal count when closing.
            if (!state) {
                numberOfModalsOpen = Math.max(numberOfModalsOpen - 1, 0);
            }
        }
    }
github cozy / cozy-ui / react / Overlay / index.jsx View on Github external
componentWillUnmount() {
    // restauration function can be undefined if there was
    // an error during mounting/rendering
    clearAllBodyScrollLocks()
    if (this.props.onEscape) {
      document.removeEventListener('keydown', this.handleKeydown)
    }
  }
github getkirby / getkirby.com / src / js / templates / cheatsheet.js View on Github external
function clearScrollLocks() {
  clearAllBodyScrollLocks();
}
github poketo / poketo-reader / src / components / popover / popover.js View on Github external
componentDidUpdate(prevProps: Props, prevState: State) {
    if (
      prevProps.isShown !== this.props.isShown ||
      prevState.isShown !== this.state.isShown
    ) {
      const isShown = getIsShown(this.props, this.state);

      if (isShown === false) {
        clearAllBodyScrollLocks();
      } else {
        disableBodyScroll();
      }
    }
  }
github aredotna / ervell / react / components / UI / Modal / Portal.js View on Github external
componentWillUnmount() {
    this.el.parentNode.removeChild(this.el);
    clearAllBodyScrollLocks();
  }
github poketo / poketo-reader / src / components / panel.js View on Github external
componentDidUpdate(prevProps: PanelProps) {
    if (prevProps.isShown !== this.props.isShown) {
      if (this.props.isShown === false) {
        clearAllBodyScrollLocks();
      } else if (this.scrollEl) {
        disableBodyScroll(this.scrollEl);
      }
    }
  }

body-scroll-lock

Enables body scroll locking (for iOS Mobile and Tablet, Android, desktop Safari/Chrome/Firefox) without breaking scrolling of a target element (eg. modal/lightbox/flyouts/nav-menus)

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis