UNPKG

tdesign-vue-next

Version:
59 lines (53 loc) 1.96 kB
/** * tdesign v1.15.2 * (c) 2025 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var Vue = require('vue'); var observe = require('../../_chunks/dep-dd949e1b.js'); var dom = require('../../_chunks/dep-0a9c2d75.js'); require('../../_chunks/dep-040b3cbb.js'); require('../../_chunks/dep-0f5dd876.js'); require('../../_chunks/dep-3e1aa2e0.js'); require('../../_chunks/dep-79f734cc.js'); require('@babel/runtime/helpers/typeof'); require('../../_chunks/dep-63ff6e12.js'); require('../../_chunks/dep-c6c5ec69.js'); require('../../_chunks/dep-ce0157af.js'); require('../../_chunks/dep-41b6fe49.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 = !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