UNPKG

tdesign-vue-next

Version:
58 lines (52 loc) 1.91 kB
/** * tdesign v1.11.5 * (c) 2025 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var Vue = require('vue'); var observe = require('../../_chunks/dep-9da21bcd.js'); var utils_dom = require('../../utils/dom.js'); require('../../_chunks/dep-30fb1b25.js'); require('../../_chunks/dep-047617bf.js'); require('../../_chunks/dep-bbe343d7.js'); require('@babel/runtime/helpers/typeof'); require('../../_chunks/dep-0a510359.js'); require('../../_chunks/dep-b8b9c2a3.js'); require('../../_chunks/dep-5ad8a2ab.js'); require('../../_chunks/dep-0c2ad01b.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; if (!(childRef !== null && childRef !== void 0 && childRef.value) || !(containerRef !== null && containerRef !== void 0 && containerRef.value)) return; observe.observe(childRef.value, containerRef.value, init, height); }); }); return { hasLazyLoadHolder: hasLazyLoadHolder, tRowHeight: tRowHeight }; } exports["default"] = useLazyLoad; //# sourceMappingURL=useLazyLoad.js.map