bind()

in content/frontend/default/directives/stick_to_footer.js [21:38]


  bind(el, { value }) {
    let contentHeight;
    const mainEl = document.querySelector(value);

    el.$_stickToFooter_listener = () => {
      if (!contentHeight) {
        contentHeight = el.getBoundingClientRect().height + NAV_TOP_MARGIN;
      }
      const { offsetHeight } = mainEl;
      const topOffset = getTopOffset(contentHeight, offsetHeight);

      el.style.top = topOffset < 0 ? `${topOffset}px` : '';
    };

    // When we scroll down to the bottom, we don't want the footer covering
    // the TOC list (sticky behavior)
    document.addEventListener('scroll', el.$_stickToFooter_listener, { passive: true });
  },