/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var _common_js_utils_observe = require('../../_common/js/utils/observe.js');
var utils_dom = require('../../utils/dom.js');
require('../../_chunks/dep-7f0559c3.js');
require('lodash/isString');
require('lodash/isFunction');
require('lodash/isArray');
require('../../utils/easing.js');

function useLazyLoad(containerRef, childRef, params) {
  var tRowHeight = vue.computed(function () {
    return Math.max(params.rowHeight || 48, 48);
  });
  var isInit = vue.ref(false);
  var hasLazyLoadHolder = vue.computed(function () {
    return (params === null || params === void 0 ? void 0 : params.type) === "lazy" && !isInit.value;
  });
  var requestAnimationFrame = !utils_dom.isServer && window.requestAnimationFrame || function (cb) {
    return setTimeout(cb, 16.6);
  };
  var init = function init() {
    if (!isInit.value) {
      requestAnimationFrame(function () {
        isInit.value = true;
      });
    }
  };
  vue.onMounted(function () {
    if ((params === null || params === void 0 ? void 0 : params.type) !== "lazy") return;
    vue.nextTick(function () {
      var bufferSize = Math.max(10, params.bufferSize || 10);
      var height = tRowHeight.value * bufferSize;
      _common_js_utils_observe["default"](childRef.value, containerRef.value, init, height);
    });
  });
  return {
    hasLazyLoadHolder: hasLazyLoadHolder,
    tRowHeight: tRowHeight
  };
}

exports["default"] = useLazyLoad;
//# sourceMappingURL=useLazyLoad.js.map
