UNPKG

tdesign-vue-next

Version:
59 lines (53 loc) 1.96 kB
/** * tdesign v1.13.2 * (c) 2025 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var Vue = require('vue'); var observe = require('../../_chunks/dep-7901b68b.js'); var utils_dom = require('../../utils/dom.js'); require('../../_chunks/dep-5c9b4e07.js'); require('../../_chunks/dep-ac58e1cc.js'); require('../../_chunks/dep-6f35bfc1.js'); require('../../_chunks/dep-d17ed13a.js'); require('@babel/runtime/helpers/typeof'); require('../../_chunks/dep-c94e2f5d.js'); require('../../_chunks/dep-5c87313c.js'); require('../../_chunks/dep-8c59be4f.js'); require('../../_chunks/dep-86aa65fa.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