export default {
  beforeMount(el, binding) {
    const select_dom = document.querySelector(
      `.${binding.arg} .el-select-dropdown__wrap`
    );
    function loadMore() {
      const isBase = this.scrollHeight - this.scrollTop <= this.clientHeight;
      if (isBase) {
        binding.value && binding.value();
      }
    }
    el.selectDomInfo = select_dom;
    el.selectLoadMore = loadMore;
    select_dom?.addEventListener("scroll", loadMore.bind(select_dom));
  },

  beforeUnmount(el) {
    if (el.selectLoadMore) {
      el.selectDomInfo.removeEventListener("scroll", el.selectLoadMore);
      delete el.selectDomInfo;
      delete el.selectLoadMore;
    }
  },
};
