lodash#delay JavaScript Examples

The following examples show how to use lodash#delay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Scrollable.js    From datapass with GNU Affero General Public License v3.0 6 votes vote down vote up
componentDidMount() {
    // Hackish way to trigger initial scroll.
    // As it's difficult to determine when all ScrollablePanels are fully rendered,
    // we suppose that after 500ms this is the case to avoid complex implementation.
    // Then we simply trigger the link by clicking on it.
    delay(() => {
      const hash = getWindowHash();
      if (!this.state.selected && this.props.scrollableId === hash) {
        document
          .querySelector(
            `.fr-sidemenu__item a[href="#${this.props.scrollableId}"]`
          )
          ?.click();
      }
    }, 500);

    return window.addEventListener('scroll', this.handleScroll);
  }